// Monkey Math
// https://adventofcode.com/2022/day/21

import java.io.File
import java.util.ArrayDeque

typealias MonkeyMap = Map<String, List<String>>
typealias MutableValuesMap = MutableMap<String, Long>

fun debugPrint(msg: String, show: Boolean = false) = if (show) { println(msg) } else {}

fun readInput(): List<String> = File("input.txt").useLines { it.toList() }

fun parseMonkey(line: String): Pair<String, List<String>> {
    val components = line.split(": ")
    val value = components[1].split(" ")
    return components[0] to value
}

fun solvePart1(monkeys: MonkeyMap): Long {
    val values: MutableValuesMap = mutableMapOf()
    return solveFor("root", monkeys, values)
}

fun solvePart2(monkeys: MonkeyMap): Long {
    val values: MutableValuesMap = mutableMapOf()
    val rootExpr = monkeys["root"]!!

    val (humnMonkey, otherMonkey) = whichMonkeyLeadsToHumn(rootExpr[0], rootExpr[2], monkeys)
    val expectedValue = solveFor(otherMonkey, monkeys, values)
    return solveForHumn(humnMonkey, expectedValue, monkeys, values)
}

fun whichMonkeyLeadsToHumn(lhs: String, rhs: String, monkeys: MonkeyMap): Pair<String, String> =
    if (leadsToHumn(lhs, monkeys)) Pair(lhs, rhs) else Pair(rhs, lhs)

fun leadsToHumn(monkey: String, monkeys: MonkeyMap): Boolean {
    if (monkey == "humn") return true

    val expr = monkeys[monkey]!!
    if (expr.size == 1) return false

    return leadsToHumn(expr[0], monkeys) || leadsToHumn(expr[2], monkeys)
}

fun solveForHumn(monkey: String, expectedValue: Long, monkeys: MonkeyMap, values: MutableValuesMap): Long {
    if (monkey == "humn") {
        return expectedValue
    }

    val expr = monkeys[monkey]!!
    assert(expr.size == 3)

    val (humnMonkey, otherMonkey) = whichMonkeyLeadsToHumn(expr[0], expr[2], monkeys)
    val knownValue = solveFor(otherMonkey, monkeys, values)
    val newExpectedValue = evaluateInverse(expr[1], expectedValue, knownValue, humnMonkey == expr[0])

    return solveForHumn(humnMonkey, newExpectedValue, monkeys, values)
}

fun solveFor(monkey: String, monkeys: MonkeyMap, values: MutableValuesMap): Long {
    val value = values[monkey]
    if (value is Long) {
        return value
    }

    val expr = monkeys[monkey]!!
    if (expr.size == 1) {
        values[monkey] = expr[0].toLong()
        return values[monkey]!!
    }

    assert(expr.size == 3)
    val lhs = values[expr[0]] ?: solveFor(expr[0], monkeys, values)
    val rhs = values[expr[2]] ?: solveFor(expr[2], monkeys, values)
    values[monkey] = evaluate(expr[1], lhs, rhs)
    return values[monkey]!!
}

fun evaluate(op: String, lhs: Long, rhs: Long): Long {
    return when (op) {
        "+" -> lhs + rhs
        "-" -> lhs - rhs
        "*" -> lhs * rhs
        "/" -> lhs / rhs
        else -> throw IllegalArgumentException("Unexpected operator.")
    }
}

fun evaluateInverse(op: String, lhs: Long, rhs: Long, lhsIsHumn: Boolean): Long {
    return when (op) {
        "+" -> lhs - rhs
        "-" -> if (lhsIsHumn) lhs + rhs else rhs - lhs
        "*" -> lhs / rhs
        "/" -> lhs * rhs
        else -> throw IllegalArgumentException("Unexpected operator.")
    }
}

fun main() {
    val input = readInput()
    val monkeys: MonkeyMap = input.map { parseMonkey(it) }.toMap()

    val part1 = solvePart1(monkeys)
    println("Part 1: $part1")

    val part2 = solvePart2(monkeys)
    println("Part 2: $part2")
}

Compiled from "MonkeyMath.kt"
public final class MonkeyMathKt {
  public static final void debugPrint(java.lang.String, boolean);
    Code:
       0: aload_0
       1: ldc           #9                  // String msg
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: ifeq          17
      10: getstatic     #21                 // Field java/lang/System.out:Ljava/io/PrintStream;
      13: aload_0
      14: invokevirtual #27                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      17: return

  public static void debugPrint$default(java.lang.String, boolean, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #34                 // Method debugPrint:(Ljava/lang/String;Z)V
      13: return

  public static final java.util.List<java.lang.String> readInput();
    Code:
       0: new           #41                 // class java/io/File
       3: dup
       4: ldc           #43                 // String input.txt
       6: invokespecial #47                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: astore_0
      10: getstatic     #53                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_0
      17: astore_3
      18: sipush        8192
      21: istore        4
      23: aload_3
      24: astore        5
      26: new           #55                 // class java/io/InputStreamReader
      29: dup
      30: new           #57                 // class java/io/FileInputStream
      33: dup
      34: aload         5
      36: invokespecial #60                 // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      39: checkcast     #62                 // class java/io/InputStream
      42: aload_1
      43: invokespecial #65                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      46: checkcast     #67                 // class java/io/Reader
      49: astore        5
      51: aload         5
      53: instanceof    #69                 // class java/io/BufferedReader
      56: ifeq          67
      59: aload         5
      61: checkcast     #69                 // class java/io/BufferedReader
      64: goto          78
      67: new           #69                 // class java/io/BufferedReader
      70: dup
      71: aload         5
      73: iload         4
      75: invokespecial #72                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      78: checkcast     #74                 // class java/io/Closeable
      81: astore_3
      82: aconst_null
      83: astore        4
      85: nop
      86: aload_3
      87: checkcast     #69                 // class java/io/BufferedReader
      90: astore        5
      92: iconst_0
      93: istore        6
      95: aload         5
      97: invokestatic  #80                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     100: astore        7
     102: iconst_0
     103: istore        8
     105: aload         7
     107: invokestatic  #86                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     110: astore        5
     112: aload_3
     113: aload         4
     115: invokestatic  #92                 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     118: aload         5
     120: goto          143
     123: astore        6
     125: aload         6
     127: astore        4
     129: aload         6
     131: athrow
     132: astore        6
     134: aload_3
     135: aload         4
     137: invokestatic  #92                 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     140: aload         6
     142: athrow
     143: nop
     144: areturn
    Exception table:
       from    to  target type
          85   112   123   Class java/lang/Throwable
          85   112   132   any
         123   132   132   any
         132   134   132   any

  public static final kotlin.Pair<java.lang.String, java.util.List<java.lang.String>> parseMonkey(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #114                // String line
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #116                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #118                // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #120                // String :
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #126                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_1
      30: aload_1
      31: iconst_1
      32: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #116                // class java/lang/CharSequence
      40: iconst_1
      41: anewarray     #118                // class java/lang/String
      44: astore_3
      45: aload_3
      46: iconst_0
      47: ldc           #132                // String
      49: aastore
      50: aload_3
      51: iconst_0
      52: iconst_0
      53: bipush        6
      55: aconst_null
      56: invokestatic  #126                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      59: astore_2
      60: aload_1
      61: iconst_0
      62: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      67: aload_2
      68: invokestatic  #138                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      71: areturn

  public static final long solvePart1(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #146                // String monkeys
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #148                // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #151                // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #153                // class java/util/Map
      16: astore_1
      17: ldc           #155                // String root
      19: aload_0
      20: aload_1
      21: invokestatic  #159                // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J
      24: lreturn

  public static final long solvePart2(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #146                // String monkeys
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #148                // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #151                // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #153                // class java/util/Map
      16: astore_1
      17: aload_0
      18: ldc           #155                // String root
      20: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      25: dup
      26: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      29: checkcast     #107                // class java/util/List
      32: astore_2
      33: aload_2
      34: iconst_0
      35: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #118                // class java/lang/String
      43: aload_2
      44: iconst_2
      45: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #118                // class java/lang/String
      53: aload_0
      54: invokestatic  #172                // Method whichMonkeyLeadsToHumn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lkotlin/Pair;
      57: astore_3
      58: aload_3
      59: invokevirtual #178                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      62: checkcast     #118                // class java/lang/String
      65: astore        4
      67: aload_3
      68: invokevirtual #181                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      71: checkcast     #118                // class java/lang/String
      74: astore        5
      76: aload         5
      78: aload_0
      79: aload_1
      80: invokestatic  #159                // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J
      83: lstore        6
      85: aload         4
      87: lload         6
      89: aload_0
      90: aload_1
      91: invokestatic  #185                // Method solveForHumn:(Ljava/lang/String;JLjava/util/Map;Ljava/util/Map;)J
      94: lreturn

  public static final kotlin.Pair<java.lang.String, java.lang.String> whichMonkeyLeadsToHumn(java.lang.String, java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #193                // String lhs
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #195                // String rhs
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #146                // String monkeys
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: aload_2
      20: invokestatic  #199                // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z
      23: ifeq          38
      26: new           #174                // class kotlin/Pair
      29: dup
      30: aload_0
      31: aload_1
      32: invokespecial #202                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      35: goto          47
      38: new           #174                // class kotlin/Pair
      41: dup
      42: aload_1
      43: aload_0
      44: invokespecial #202                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      47: areturn

  public static final boolean leadsToHumn(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #205                // String monkey
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #146                // String monkeys
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: ldc           #207                // String humn
      15: invokestatic  #211                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      18: ifeq          23
      21: iconst_1
      22: ireturn
      23: aload_1
      24: aload_0
      25: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      30: dup
      31: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      34: checkcast     #107                // class java/util/List
      37: astore_2
      38: aload_2
      39: invokeinterface #215,  1          // InterfaceMethod java/util/List.size:()I
      44: iconst_1
      45: if_icmpne     50
      48: iconst_0
      49: ireturn
      50: aload_2
      51: iconst_0
      52: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      57: checkcast     #118                // class java/lang/String
      60: aload_1
      61: invokestatic  #199                // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z
      64: ifne          84
      67: aload_2
      68: iconst_2
      69: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      74: checkcast     #118                // class java/lang/String
      77: aload_1
      78: invokestatic  #199                // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z
      81: ifeq          88
      84: iconst_1
      85: goto          89
      88: iconst_0
      89: ireturn

  public static final long solveForHumn(java.lang.String, long, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Map<java.lang.String, java.lang.Long>);
    Code:
       0: aload_0
       1: ldc           #205                // String monkey
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #146                // String monkeys
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload         4
      14: ldc           #218                // String values
      16: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      19: aload_0
      20: ldc           #207                // String humn
      22: invokestatic  #211                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      25: ifeq          30
      28: lload_1
      29: lreturn
      30: aload_3
      31: aload_0
      32: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      37: dup
      38: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      41: checkcast     #107                // class java/util/List
      44: astore        5
      46: aload         5
      48: invokeinterface #215,  1          // InterfaceMethod java/util/List.size:()I
      53: iconst_3
      54: if_icmpne     61
      57: iconst_1
      58: goto          62
      61: iconst_0
      62: istore        6
      64: getstatic     #223                // Field kotlin/_Assertions.ENABLED:Z
      67: ifeq          89
      70: iload         6
      72: ifne          89
      75: ldc           #225                // String Assertion failed
      77: astore        7
      79: new           #227                // class java/lang/AssertionError
      82: dup
      83: aload         7
      85: invokespecial #229                // Method java/lang/AssertionError."<init>":(Ljava/lang/Object;)V
      88: athrow
      89: aload         5
      91: iconst_0
      92: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #118                // class java/lang/String
     100: aload         5
     102: iconst_2
     103: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #118                // class java/lang/String
     111: aload_3
     112: invokestatic  #172                // Method whichMonkeyLeadsToHumn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lkotlin/Pair;
     115: astore        6
     117: aload         6
     119: invokevirtual #178                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     122: checkcast     #118                // class java/lang/String
     125: astore        7
     127: aload         6
     129: invokevirtual #181                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     132: checkcast     #118                // class java/lang/String
     135: astore        8
     137: aload         8
     139: aload_3
     140: aload         4
     142: invokestatic  #159                // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J
     145: lstore        9
     147: aload         5
     149: iconst_1
     150: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     155: checkcast     #118                // class java/lang/String
     158: lload_1
     159: lload         9
     161: aload         7
     163: aload         5
     165: iconst_0
     166: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     171: invokestatic  #211                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     174: invokestatic  #233                // Method evaluateInverse:(Ljava/lang/String;JJZ)J
     177: lstore        11
     179: aload         7
     181: lload         11
     183: aload_3
     184: aload         4
     186: invokestatic  #185                // Method solveForHumn:(Ljava/lang/String;JLjava/util/Map;Ljava/util/Map;)J
     189: lreturn

  public static final long solveFor(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Map<java.lang.String, java.lang.Long>);
    Code:
       0: aload_0
       1: ldc           #205                // String monkey
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #146                // String monkeys
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #218                // String values
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_2
      19: aload_0
      20: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      25: checkcast     #238                // class java/lang/Long
      28: astore_3
      29: aload_3
      30: ifnull        38
      33: aload_3
      34: invokevirtual #242                // Method java/lang/Long.longValue:()J
      37: lreturn
      38: aload_1
      39: aload_0
      40: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      45: dup
      46: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      49: checkcast     #107                // class java/util/List
      52: astore        4
      54: aload         4
      56: invokeinterface #215,  1          // InterfaceMethod java/util/List.size:()I
      61: iconst_1
      62: if_icmpne     109
      65: nop
      66: aload_2
      67: aload_0
      68: aload         4
      70: iconst_0
      71: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #118                // class java/lang/String
      79: invokestatic  #246                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      82: invokestatic  #250                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      85: invokeinterface #254,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      90: pop
      91: aload_2
      92: aload_0
      93: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      98: dup
      99: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     102: checkcast     #256                // class java/lang/Number
     105: invokevirtual #257                // Method java/lang/Number.longValue:()J
     108: lreturn
     109: aload         4
     111: invokeinterface #215,  1          // InterfaceMethod java/util/List.size:()I
     116: iconst_3
     117: if_icmpne     124
     120: iconst_1
     121: goto          125
     124: iconst_0
     125: istore        5
     127: getstatic     #223                // Field kotlin/_Assertions.ENABLED:Z
     130: ifeq          152
     133: iload         5
     135: ifne          152
     138: ldc           #225                // String Assertion failed
     140: astore        6
     142: new           #227                // class java/lang/AssertionError
     145: dup
     146: aload         6
     148: invokespecial #229                // Method java/lang/AssertionError."<init>":(Ljava/lang/Object;)V
     151: athrow
     152: aload_2
     153: aload         4
     155: iconst_0
     156: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     161: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     166: checkcast     #238                // class java/lang/Long
     169: dup
     170: ifnull        179
     173: invokevirtual #242                // Method java/lang/Long.longValue:()J
     176: goto          196
     179: pop
     180: aload         4
     182: iconst_0
     183: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     188: checkcast     #118                // class java/lang/String
     191: aload_1
     192: aload_2
     193: invokestatic  #159                // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J
     196: lstore        5
     198: aload_2
     199: aload         4
     201: iconst_2
     202: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     207: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     212: checkcast     #238                // class java/lang/Long
     215: dup
     216: ifnull        225
     219: invokevirtual #242                // Method java/lang/Long.longValue:()J
     222: goto          242
     225: pop
     226: aload         4
     228: iconst_2
     229: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     234: checkcast     #118                // class java/lang/String
     237: aload_1
     238: aload_2
     239: invokestatic  #159                // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J
     242: lstore        7
     244: aload_2
     245: aload_0
     246: aload         4
     248: iconst_1
     249: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #118                // class java/lang/String
     257: lload         5
     259: lload         7
     261: invokestatic  #261                // Method evaluate:(Ljava/lang/String;JJ)J
     264: invokestatic  #250                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     267: invokeinterface #254,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     272: pop
     273: aload_2
     274: aload_0
     275: invokeinterface #165,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     280: dup
     281: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     284: checkcast     #256                // class java/lang/Number
     287: invokevirtual #257                // Method java/lang/Number.longValue:()J
     290: lreturn

  public static final long evaluate(java.lang.String, long, long);
    Code:
       0: aload_0
       1: ldc_w         #264                // String op
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: astore        5
      10: aload         5
      12: invokevirtual #267                // Method java/lang/String.hashCode:()I
      15: tableswitch   { // 42 to 47
                    42: 52
                    43: 66
                    44: 132
                    45: 80
                    46: 132
                    47: 94
               default: 132
          }
      52: aload         5
      54: ldc_w         #269                // String *
      57: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      60: ifne          120
      63: goto          132
      66: aload         5
      68: ldc_w         #275                // String +
      71: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      74: ifne          108
      77: goto          132
      80: aload         5
      82: ldc_w         #277                // String -
      85: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      88: ifne          114
      91: goto          132
      94: aload         5
      96: ldc_w         #279                // String /
      99: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          126
     105: goto          132
     108: lload_1
     109: lload_3
     110: ladd
     111: goto          143
     114: lload_1
     115: lload_3
     116: lsub
     117: goto          143
     120: lload_1
     121: lload_3
     122: lmul
     123: goto          143
     126: lload_1
     127: lload_3
     128: ldiv
     129: goto          143
     132: new           #281                // class java/lang/IllegalArgumentException
     135: dup
     136: ldc_w         #283                // String Unexpected operator.
     139: invokespecial #284                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     142: athrow
     143: lreturn

  public static final long evaluateInverse(java.lang.String, long, long, boolean);
    Code:
       0: aload_0
       1: ldc_w         #264                // String op
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: astore        6
      10: aload         6
      12: invokevirtual #267                // Method java/lang/String.hashCode:()I
      15: tableswitch   { // 42 to 47
                    42: 52
                    43: 66
                    44: 143
                    45: 80
                    46: 143
                    47: 94
               default: 143
          }
      52: aload         6
      54: ldc_w         #269                // String *
      57: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      60: ifne          131
      63: goto          143
      66: aload         6
      68: ldc_w         #275                // String +
      71: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      74: ifne          108
      77: goto          143
      80: aload         6
      82: ldc_w         #277                // String -
      85: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      88: ifne          114
      91: goto          143
      94: aload         6
      96: ldc_w         #279                // String /
      99: invokevirtual #273                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          137
     105: goto          143
     108: lload_1
     109: lload_3
     110: lsub
     111: goto          154
     114: iload         5
     116: ifeq          125
     119: lload_1
     120: lload_3
     121: ladd
     122: goto          154
     125: lload_3
     126: lload_1
     127: lsub
     128: goto          154
     131: lload_1
     132: lload_3
     133: ldiv
     134: goto          154
     137: lload_1
     138: lload_3
     139: lmul
     140: goto          154
     143: new           #281                // class java/lang/IllegalArgumentException
     146: dup
     147: ldc_w         #283                // String Unexpected operator.
     150: invokespecial #284                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     153: athrow
     154: lreturn

  public static final void main();
    Code:
       0: invokestatic  #288                // Method readInput:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: checkcast     #290                // class java/lang/Iterable
       8: astore_2
       9: iconst_0
      10: istore_3
      11: aload_2
      12: astore        4
      14: new           #292                // class java/util/ArrayList
      17: dup
      18: aload_2
      19: bipush        10
      21: invokestatic  #298                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #301                // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #303                // class java/util/Collection
      30: astore        5
      32: iconst_0
      33: istore        6
      35: aload         4
      37: invokeinterface #307,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        7
      44: aload         7
      46: invokeinterface #313,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          94
      54: aload         7
      56: invokeinterface #316,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        8
      63: aload         5
      65: aload         8
      67: checkcast     #118                // class java/lang/String
      70: astore        9
      72: astore        11
      74: iconst_0
      75: istore        10
      77: aload         9
      79: invokestatic  #318                // Method parseMonkey:(Ljava/lang/String;)Lkotlin/Pair;
      82: aload         11
      84: swap
      85: invokeinterface #321,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: goto          44
      94: aload         5
      96: checkcast     #107                // class java/util/List
      99: nop
     100: checkcast     #290                // class java/lang/Iterable
     103: invokestatic  #327                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     106: astore_1
     107: aload_1
     108: invokestatic  #329                // Method solvePart1:(Ljava/util/Map;)J
     111: lstore_2
     112: new           #331                // class java/lang/StringBuilder
     115: dup
     116: invokespecial #332                // Method java/lang/StringBuilder."<init>":()V
     119: ldc_w         #334                // String Part 1:
     122: invokevirtual #338                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     125: lload_2
     126: invokevirtual #341                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     129: invokevirtual #345                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     132: getstatic     #21                 // Field java/lang/System.out:Ljava/io/PrintStream;
     135: swap
     136: invokevirtual #27                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     139: aload_1
     140: invokestatic  #347                // Method solvePart2:(Ljava/util/Map;)J
     143: lstore        4
     145: new           #331                // class java/lang/StringBuilder
     148: dup
     149: invokespecial #332                // Method java/lang/StringBuilder."<init>":()V
     152: ldc_w         #349                // String Part 2:
     155: invokevirtual #338                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     158: lload         4
     160: invokevirtual #341                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     163: invokevirtual #345                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     166: getstatic     #21                 // Field java/lang/System.out:Ljava/io/PrintStream;
     169: swap
     170: invokevirtual #27                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     173: return

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


import java.util.concurrent.ThreadLocalRandom

data class CityPair(val city1: Int, val city2: Int)

class City(val id: Int, val name: String, val x: Double, val y: Double) {
    override fun toString() = name
    fun distanceTo(other: City) =CitiesAndDistances.distances[CityPair(id, other.id)]?:0.0
}

object CitiesAndDistances {

    val citiesById = CitiesAndDistances::class.java.getResource("cities.csv").readText().lines()
            .asSequence()
            .map { it.split(",") }
            .map { City(it[0].toInt(), it[1], it[2].toDouble(), it[3].toDouble()) }
            .map { it.id to it }
            .toMap()

    val citiesByString = citiesById.entries.asSequence()
            .map { it.value.name to it.value }
            .toMap()

    val cities = citiesById.values.toList()

    val distances = CitiesAndDistances::class.java.getResource("distances.csv").readText().lines()
            .asSequence()
            .map { it.split(",") }
            .map { CityPair(it[0].toInt(), it[1].toInt()) to it[2].toDouble() }
            .toMap()

    val distancesByStartCityId = distances.entries.asSequence()
            .map { it.key.city1 to (cities[it.key.city2] to it.value) }
            .groupBy({it.first},{it.second})

    val randomCity get() = ThreadLocalRandom.current().nextInt(0,CitiesAndDistances.cities.count()).let { CitiesAndDistances.cities[it] }
}

operator fun Map<CityPair,String>.get(city1: Int, city2: Int) = get(CityPair(city1,city2))
operator fun Map<CityPair,String>.get(city1: City, city2: City) = get(CityPair(city1.id,city2.id))

Compiled from "CitiesAndDistances.kt"
public final class CitiesAndDistancesKt {
  public static final java.lang.String get(java.util.Map<CityPair, java.lang.String>, int, int);
    Code:
       0: aload_0
       1: ldc           #11                 // String <this>
       3: invokestatic  #17                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: new           #19                 // class CityPair
      10: dup
      11: iload_1
      12: iload_2
      13: invokespecial #23                 // Method CityPair."<init>":(II)V
      16: invokeinterface #28,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      21: checkcast     #30                 // class java/lang/String
      24: areturn

  public static final java.lang.String get(java.util.Map<CityPair, java.lang.String>, City, City);
    Code:
       0: aload_0
       1: ldc           #11                 // String <this>
       3: invokestatic  #17                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #38                 // String city1
       9: invokestatic  #17                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #39                 // String city2
      15: invokestatic  #17                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: new           #19                 // class CityPair
      22: dup
      23: aload_1
      24: invokevirtual #45                 // Method City.getId:()I
      27: aload_2
      28: invokevirtual #45                 // Method City.getId:()I
      31: invokespecial #23                 // Method CityPair."<init>":(II)V
      34: invokeinterface #28,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      39: checkcast     #30                 // class java/lang/String
      42: areturn
}

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

  private static final java.util.Map<java.lang.Integer, City> citiesById;

  private static final java.util.Map<java.lang.String, City> citiesByString;

  private static final java.util.List<City> cities;

  private static final java.util.Map<CityPair, java.lang.Double> distances;

  private static final java.util.Map<java.lang.Integer, java.util.List<kotlin.Pair<City, java.lang.Double>>> distancesByStartCityId;

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

  public final java.util.Map<java.lang.Integer, City> getCitiesById();
    Code:
       0: getstatic     #18                 // Field citiesById:Ljava/util/Map;
       3: areturn

  public final java.util.Map<java.lang.String, City> getCitiesByString();
    Code:
       0: getstatic     #23                 // Field citiesByString:Ljava/util/Map;
       3: areturn

  public final java.util.List<City> getCities();
    Code:
       0: getstatic     #30                 // Field cities:Ljava/util/List;
       3: areturn

  public final java.util.Map<CityPair, java.lang.Double> getDistances();
    Code:
       0: getstatic     #35                 // Field distances:Ljava/util/Map;
       3: areturn

  public final java.util.Map<java.lang.Integer, java.util.List<kotlin.Pair<City, java.lang.Double>>> getDistancesByStartCityId();
    Code:
       0: getstatic     #40                 // Field distancesByStartCityId:Ljava/util/Map;
       3: areturn

  public final City getRandomCity();
    Code:
       0: invokestatic  #48                 // Method java/util/concurrent/ThreadLocalRandom.current:()Ljava/util/concurrent/ThreadLocalRandom;
       3: iconst_0
       4: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
       7: pop
       8: getstatic     #30                 // Field cities:Ljava/util/List;
      11: checkcast     #53                 // class java/util/Collection
      14: invokeinterface #57,  1           // InterfaceMethod java/util/Collection.size:()I
      19: invokevirtual #61                 // Method java/util/concurrent/ThreadLocalRandom.nextInt:(II)I
      22: istore_1
      23: iconst_0
      24: istore_2
      25: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
      28: pop
      29: getstatic     #30                 // Field cities:Ljava/util/List;
      32: iload_1
      33: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      38: checkcast     #69                 // class City
      41: nop
      42: areturn

  private static final java.util.List citiesById$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #83                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #85                 // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #87                 // String ,
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #93                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: areturn

  private static final City citiesById$lambda$1(java.util.List);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #69                 // class City
       9: dup
      10: aload_0
      11: iconst_0
      12: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: checkcast     #85                 // class java/lang/String
      20: invokestatic  #102                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      23: aload_0
      24: iconst_1
      25: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      30: checkcast     #85                 // class java/lang/String
      33: aload_0
      34: iconst_2
      35: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #85                 // class java/lang/String
      43: invokestatic  #108                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      46: aload_0
      47: iconst_3
      48: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      53: checkcast     #85                 // class java/lang/String
      56: invokestatic  #108                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      59: invokespecial #111                // Method City."<init>":(ILjava/lang/String;DD)V
      62: areturn

  private static final kotlin.Pair citiesById$lambda$2(City);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #116                // Method City.getId:()I
      10: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      13: aload_0
      14: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      17: areturn

  private static final kotlin.Pair citiesByString$lambda$3(java.util.Map$Entry);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #135,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      12: checkcast     #69                 // class City
      15: invokevirtual #139                // Method City.getName:()Ljava/lang/String;
      18: aload_0
      19: invokeinterface #135,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      24: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      27: areturn

  private static final java.util.List distances$lambda$4(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #83                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #85                 // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #87                 // String ,
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #93                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: areturn

  private static final kotlin.Pair distances$lambda$5(java.util.List);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #145                // class CityPair
       9: dup
      10: aload_0
      11: iconst_0
      12: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: checkcast     #85                 // class java/lang/String
      20: invokestatic  #102                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      23: aload_0
      24: iconst_1
      25: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      30: checkcast     #85                 // class java/lang/String
      33: invokestatic  #102                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      36: invokespecial #148                // Method CityPair."<init>":(II)V
      39: aload_0
      40: iconst_2
      41: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      46: checkcast     #85                 // class java/lang/String
      49: invokestatic  #108                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      52: invokestatic  #151                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      55: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      58: areturn

  private static final kotlin.Pair distancesByStartCityId$lambda$6(java.util.Map$Entry);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #155,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      12: checkcast     #145                // class CityPair
      15: invokevirtual #158                // Method CityPair.getCity1:()I
      18: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      21: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
      24: pop
      25: getstatic     #30                 // Field cities:Ljava/util/List;
      28: aload_0
      29: invokeinterface #155,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      34: checkcast     #145                // class CityPair
      37: invokevirtual #161                // Method CityPair.getCity2:()I
      40: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: aload_0
      46: invokeinterface #135,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      51: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      54: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      57: areturn

  static {};
    Code:
       0: new           #2                  // class CitiesAndDistances
       3: dup
       4: invokespecial #163                // Method "<init>":()V
       7: putstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
      10: ldc           #2                  // class CitiesAndDistances
      12: ldc           #165                // String cities.csv
      14: invokevirtual #171                // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      17: dup
      18: ldc           #173                // String getResource(...)
      20: invokestatic  #176                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      23: astore_0
      24: getstatic     #182                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      27: astore_1
      28: aload_0
      29: invokestatic  #188                // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      32: astore_2
      33: new           #85                 // class java/lang/String
      36: dup
      37: aload_2
      38: aload_1
      39: invokespecial #191                // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      42: checkcast     #83                 // class java/lang/CharSequence
      45: invokestatic  #195                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      48: checkcast     #197                // class java/lang/Iterable
      51: invokestatic  #203                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      54: invokedynamic #220,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      59: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      62: invokedynamic #231,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      67: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      70: invokedynamic #236,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
      75: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      78: invokestatic  #242                // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;
      81: putstatic     #18                 // Field citiesById:Ljava/util/Map;
      84: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
      87: pop
      88: getstatic     #18                 // Field citiesById:Ljava/util/Map;
      91: invokeinterface #248,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      96: checkcast     #197                // class java/lang/Iterable
      99: invokestatic  #203                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     102: invokedynamic #253,  0            // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;
     107: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     110: invokestatic  #242                // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;
     113: putstatic     #23                 // Field citiesByString:Ljava/util/Map;
     116: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
     119: pop
     120: getstatic     #18                 // Field citiesById:Ljava/util/Map;
     123: invokeinterface #257,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     128: checkcast     #197                // class java/lang/Iterable
     131: invokestatic  #261                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     134: putstatic     #30                 // Field cities:Ljava/util/List;
     137: ldc           #2                  // class CitiesAndDistances
     139: ldc_w         #263                // String distances.csv
     142: invokevirtual #171                // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
     145: dup
     146: ldc           #173                // String getResource(...)
     148: invokestatic  #176                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     151: astore_0
     152: getstatic     #182                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     155: astore_1
     156: aload_0
     157: invokestatic  #188                // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
     160: astore_2
     161: new           #85                 // class java/lang/String
     164: dup
     165: aload_2
     166: aload_1
     167: invokespecial #191                // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
     170: checkcast     #83                 // class java/lang/CharSequence
     173: invokestatic  #195                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
     176: checkcast     #197                // class java/lang/Iterable
     179: invokestatic  #203                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     182: invokedynamic #267,  0            // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;
     187: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     190: invokedynamic #272,  0            // InvokeDynamic #5:invoke:()Lkotlin/jvm/functions/Function1;
     195: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     198: invokestatic  #242                // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;
     201: putstatic     #35                 // Field distances:Ljava/util/Map;
     204: getstatic     #51                 // Field INSTANCE:LCitiesAndDistances;
     207: pop
     208: getstatic     #35                 // Field distances:Ljava/util/Map;
     211: invokeinterface #248,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     216: checkcast     #197                // class java/lang/Iterable
     219: invokestatic  #203                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     222: invokedynamic #276,  0            // InvokeDynamic #6:invoke:()Lkotlin/jvm/functions/Function1;
     227: invokestatic  #226                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     230: astore_0
     231: nop
     232: iconst_0
     233: istore_1
     234: aload_0
     235: astore_2
     236: new           #278                // class java/util/LinkedHashMap
     239: dup
     240: invokespecial #279                // Method java/util/LinkedHashMap."<init>":()V
     243: checkcast     #244                // class java/util/Map
     246: astore_3
     247: iconst_0
     248: istore        4
     250: aload_2
     251: invokeinterface #285,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     256: astore        5
     258: aload         5
     260: invokeinterface #291,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     265: ifeq          399
     268: aload         5
     270: invokeinterface #294,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     275: astore        6
     277: aload         6
     279: checkcast     #296                // class kotlin/Pair
     282: astore        7
     284: iconst_0
     285: istore        8
     287: aload         7
     289: invokevirtual #299                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     292: checkcast     #301                // class java/lang/Number
     295: invokevirtual #304                // Method java/lang/Number.intValue:()I
     298: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     301: astore        9
     303: aload_3
     304: astore        10
     306: iconst_0
     307: istore        11
     309: aload         10
     311: aload         9
     313: invokeinterface #306,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     318: astore        12
     320: aload         12
     322: ifnonnull     357
     325: iconst_0
     326: istore        13
     328: new           #308                // class java/util/ArrayList
     331: dup
     332: invokespecial #309                // Method java/util/ArrayList."<init>":()V
     335: checkcast     #63                 // class java/util/List
     338: astore        13
     340: aload         10
     342: aload         9
     344: aload         13
     346: invokeinterface #313,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     351: pop
     352: aload         13
     354: goto          359
     357: aload         12
     359: nop
     360: checkcast     #63                 // class java/util/List
     363: astore        7
     365: aload         7
     367: aload         6
     369: checkcast     #296                // class kotlin/Pair
     372: astore        8
     374: astore        15
     376: iconst_0
     377: istore        14
     379: aload         8
     381: invokevirtual #316                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     384: checkcast     #296                // class kotlin/Pair
     387: aload         15
     389: swap
     390: invokeinterface #320,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     395: pop
     396: goto          258
     399: aload_3
     400: nop
     401: putstatic     #40                 // Field distancesByStartCityId:Ljava/util/Map;
     404: return
}


import java.io.File

fun main() {
    fun readInput(name: String) = File("src/day04", name)
        .readLines()

    fun processInput(line: String): Pair<Pair<Int, Int>, Pair<Int, Int>> {
        val (range1, range2, _) = line.split(",").map { range ->
            range.split("-").map { it.toInt() }.let { (start, end, _) ->
                Pair(start, end)
            }
        }

        return Pair(range1, range2)
    }

    fun sign(n: Int): Int =
        if      (n > 0) { 1 }
        else if (n < 0) { -1 }
        else            { 0 }

    fun Pair<Int, Int>.contains(otherRange: Pair<Int, Int>): Boolean {
        val startDiff = this.first - otherRange.first
        val endDiff = this.second - otherRange.second

        return (sign(startDiff) >= 0) and (sign(endDiff) <= 0)
    }

    fun Pair<Int, Int>.overlaps(otherRange: Pair<Int, Int>): Boolean =
        (this.first <= otherRange.second) and (otherRange.first <= this.second)

    fun part1(input: List<String>): Int {
        var count = 0
        for (line in input) {
            val (range1, range2) = processInput(line)

            if (range1.contains(range2) or range2.contains(range1)) {
                ++count
            }
        }

        return count
    }

    fun part2(input: List<String>): Int {
        var count = 0
        for (line in input) {
            val (range1, range2) = processInput(line)

            if (range1.overlaps(range2)) {
                ++count
            }
        }

        return count
    }

    val input = readInput("input")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day04.kt"
public final class Day04Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String input
       2: invokestatic  #12                 // Method main$readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #22                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #28                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #31                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #22                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #28                 // Method java/io/PrintStream.println:(I)V
      30: return

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

  private static final java.util.List<java.lang.String> main$readInput(java.lang.String);
    Code:
       0: new           #40                 // class java/io/File
       3: dup
       4: ldc           #42                 // String src/day04
       6: aload_0
       7: invokespecial #46                 // Method java/io/File."<init>":(Ljava/lang/String;Ljava/lang/String;)V
      10: aconst_null
      11: iconst_1
      12: aconst_null
      13: invokestatic  #52                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      16: areturn

  private static final kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> main$processInput(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #59                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #61                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #63                 // String ,
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #69                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #71                 // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #73                 // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #83                 // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          293
      72: aload         7
      74: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #61                 // class java/lang/String
      88: astore        9
      90: astore        21
      92: iconst_0
      93: istore        10
      95: aload         9
      97: checkcast     #59                 // class java/lang/CharSequence
     100: iconst_1
     101: anewarray     #61                 // class java/lang/String
     104: astore        11
     106: aload         11
     108: iconst_0
     109: ldc           #99                 // String -
     111: aastore
     112: aload         11
     114: iconst_0
     115: iconst_0
     116: bipush        6
     118: aconst_null
     119: invokestatic  #69                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     122: checkcast     #71                 // class java/lang/Iterable
     125: astore        11
     127: iconst_0
     128: istore        12
     130: aload         11
     132: astore        13
     134: new           #73                 // class java/util/ArrayList
     137: dup
     138: aload         11
     140: bipush        10
     142: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     145: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     148: checkcast     #83                 // class java/util/Collection
     151: astore        14
     153: iconst_0
     154: istore        15
     156: aload         13
     158: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     163: astore        16
     165: aload         16
     167: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     172: ifeq          219
     175: aload         16
     177: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        17
     184: aload         14
     186: aload         17
     188: checkcast     #61                 // class java/lang/String
     191: astore        18
     193: astore        19
     195: iconst_0
     196: istore        20
     198: aload         18
     200: invokestatic  #105                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     203: nop
     204: invokestatic  #109                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     207: aload         19
     209: swap
     210: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     215: pop
     216: goto          165
     219: aload         14
     221: checkcast     #115                // class java/util/List
     224: nop
     225: astore        12
     227: iconst_0
     228: istore        13
     230: aload         12
     232: iconst_0
     233: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     238: checkcast     #121                // class java/lang/Number
     241: invokevirtual #125                // Method java/lang/Number.intValue:()I
     244: istore        14
     246: aload         12
     248: iconst_1
     249: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #121                // class java/lang/Number
     257: invokevirtual #125                // Method java/lang/Number.intValue:()I
     260: istore        15
     262: new           #127                // class kotlin/Pair
     265: dup
     266: iload         14
     268: invokestatic  #109                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     271: iload         15
     273: invokestatic  #109                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     276: invokespecial #130                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     279: nop
     280: nop
     281: aload         21
     283: swap
     284: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     289: pop
     290: goto          62
     293: aload         5
     295: checkcast     #115                // class java/util/List
     298: nop
     299: astore_1
     300: aload_1
     301: iconst_0
     302: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     307: checkcast     #127                // class kotlin/Pair
     310: astore_2
     311: aload_1
     312: iconst_1
     313: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     318: checkcast     #127                // class kotlin/Pair
     321: astore_3
     322: new           #127                // class kotlin/Pair
     325: dup
     326: aload_2
     327: aload_3
     328: invokespecial #130                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     331: areturn

  private static final int main$sign(int);
    Code:
       0: iload_0
       1: ifle          8
       4: iconst_1
       5: goto          17
       8: iload_0
       9: ifge          16
      12: iconst_m1
      13: goto          17
      16: iconst_0
      17: ireturn

  private static final boolean main$contains(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #160                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #121                // class java/lang/Number
       7: invokevirtual #125                // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokevirtual #160                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      14: checkcast     #121                // class java/lang/Number
      17: invokevirtual #125                // Method java/lang/Number.intValue:()I
      20: isub
      21: istore_2
      22: aload_0
      23: invokevirtual #163                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      26: checkcast     #121                // class java/lang/Number
      29: invokevirtual #125                // Method java/lang/Number.intValue:()I
      32: aload_1
      33: invokevirtual #163                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      36: checkcast     #121                // class java/lang/Number
      39: invokevirtual #125                // Method java/lang/Number.intValue:()I
      42: isub
      43: istore_3
      44: iload_2
      45: invokestatic  #165                // Method main$sign:(I)I
      48: iflt          55
      51: iconst_1
      52: goto          56
      55: iconst_0
      56: iload_3
      57: invokestatic  #165                // Method main$sign:(I)I
      60: ifgt          67
      63: iconst_1
      64: goto          68
      67: iconst_0
      68: iand
      69: ireturn

  private static final boolean main$overlaps(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #160                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #121                // class java/lang/Number
       7: invokevirtual #125                // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokevirtual #163                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #121                // class java/lang/Number
      17: invokevirtual #125                // Method java/lang/Number.intValue:()I
      20: if_icmpgt     27
      23: iconst_1
      24: goto          28
      27: iconst_0
      28: aload_1
      29: invokevirtual #160                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      32: checkcast     #121                // class java/lang/Number
      35: invokevirtual #125                // Method java/lang/Number.intValue:()I
      38: aload_0
      39: invokevirtual #163                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      42: checkcast     #121                // class java/lang/Number
      45: invokevirtual #125                // Method java/lang/Number.intValue:()I
      48: if_icmpgt     55
      51: iconst_1
      52: goto          56
      55: iconst_0
      56: iand
      57: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: invokeinterface #173,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       8: astore_2
       9: aload_2
      10: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      15: ifeq          78
      18: aload_2
      19: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      24: checkcast     #61                 // class java/lang/String
      27: astore_3
      28: aload_3
      29: invokestatic  #175                // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;
      32: astore        4
      34: aload         4
      36: invokevirtual #178                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      39: checkcast     #127                // class kotlin/Pair
      42: astore        5
      44: aload         4
      46: invokevirtual #181                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      49: checkcast     #127                // class kotlin/Pair
      52: astore        6
      54: aload         5
      56: aload         6
      58: invokestatic  #183                // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z
      61: aload         6
      63: aload         5
      65: invokestatic  #183                // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z
      68: ior
      69: ifeq          9
      72: iinc          1, 1
      75: goto          9
      78: iload_1
      79: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: invokeinterface #173,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       8: astore_2
       9: aload_2
      10: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      15: ifeq          70
      18: aload_2
      19: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      24: checkcast     #61                 // class java/lang/String
      27: astore_3
      28: aload_3
      29: invokestatic  #175                // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;
      32: astore        4
      34: aload         4
      36: invokevirtual #178                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      39: checkcast     #127                // class kotlin/Pair
      42: astore        5
      44: aload         4
      46: invokevirtual #181                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      49: checkcast     #127                // class kotlin/Pair
      52: astore        6
      54: aload         5
      56: aload         6
      58: invokestatic  #186                // Method main$overlaps:(Lkotlin/Pair;Lkotlin/Pair;)Z
      61: ifeq          9
      64: iinc          1, 1
      67: goto          9
      70: iload_1
      71: ireturn
}