package cz.wrent.advent

import java.lang.Integer.max
import java.util.Deque
import java.util.LinkedList

fun main() {
//	println(partOne(test))
//	val result = partOne(input)
//	println("16a: $result")
	println(partTwo(test))
	println("16b: ${partTwo(input)}")
}

private fun partOne(input: String): Int {
	val valves = input.toValves()
	calculateDistances(valves)

	return recursiveSolution(valves)
}

private fun recursiveSolution(valves: Map<String, Valve>): Int {
	val meaningful = valves.values.filter { it.flowRate > 0 }.sortedByDescending { it.flowRate }.map { it.label }

	return meaningful.map { process("AA", it, 30, 0, emptyList(), meaningful, valves) }.maxOf { it }
}

private fun process(
	current: String,
	next: String,
	minutes: Int,
	released: Int,
	opened: List<String>,
	meaningful: List<String>,
	valves: Map<String, Valve>
): Int {
	val distance = valves[current]!!.distances[next]!!
	val time = minutes - distance - 1

	if (time < 1) {
		return released
	}
	val nextReleased = released + time * valves[next]!!.flowRate
	val nextOpened = opened + next

	if (meaningful.size == nextOpened.size) {
		return nextReleased
	} else {
		return meaningful.filterNot { nextOpened.contains(it) }
			.map { process(next, it, time, nextReleased, nextOpened, meaningful, valves) }.maxOf { it }
	}
}

fun <T> List<T>.permutations(): List<List<T>> =
	if (isEmpty()) listOf(emptyList()) else mutableListOf<List<T>>().also { result ->
		for (i in this.indices) {
			(this - this[i]).permutations().forEach {
				result.add(it + this[i])
			}
		}
	}

private fun calculateDistances(valves: Map<String, Valve>) {
	valves.values.filter { it.label == "AA" || it.flowRate > 0 }.forEach { curr ->
		curr.distances = calculateDistances(curr, valves)
	}
}

private fun calculateDistances(from: Valve, valves: Map<String, Valve>): Map<String, Int> {
	val nextValves: Deque<Pair<String, Int>> = LinkedList(listOf(from.label to 0))
	val map = mutableMapOf<String, Int>()
	while (nextValves.isNotEmpty()) {
		val next = nextValves.pop()
		map[next.first] = next.second
		val nextValve = valves[next.first]!!
		val nextDistance = next.second + 1
		nextValve.leadsTo.forEach {
			if (map[it] == null || map[it]!! > nextDistance)
				nextValves.push(it to next.second + 1)
		}
	}
	return map
}

private fun partTwo(input: String): Int {
	val valves = input.toValves()
	calculateDistances(valves)

	return recursiveSolutionWithElephant(valves)
}

private fun recursiveSolutionWithElephant(valves: Map<String, Valve>): Int {
	val meaningful = valves.values.filter { it.flowRate > 0 }.sortedByDescending { it.flowRate }.map { it.label }

	return meaningful.map { i ->
		meaningful.map { j ->
			if (i == j) -1 else processWithElephant("AA", "AA", i, j, 26, 26, 0, emptyList(), meaningful, valves)
		}.maxOf { it }
	}.maxOf { it }
}

private fun processWithElephant(
	current: String,
	currentElephant: String,
	next: String,
	nextElephant: String,
	minutes: Int,
	elephantMinutes: Int,
	released: Int,
	opened: List<String>,
	meaningful: List<String>,
	valves: Map<String, Valve>
): Int {
	val distance = valves[current]!!.distances[next]!!
	val time = minutes - distance - 1

	val elephantDistance = valves[currentElephant]!!.distances[nextElephant]!!
	val elephantTime = elephantMinutes - elephantDistance - 1

	if (time < 1 && elephantTime < 1) {
		return released
	}
	var nextReleased = released
	var nextOpened = opened
	if (time > 0) {
		nextReleased += time * valves[next]!!.flowRate
		nextOpened = nextOpened + next
	}
	if (elephantTime > 0) {
		nextReleased += elephantTime * valves[nextElephant]!!.flowRate
		nextOpened = nextOpened + nextElephant
	}

	if (meaningful.size == nextOpened.size) {
		if (nextReleased > best) {
			best = nextReleased
			println(best)
		}
		return nextReleased
	} else {
		val filtered = meaningful.filterNot { nextOpened.contains(it) }
		if (!canBeBetterThanBest(nextReleased, max(time, elephantTime), filtered, valves)) {
			return -1
		}

		return filtered.map { i ->
			filtered.map { j ->
				if (i == j) -1 else processWithElephant(
					next,
					nextElephant,
					i,
					j,
					time,
					elephantTime,
					nextReleased,
					nextOpened,
					meaningful,
					valves
				)
			}.maxOf { it }
		}.maxOf { it }
	}
}

private fun canBeBetterThanBest(
	nextReleased: Int,
	max: Int,
	filtered: List<String>,
	valves: Map<String, Valve>
): Boolean {
	val b = nextReleased + filtered.mapIndexed { i, label ->
		valves[label]!!.flowRate * (max - (2 * i))
	}.sumOf { it }
//	println("$best : $b")
	return b > best
}

var best = 1488

private data class Next(
	val label: String,
	val time: Int,
	val released: Int,
	val alreadyReleased: MutableSet<String> = mutableSetOf()
)

private fun String.toValves(): Map<String, Valve> {
	val regex = Regex("Valve (.+) has flow rate=(\\d+); tunnels? leads? to valves? (.*)")
	return this.split("\n")
		.map { regex.matchEntire(it)!!.groupValues }
		.map { Valve(it.get(1), it.get(2).toInt(), it.get(3).split(", ")) }
		.map { it.label to it }
		.toMap()
}

private data class Valve(
	val label: String,
	val flowRate: Int,
	val leadsTo: List<String>,
	var opened: Boolean = false,
	var distances: Map<String, Int> = emptyMap()
)

private const val test = """Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II"""

private const val input =
	"""Valve QZ has flow rate=0; tunnels lead to valves IR, FA
Valve FV has flow rate=0; tunnels lead to valves AA, GZ
Valve GZ has flow rate=0; tunnels lead to valves FV, PO
Valve QL has flow rate=0; tunnels lead to valves MR, AA
Valve AA has flow rate=0; tunnels lead to valves QL, GQ, EV, FV
Valve SQ has flow rate=23; tunnel leads to valve ZG
Valve PK has flow rate=8; tunnels lead to valves MN, GN, WF, TY, CX
Valve GQ has flow rate=0; tunnels lead to valves AA, MT
Valve TI has flow rate=22; tunnels lead to valves GM, CS
Valve JU has flow rate=17; tunnels lead to valves TT, RR, UJ, JY
Valve YD has flow rate=7; tunnels lead to valves AT, ZS, BS
Valve YB has flow rate=0; tunnels lead to valves EA, MW
Valve FA has flow rate=0; tunnels lead to valves QZ, JT
Valve TN has flow rate=0; tunnels lead to valves ZS, PO
Valve MW has flow rate=0; tunnels lead to valves YB, YL
Valve XN has flow rate=0; tunnels lead to valves VL, VM
Valve MN has flow rate=0; tunnels lead to valves PK, TT
Valve IP has flow rate=9; tunnels lead to valves YC, SA, CH, PI
Valve PD has flow rate=0; tunnels lead to valves YZ, VM
Valve ZS has flow rate=0; tunnels lead to valves TN, YD
Valve PC has flow rate=0; tunnels lead to valves MR, XT
Valve VM has flow rate=13; tunnels lead to valves CX, XN, PD
Valve PO has flow rate=4; tunnels lead to valves GZ, TN, SA, XT, BM
Valve GN has flow rate=0; tunnels lead to valves PK, YL
Valve YL has flow rate=5; tunnels lead to valves MT, YZ, GN, SU, MW
Valve IR has flow rate=6; tunnels lead to valves LK, PI, BM, QZ, EV
Valve GM has flow rate=0; tunnels lead to valves TI, RH
Valve CS has flow rate=0; tunnels lead to valves UJ, TI
Valve EA has flow rate=18; tunnels lead to valves VL, YB, WF, JY
Valve LK has flow rate=0; tunnels lead to valves IR, MR
Valve BM has flow rate=0; tunnels lead to valves IR, PO
Valve JZ has flow rate=0; tunnels lead to valves RH, RR
Valve SA has flow rate=0; tunnels lead to valves IP, PO
Valve XT has flow rate=0; tunnels lead to valves PO, PC
Valve YC has flow rate=0; tunnels lead to valves IP, IL
Valve RH has flow rate=15; tunnels lead to valves WJ, JZ, GM
Valve CH has flow rate=0; tunnels lead to valves IP, BS
Valve JY has flow rate=0; tunnels lead to valves EA, JU
Valve TY has flow rate=0; tunnels lead to valves WJ, PK
Valve WJ has flow rate=0; tunnels lead to valves TY, RH
Valve IL has flow rate=0; tunnels lead to valves YC, MR
Valve BS has flow rate=0; tunnels lead to valves YD, CH
Valve AT has flow rate=0; tunnels lead to valves YD, UX
Valve UJ has flow rate=0; tunnels lead to valves CS, JU
Valve VL has flow rate=0; tunnels lead to valves EA, XN
Valve JT has flow rate=21; tunnels lead to valves ZG, FA
Valve UX has flow rate=10; tunnel leads to valve AT
Valve RR has flow rate=0; tunnels lead to valves JZ, JU
Valve TT has flow rate=0; tunnels lead to valves JU, MN
Valve MT has flow rate=0; tunnels lead to valves GQ, YL
Valve EV has flow rate=0; tunnels lead to valves AA, IR
Valve ZG has flow rate=0; tunnels lead to valves JT, SQ
Valve WF has flow rate=0; tunnels lead to valves EA, PK
Valve YZ has flow rate=0; tunnels lead to valves PD, YL
Valve MR has flow rate=3; tunnels lead to valves LK, IL, QL, SU, PC
Valve PI has flow rate=0; tunnels lead to valves IR, IP
Valve CX has flow rate=0; tunnels lead to valves VM, PK
Valve SU has flow rate=0; tunnels lead to valves YL, MR"""

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day16Kt$recursiveSolutionWithElephant$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day16Kt$recursiveSolutionWithElephant$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class cz/wrent/advent/Valve
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class cz/wrent/advent/Valve
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "Day16.kt"
public final class cz.wrent.advent.Day16Kt {
  private static int best;

  private static final java.lang.String test;

  private static final java.lang.String input;

  public static final void main();
    Code:
       0: ldc           #8                  // String Valve AA has flow rate=0; tunnels lead to valves DD, II, BB\nValve BB has flow rate=13; tunnels lead to valves CC, AA\nValve CC has flow rate=2; tunnels lead to valves DD, BB\nValve DD has flow rate=20; tunnels lead to valves CC, AA, EE\nValve EE has flow rate=3; tunnels lead to valves FF, DD\nValve FF has flow rate=0; tunnels lead to valves EE, GG\nValve GG has flow rate=0; tunnels lead to valves FF, HH\nValve HH has flow rate=22; tunnel leads to valve GG\nValve II has flow rate=0; tunnels lead to valves AA, JJ\nValve JJ has flow rate=21; tunnel leads to valve II
       2: invokestatic  #12                 // Method partTwo:(Ljava/lang/String;)I
       5: istore_0
       6: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: iload_0
      10: invokevirtual #24                 // Method java/io/PrintStream.println:(I)V
      13: new           #26                 // class java/lang/StringBuilder
      16: dup
      17: invokespecial #29                 // Method java/lang/StringBuilder."<init>":()V
      20: ldc           #31                 // String 16b:
      22: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: ldc           #37                 // String Valve QZ has flow rate=0; tunnels lead to valves IR, FA\nValve FV has flow rate=0; tunnels lead to valves AA, GZ\nValve GZ has flow rate=0; tunnels lead to valves FV, PO\nValve QL has flow rate=0; tunnels lead to valves MR, AA\nValve AA has flow rate=0; tunnels lead to valves QL, GQ, EV, FV\nValve SQ has flow rate=23; tunnel leads to valve ZG\nValve PK has flow rate=8; tunnels lead to valves MN, GN, WF, TY, CX\nValve GQ has flow rate=0; tunnels lead to valves AA, MT\nValve TI has flow rate=22; tunnels lead to valves GM, CS\nValve JU has flow rate=17; tunnels lead to valves TT, RR, UJ, JY\nValve YD has flow rate=7; tunnels lead to valves AT, ZS, BS\nValve YB has flow rate=0; tunnels lead to valves EA, MW\nValve FA has flow rate=0; tunnels lead to valves QZ, JT\nValve TN has flow rate=0; tunnels lead to valves ZS, PO\nValve MW has flow rate=0; tunnels lead to valves YB, YL\nValve XN has flow rate=0; tunnels lead to valves VL, VM\nValve MN has flow rate=0; tunnels lead to valves PK, TT\nValve IP has flow rate=9; tunnels lead to valves YC, SA, CH, PI\nValve PD has flow rate=0; tunnels lead to valves YZ, VM\nValve ZS has flow rate=0; tunnels lead to valves TN, YD\nValve PC has flow rate=0; tunnels lead to valves MR, XT\nValve VM has flow rate=13; tunnels lead to valves CX, XN, PD\nValve PO has flow rate=4; tunnels lead to valves GZ, TN, SA, XT, BM\nValve GN has flow rate=0; tunnels lead to valves PK, YL\nValve YL has flow rate=5; tunnels lead to valves MT, YZ, GN, SU, MW\nValve IR has flow rate=6; tunnels lead to valves LK, PI, BM, QZ, EV\nValve GM has flow rate=0; tunnels lead to valves TI, RH\nValve CS has flow rate=0; tunnels lead to valves UJ, TI\nValve EA has flow rate=18; tunnels lead to valves VL, YB, WF, JY\nValve LK has flow rate=0; tunnels lead to valves IR, MR\nValve BM has flow rate=0; tunnels lead to valves IR, PO\nValve JZ has flow rate=0; tunnels lead to valves RH, RR\nValve SA has flow rate=0; tunnels lead to valves IP, PO\nValve XT has flow rate=0; tunnels lead to valves PO, PC\nValve YC has flow rate=0; tunnels lead to valves IP, IL\nValve RH has flow rate=15; tunnels lead to valves WJ, JZ, GM\nValve CH has flow rate=0; tunnels lead to valves IP, BS\nValve JY has flow rate=0; tunnels lead to valves EA, JU\nValve TY has flow rate=0; tunnels lead to valves WJ, PK\nValve WJ has flow rate=0; tunnels lead to valves TY, RH\nValve IL has flow rate=0; tunnels lead to valves YC, MR\nValve BS has flow rate=0; tunnels lead to valves YD, CH\nValve AT has flow rate=0; tunnels lead to valves YD, UX\nValve UJ has flow rate=0; tunnels lead to valves CS, JU\nValve VL has flow rate=0; tunnels lead to valves EA, XN\nValve JT has flow rate=21; tunnels lead to valves ZG, FA\nValve UX has flow rate=10; tunnel leads to valve AT\nValve RR has flow rate=0; tunnels lead to valves JZ, JU\nValve TT has flow rate=0; tunnels lead to valves JU, MN\nValve MT has flow rate=0; tunnels lead to valves GQ, YL\nValve EV has flow rate=0; tunnels lead to valves AA, IR\nValve ZG has flow rate=0; tunnels lead to valves JT, SQ\nValve WF has flow rate=0; tunnels lead to valves EA, PK\nValve YZ has flow rate=0; tunnels lead to valves PD, YL\nValve MR has flow rate=3; tunnels lead to valves LK, IL, QL, SU, PC\nValve PI has flow rate=0; tunnels lead to valves IR, IP\nValve CX has flow rate=0; tunnels lead to valves VM, PK\nValve SU has flow rate=0; tunnels lead to valves YL, MR
      27: invokestatic  #12                 // Method partTwo:(Ljava/lang/String;)I
      30: invokevirtual #40                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: invokevirtual #44                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      36: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      39: swap
      40: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      43: return

  private static final int partOne(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #52                 // Method toValves:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_1
       5: aload_1
       6: invokestatic  #56                 // Method calculateDistances:(Ljava/util/Map;)V
       9: aload_1
      10: invokestatic  #60                 // Method recursiveSolution:(Ljava/util/Map;)I
      13: ireturn

  private static final int recursiveSolution(java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: aload_0
       1: invokeinterface #71,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
       6: checkcast     #73                 // class java/lang/Iterable
       9: astore_2
      10: iconst_0
      11: istore_3
      12: aload_2
      13: astore        4
      15: new           #75                 // class java/util/ArrayList
      18: dup
      19: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
      22: checkcast     #78                 // class java/util/Collection
      25: astore        5
      27: iconst_0
      28: istore        6
      30: aload         4
      32: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        7
      39: aload         7
      41: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          97
      49: aload         7
      51: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        8
      58: aload         8
      60: checkcast     #94                 // class cz/wrent/advent/Valve
      63: astore        9
      65: iconst_0
      66: istore        10
      68: aload         9
      70: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      73: ifle          80
      76: iconst_1
      77: goto          81
      80: iconst_0
      81: ifeq          39
      84: aload         5
      86: aload         8
      88: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          39
      97: aload         5
      99: checkcast     #104                // class java/util/List
     102: nop
     103: checkcast     #73                 // class java/lang/Iterable
     106: astore_2
     107: nop
     108: iconst_0
     109: istore_3
     110: aload_2
     111: new           #106                // class cz/wrent/advent/Day16Kt$recursiveSolution$$inlined$sortedByDescending$1
     114: dup
     115: invokespecial #107                // Method cz/wrent/advent/Day16Kt$recursiveSolution$$inlined$sortedByDescending$1."<init>":()V
     118: checkcast     #109                // class java/util/Comparator
     121: invokestatic  #115                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     124: checkcast     #73                 // class java/lang/Iterable
     127: astore_2
     128: nop
     129: iconst_0
     130: istore_3
     131: aload_2
     132: astore        4
     134: new           #75                 // class java/util/ArrayList
     137: dup
     138: aload_2
     139: bipush        10
     141: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     144: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     147: checkcast     #78                 // class java/util/Collection
     150: astore        5
     152: iconst_0
     153: istore        6
     155: aload         4
     157: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     162: astore        7
     164: aload         7
     166: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     171: ifeq          214
     174: aload         7
     176: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     181: astore        8
     183: aload         5
     185: aload         8
     187: checkcast     #94                 // class cz/wrent/advent/Valve
     190: astore        9
     192: astore        11
     194: iconst_0
     195: istore        10
     197: aload         9
     199: invokevirtual #124                // Method cz/wrent/advent/Valve.getLabel:()Ljava/lang/String;
     202: aload         11
     204: swap
     205: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          164
     214: aload         5
     216: checkcast     #104                // class java/util/List
     219: nop
     220: astore_1
     221: aload_1
     222: checkcast     #73                 // class java/lang/Iterable
     225: astore_2
     226: iconst_0
     227: istore_3
     228: aload_2
     229: astore        4
     231: new           #75                 // class java/util/ArrayList
     234: dup
     235: aload_2
     236: bipush        10
     238: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     241: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     244: checkcast     #78                 // class java/util/Collection
     247: astore        5
     249: iconst_0
     250: istore        6
     252: aload         4
     254: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     259: astore        7
     261: aload         7
     263: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifeq          324
     271: aload         7
     273: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     278: astore        8
     280: aload         5
     282: aload         8
     284: checkcast     #126                // class java/lang/String
     287: astore        9
     289: astore        11
     291: iconst_0
     292: istore        10
     294: ldc           #128                // String AA
     296: aload         9
     298: bipush        30
     300: iconst_0
     301: invokestatic  #132                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     304: aload_1
     305: aload_0
     306: invokestatic  #136                // Method process:(Ljava/lang/String;Ljava/lang/String;IILjava/util/List;Ljava/util/List;Ljava/util/Map;)I
     309: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     312: aload         11
     314: swap
     315: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     320: pop
     321: goto          261
     324: aload         5
     326: checkcast     #104                // class java/util/List
     329: nop
     330: checkcast     #73                 // class java/lang/Iterable
     333: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     338: astore_3
     339: aload_3
     340: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     345: ifne          356
     348: new           #144                // class java/util/NoSuchElementException
     351: dup
     352: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     355: athrow
     356: aload_3
     357: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     362: checkcast     #147                // class java/lang/Number
     365: invokevirtual #150                // Method java/lang/Number.intValue:()I
     368: istore        4
     370: iconst_0
     371: istore        5
     373: iload         4
     375: istore        4
     377: aload_3
     378: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     383: ifeq          421
     386: aload_3
     387: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     392: checkcast     #147                // class java/lang/Number
     395: invokevirtual #150                // Method java/lang/Number.intValue:()I
     398: istore        5
     400: iconst_0
     401: istore        6
     403: iload         5
     405: istore        5
     407: iload         4
     409: iload         5
     411: if_icmpge     377
     414: iload         5
     416: istore        4
     418: goto          377
     421: iload         4
     423: ireturn

  private static final int process(java.lang.String, java.lang.String, int, int, java.util.List<java.lang.String>, java.util.List<java.lang.String>, java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: aload         6
       2: aload_0
       3: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       8: dup
       9: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      12: checkcast     #94                 // class cz/wrent/advent/Valve
      15: invokevirtual #189                // Method cz/wrent/advent/Valve.getDistances:()Ljava/util/Map;
      18: aload_1
      19: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      24: dup
      25: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      28: checkcast     #147                // class java/lang/Number
      31: invokevirtual #150                // Method java/lang/Number.intValue:()I
      34: istore        7
      36: iload_2
      37: iload         7
      39: isub
      40: iconst_1
      41: isub
      42: istore        8
      44: iload         8
      46: iconst_1
      47: if_icmpge     52
      50: iload_3
      51: ireturn
      52: iload_3
      53: iload         8
      55: aload         6
      57: aload_1
      58: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      63: dup
      64: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      67: checkcast     #94                 // class cz/wrent/advent/Valve
      70: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      73: imul
      74: iadd
      75: istore        9
      77: aload         4
      79: checkcast     #78                 // class java/util/Collection
      82: aload_1
      83: invokestatic  #193                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      86: astore        10
      88: aload         5
      90: invokeinterface #196,  1          // InterfaceMethod java/util/List.size:()I
      95: aload         10
      97: invokeinterface #196,  1          // InterfaceMethod java/util/List.size:()I
     102: if_icmpne     108
     105: iload         9
     107: ireturn
     108: aload         5
     110: checkcast     #73                 // class java/lang/Iterable
     113: astore        11
     115: iconst_0
     116: istore        12
     118: aload         11
     120: astore        13
     122: new           #75                 // class java/util/ArrayList
     125: dup
     126: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
     129: checkcast     #78                 // class java/util/Collection
     132: astore        14
     134: iconst_0
     135: istore        15
     137: aload         13
     139: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     144: astore        16
     146: aload         16
     148: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     153: ifeq          200
     156: aload         16
     158: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     163: astore        17
     165: aload         17
     167: checkcast     #126                // class java/lang/String
     170: astore        18
     172: iconst_0
     173: istore        19
     175: aload         10
     177: aload         18
     179: invokeinterface #199,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     184: ifne          146
     187: aload         14
     189: aload         17
     191: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: goto          146
     200: aload         14
     202: checkcast     #104                // class java/util/List
     205: nop
     206: checkcast     #73                 // class java/lang/Iterable
     209: astore        11
     211: nop
     212: iconst_0
     213: istore        12
     215: aload         11
     217: astore        13
     219: new           #75                 // class java/util/ArrayList
     222: dup
     223: aload         11
     225: bipush        10
     227: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     230: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     233: checkcast     #78                 // class java/util/Collection
     236: astore        14
     238: iconst_0
     239: istore        15
     241: aload         13
     243: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     248: astore        16
     250: aload         16
     252: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     257: ifeq          314
     260: aload         16
     262: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: astore        17
     269: aload         14
     271: aload         17
     273: checkcast     #126                // class java/lang/String
     276: astore        18
     278: astore        20
     280: iconst_0
     281: istore        19
     283: aload_1
     284: aload         18
     286: iload         8
     288: iload         9
     290: aload         10
     292: aload         5
     294: aload         6
     296: invokestatic  #136                // Method process:(Ljava/lang/String;Ljava/lang/String;IILjava/util/List;Ljava/util/List;Ljava/util/Map;)I
     299: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     302: aload         20
     304: swap
     305: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     310: pop
     311: goto          250
     314: aload         14
     316: checkcast     #104                // class java/util/List
     319: nop
     320: checkcast     #73                 // class java/lang/Iterable
     323: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     328: astore        12
     330: aload         12
     332: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     337: ifne          348
     340: new           #144                // class java/util/NoSuchElementException
     343: dup
     344: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     347: athrow
     348: aload         12
     350: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     355: checkcast     #147                // class java/lang/Number
     358: invokevirtual #150                // Method java/lang/Number.intValue:()I
     361: istore        13
     363: iconst_0
     364: istore        14
     366: iload         13
     368: istore        13
     370: aload         12
     372: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     377: ifeq          416
     380: aload         12
     382: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     387: checkcast     #147                // class java/lang/Number
     390: invokevirtual #150                // Method java/lang/Number.intValue:()I
     393: istore        14
     395: iconst_0
     396: istore        15
     398: iload         14
     400: istore        14
     402: iload         13
     404: iload         14
     406: if_icmpge     370
     409: iload         14
     411: istore        13
     413: goto          370
     416: iload         13
     418: ireturn

  public static final <T> java.util.List<java.util.List<T>> permutations(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #220                // String <this>
       3: invokestatic  #224                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #227,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          24
      15: invokestatic  #132                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      18: invokestatic  #231                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      21: goto          161
      24: new           #75                 // class java/util/ArrayList
      27: dup
      28: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
      31: checkcast     #104                // class java/util/List
      34: astore_1
      35: aload_1
      36: astore_2
      37: iconst_0
      38: istore_3
      39: iconst_0
      40: istore        4
      42: aload_0
      43: checkcast     #78                 // class java/util/Collection
      46: invokeinterface #232,  1          // InterfaceMethod java/util/Collection.size:()I
      51: istore        5
      53: iload         4
      55: iload         5
      57: if_icmpge     159
      60: aload_0
      61: checkcast     #73                 // class java/lang/Iterable
      64: aload_0
      65: iload         4
      67: invokeinterface #235,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      72: invokestatic  #239                // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;
      75: invokestatic  #241                // Method permutations:(Ljava/util/List;)Ljava/util/List;
      78: checkcast     #73                 // class java/lang/Iterable
      81: astore        6
      83: iconst_0
      84: istore        7
      86: aload         6
      88: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      93: astore        8
      95: aload         8
      97: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     102: ifeq          152
     105: aload         8
     107: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     112: astore        9
     114: aload         9
     116: checkcast     #104                // class java/util/List
     119: astore        10
     121: iconst_0
     122: istore        11
     124: aload_2
     125: aload         10
     127: checkcast     #78                 // class java/util/Collection
     130: aload_0
     131: iload         4
     133: invokeinterface #235,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     138: invokestatic  #193                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     141: invokeinterface #242,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     146: pop
     147: nop
     148: nop
     149: goto          95
     152: nop
     153: iinc          4, 1
     156: goto          53
     159: nop
     160: aload_1
     161: areturn

  private static final void calculateDistances(java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: aload_0
       1: invokeinterface #71,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
       6: checkcast     #73                 // class java/lang/Iterable
       9: astore_1
      10: iconst_0
      11: istore_2
      12: aload_1
      13: astore_3
      14: new           #75                 // class java/util/ArrayList
      17: dup
      18: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
      21: checkcast     #78                 // class java/util/Collection
      24: astore        4
      26: iconst_0
      27: istore        5
      29: aload_3
      30: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      35: astore        6
      37: aload         6
      39: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      44: ifeq          108
      47: aload         6
      49: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      54: astore        7
      56: aload         7
      58: checkcast     #94                 // class cz/wrent/advent/Valve
      61: astore        8
      63: iconst_0
      64: istore        9
      66: aload         8
      68: invokevirtual #124                // Method cz/wrent/advent/Valve.getLabel:()Ljava/lang/String;
      71: ldc           #128                // String AA
      73: invokestatic  #255                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      76: ifne          87
      79: aload         8
      81: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      84: ifle          91
      87: iconst_1
      88: goto          92
      91: iconst_0
      92: ifeq          37
      95: aload         4
      97: aload         7
      99: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: goto          37
     108: aload         4
     110: checkcast     #104                // class java/util/List
     113: nop
     114: checkcast     #73                 // class java/lang/Iterable
     117: astore_1
     118: nop
     119: iconst_0
     120: istore_2
     121: aload_1
     122: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     127: astore_3
     128: aload_3
     129: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     134: ifeq          171
     137: aload_3
     138: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        4
     145: aload         4
     147: checkcast     #94                 // class cz/wrent/advent/Valve
     150: astore        5
     152: iconst_0
     153: istore        6
     155: aload         5
     157: aload         5
     159: aload_0
     160: invokestatic  #258                // Method calculateDistances:(Lcz/wrent/advent/Valve;Ljava/util/Map;)Ljava/util/Map;
     163: invokevirtual #261                // Method cz/wrent/advent/Valve.setDistances:(Ljava/util/Map;)V
     166: nop
     167: nop
     168: goto          128
     171: nop
     172: return

  private static final java.util.Map<java.lang.String, java.lang.Integer> calculateDistances(cz.wrent.advent.Valve, java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: new           #267                // class java/util/LinkedList
       3: dup
       4: aload_0
       5: invokevirtual #124                // Method cz/wrent/advent/Valve.getLabel:()Ljava/lang/String;
       8: iconst_0
       9: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: invokestatic  #273                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      15: invokestatic  #231                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      18: checkcast     #78                 // class java/util/Collection
      21: invokespecial #276                // Method java/util/LinkedList."<init>":(Ljava/util/Collection;)V
      24: checkcast     #278                // class java/util/Deque
      27: astore_2
      28: new           #280                // class java/util/LinkedHashMap
      31: dup
      32: invokespecial #281                // Method java/util/LinkedHashMap."<init>":()V
      35: checkcast     #67                 // class java/util/Map
      38: astore_3
      39: aload_2
      40: checkcast     #78                 // class java/util/Collection
      43: invokeinterface #282,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      48: ifne          55
      51: iconst_1
      52: goto          56
      55: iconst_0
      56: ifeq          243
      59: aload_2
      60: invokeinterface #285,  1          // InterfaceMethod java/util/Deque.pop:()Ljava/lang/Object;
      65: checkcast     #287                // class kotlin/Pair
      68: astore        4
      70: aload_3
      71: aload         4
      73: invokevirtual #290                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      76: aload         4
      78: invokevirtual #293                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      81: invokeinterface #297,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      86: pop
      87: aload_1
      88: aload         4
      90: invokevirtual #290                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      93: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      98: dup
      99: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     102: checkcast     #94                 // class cz/wrent/advent/Valve
     105: astore        5
     107: aload         4
     109: invokevirtual #293                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     112: checkcast     #147                // class java/lang/Number
     115: invokevirtual #150                // Method java/lang/Number.intValue:()I
     118: iconst_1
     119: iadd
     120: istore        6
     122: aload         5
     124: invokevirtual #300                // Method cz/wrent/advent/Valve.getLeadsTo:()Ljava/util/List;
     127: checkcast     #73                 // class java/lang/Iterable
     130: astore        7
     132: iconst_0
     133: istore        8
     135: aload         7
     137: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     142: astore        9
     144: aload         9
     146: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     151: ifeq          239
     154: aload         9
     156: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     161: astore        10
     163: aload         10
     165: checkcast     #126                // class java/lang/String
     168: astore        11
     170: iconst_0
     171: istore        12
     173: aload_3
     174: aload         11
     176: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     181: ifnull        207
     184: aload_3
     185: aload         11
     187: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     192: dup
     193: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     196: checkcast     #147                // class java/lang/Number
     199: invokevirtual #150                // Method java/lang/Number.intValue:()I
     202: iload         6
     204: if_icmple     234
     207: aload_2
     208: aload         11
     210: aload         4
     212: invokevirtual #293                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     215: checkcast     #147                // class java/lang/Number
     218: invokevirtual #150                // Method java/lang/Number.intValue:()I
     221: iconst_1
     222: iadd
     223: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     226: invokestatic  #273                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     229: invokeinterface #303,  2          // InterfaceMethod java/util/Deque.push:(Ljava/lang/Object;)V
     234: nop
     235: nop
     236: goto          144
     239: nop
     240: goto          39
     243: aload_3
     244: areturn

  private static final int partTwo(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #52                 // Method toValves:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_1
       5: aload_1
       6: invokestatic  #56                 // Method calculateDistances:(Ljava/util/Map;)V
       9: aload_1
      10: invokestatic  #314                // Method recursiveSolutionWithElephant:(Ljava/util/Map;)I
      13: ireturn

  private static final int recursiveSolutionWithElephant(java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: aload_0
       1: invokeinterface #71,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
       6: checkcast     #73                 // class java/lang/Iterable
       9: astore_2
      10: iconst_0
      11: istore_3
      12: aload_2
      13: astore        4
      15: new           #75                 // class java/util/ArrayList
      18: dup
      19: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
      22: checkcast     #78                 // class java/util/Collection
      25: astore        5
      27: iconst_0
      28: istore        6
      30: aload         4
      32: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        7
      39: aload         7
      41: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          97
      49: aload         7
      51: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        8
      58: aload         8
      60: checkcast     #94                 // class cz/wrent/advent/Valve
      63: astore        9
      65: iconst_0
      66: istore        10
      68: aload         9
      70: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      73: ifle          80
      76: iconst_1
      77: goto          81
      80: iconst_0
      81: ifeq          39
      84: aload         5
      86: aload         8
      88: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          39
      97: aload         5
      99: checkcast     #104                // class java/util/List
     102: nop
     103: checkcast     #73                 // class java/lang/Iterable
     106: astore_2
     107: nop
     108: iconst_0
     109: istore_3
     110: aload_2
     111: new           #316                // class cz/wrent/advent/Day16Kt$recursiveSolutionWithElephant$$inlined$sortedByDescending$1
     114: dup
     115: invokespecial #317                // Method cz/wrent/advent/Day16Kt$recursiveSolutionWithElephant$$inlined$sortedByDescending$1."<init>":()V
     118: checkcast     #109                // class java/util/Comparator
     121: invokestatic  #115                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     124: checkcast     #73                 // class java/lang/Iterable
     127: astore_2
     128: nop
     129: iconst_0
     130: istore_3
     131: aload_2
     132: astore        4
     134: new           #75                 // class java/util/ArrayList
     137: dup
     138: aload_2
     139: bipush        10
     141: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     144: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     147: checkcast     #78                 // class java/util/Collection
     150: astore        5
     152: iconst_0
     153: istore        6
     155: aload         4
     157: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     162: astore        7
     164: aload         7
     166: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     171: ifeq          214
     174: aload         7
     176: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     181: astore        8
     183: aload         5
     185: aload         8
     187: checkcast     #94                 // class cz/wrent/advent/Valve
     190: astore        9
     192: astore        21
     194: iconst_0
     195: istore        10
     197: aload         9
     199: invokevirtual #124                // Method cz/wrent/advent/Valve.getLabel:()Ljava/lang/String;
     202: aload         21
     204: swap
     205: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          164
     214: aload         5
     216: checkcast     #104                // class java/util/List
     219: nop
     220: astore_1
     221: aload_1
     222: checkcast     #73                 // class java/lang/Iterable
     225: astore_2
     226: iconst_0
     227: istore_3
     228: aload_2
     229: astore        4
     231: new           #75                 // class java/util/ArrayList
     234: dup
     235: aload_2
     236: bipush        10
     238: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     241: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     244: checkcast     #78                 // class java/util/Collection
     247: astore        5
     249: iconst_0
     250: istore        6
     252: aload         4
     254: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     259: astore        7
     261: aload         7
     263: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifeq          541
     271: aload         7
     273: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     278: astore        8
     280: aload         5
     282: aload         8
     284: checkcast     #126                // class java/lang/String
     287: astore        9
     289: astore        21
     291: iconst_0
     292: istore        10
     294: aload_1
     295: checkcast     #73                 // class java/lang/Iterable
     298: astore        11
     300: iconst_0
     301: istore        12
     303: aload         11
     305: astore        13
     307: new           #75                 // class java/util/ArrayList
     310: dup
     311: aload         11
     313: bipush        10
     315: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     318: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     321: checkcast     #78                 // class java/util/Collection
     324: astore        14
     326: iconst_0
     327: istore        15
     329: aload         13
     331: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     336: astore        16
     338: aload         16
     340: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     345: ifeq          421
     348: aload         16
     350: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     355: astore        17
     357: aload         14
     359: aload         17
     361: checkcast     #126                // class java/lang/String
     364: astore        18
     366: astore        19
     368: iconst_0
     369: istore        20
     371: aload         9
     373: aload         18
     375: invokestatic  #255                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     378: ifeq          385
     381: iconst_m1
     382: goto          406
     385: ldc           #128                // String AA
     387: ldc           #128                // String AA
     389: aload         9
     391: aload         18
     393: bipush        26
     395: bipush        26
     397: iconst_0
     398: invokestatic  #132                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     401: aload_1
     402: aload_0
     403: invokestatic  #321                // Method processWithElephant:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIILjava/util/List;Ljava/util/List;Ljava/util/Map;)I
     406: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     409: aload         19
     411: swap
     412: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     417: pop
     418: goto          338
     421: aload         14
     423: checkcast     #104                // class java/util/List
     426: nop
     427: checkcast     #73                 // class java/lang/Iterable
     430: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     435: astore        12
     437: aload         12
     439: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     444: ifne          455
     447: new           #144                // class java/util/NoSuchElementException
     450: dup
     451: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     454: athrow
     455: aload         12
     457: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     462: checkcast     #147                // class java/lang/Number
     465: invokevirtual #150                // Method java/lang/Number.intValue:()I
     468: istore        13
     470: iconst_0
     471: istore        14
     473: iload         13
     475: istore        13
     477: aload         12
     479: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     484: ifeq          523
     487: aload         12
     489: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     494: checkcast     #147                // class java/lang/Number
     497: invokevirtual #150                // Method java/lang/Number.intValue:()I
     500: istore        14
     502: iconst_0
     503: istore        15
     505: iload         14
     507: istore        14
     509: iload         13
     511: iload         14
     513: if_icmpge     477
     516: iload         14
     518: istore        13
     520: goto          477
     523: iload         13
     525: nop
     526: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     529: aload         21
     531: swap
     532: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     537: pop
     538: goto          261
     541: aload         5
     543: checkcast     #104                // class java/util/List
     546: nop
     547: checkcast     #73                 // class java/lang/Iterable
     550: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     555: astore_3
     556: aload_3
     557: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     562: ifne          573
     565: new           #144                // class java/util/NoSuchElementException
     568: dup
     569: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     572: athrow
     573: aload_3
     574: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     579: checkcast     #147                // class java/lang/Number
     582: invokevirtual #150                // Method java/lang/Number.intValue:()I
     585: istore        4
     587: iconst_0
     588: istore        5
     590: iload         4
     592: istore        4
     594: aload_3
     595: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     600: ifeq          638
     603: aload_3
     604: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     609: checkcast     #147                // class java/lang/Number
     612: invokevirtual #150                // Method java/lang/Number.intValue:()I
     615: istore        5
     617: iconst_0
     618: istore        6
     620: iload         5
     622: istore        5
     624: iload         4
     626: iload         5
     628: if_icmpge     594
     631: iload         5
     633: istore        4
     635: goto          594
     638: iload         4
     640: ireturn

  private static final int processWithElephant(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, int, java.util.List<java.lang.String>, java.util.List<java.lang.String>, java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: aload         9
       2: aload_0
       3: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       8: dup
       9: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      12: checkcast     #94                 // class cz/wrent/advent/Valve
      15: invokevirtual #189                // Method cz/wrent/advent/Valve.getDistances:()Ljava/util/Map;
      18: aload_2
      19: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      24: dup
      25: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      28: checkcast     #147                // class java/lang/Number
      31: invokevirtual #150                // Method java/lang/Number.intValue:()I
      34: istore        10
      36: iload         4
      38: iload         10
      40: isub
      41: iconst_1
      42: isub
      43: istore        11
      45: aload         9
      47: aload_1
      48: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      53: dup
      54: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      57: checkcast     #94                 // class cz/wrent/advent/Valve
      60: invokevirtual #189                // Method cz/wrent/advent/Valve.getDistances:()Ljava/util/Map;
      63: aload_3
      64: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      69: dup
      70: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      73: checkcast     #147                // class java/lang/Number
      76: invokevirtual #150                // Method java/lang/Number.intValue:()I
      79: istore        12
      81: iload         5
      83: iload         12
      85: isub
      86: iconst_1
      87: isub
      88: istore        13
      90: iload         11
      92: iconst_1
      93: if_icmpge     105
      96: iload         13
      98: iconst_1
      99: if_icmpge     105
     102: iload         6
     104: ireturn
     105: iconst_0
     106: istore        14
     108: iload         6
     110: istore        14
     112: aconst_null
     113: astore        15
     115: aload         7
     117: astore        15
     119: iload         11
     121: ifle          161
     124: iload         14
     126: iload         11
     128: aload         9
     130: aload_2
     131: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     136: dup
     137: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     140: checkcast     #94                 // class cz/wrent/advent/Valve
     143: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
     146: imul
     147: iadd
     148: istore        14
     150: aload         15
     152: checkcast     #78                 // class java/util/Collection
     155: aload_2
     156: invokestatic  #193                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     159: astore        15
     161: iload         13
     163: ifle          203
     166: iload         14
     168: iload         13
     170: aload         9
     172: aload_3
     173: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     178: dup
     179: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     182: checkcast     #94                 // class cz/wrent/advent/Valve
     185: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
     188: imul
     189: iadd
     190: istore        14
     192: aload         15
     194: checkcast     #78                 // class java/util/Collection
     197: aload_3
     198: invokestatic  #193                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     201: astore        15
     203: aload         8
     205: invokeinterface #196,  1          // InterfaceMethod java/util/List.size:()I
     210: aload         15
     212: invokeinterface #196,  1          // InterfaceMethod java/util/List.size:()I
     217: if_icmpne     249
     220: iload         14
     222: getstatic     #332                // Field best:I
     225: if_icmple     246
     228: iload         14
     230: putstatic     #332                // Field best:I
     233: getstatic     #332                // Field best:I
     236: istore        16
     238: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
     241: iload         16
     243: invokevirtual #24                 // Method java/io/PrintStream.println:(I)V
     246: iload         14
     248: ireturn
     249: aload         8
     251: checkcast     #73                 // class java/lang/Iterable
     254: astore        17
     256: iconst_0
     257: istore        18
     259: aload         17
     261: astore        19
     263: new           #75                 // class java/util/ArrayList
     266: dup
     267: invokespecial #76                 // Method java/util/ArrayList."<init>":()V
     270: checkcast     #78                 // class java/util/Collection
     273: astore        20
     275: iconst_0
     276: istore        21
     278: aload         19
     280: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     285: astore        22
     287: aload         22
     289: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifeq          341
     297: aload         22
     299: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     304: astore        23
     306: aload         23
     308: checkcast     #126                // class java/lang/String
     311: astore        24
     313: iconst_0
     314: istore        25
     316: aload         15
     318: aload         24
     320: invokeinterface #199,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     325: ifne          287
     328: aload         20
     330: aload         23
     332: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     337: pop
     338: goto          287
     341: aload         20
     343: checkcast     #104                // class java/util/List
     346: nop
     347: astore        16
     349: iload         14
     351: iload         11
     353: iload         13
     355: invokestatic  #336                // Method java/lang/Integer.max:(II)I
     358: aload         16
     360: aload         9
     362: invokestatic  #340                // Method canBeBetterThanBest:(IILjava/util/List;Ljava/util/Map;)Z
     365: ifne          370
     368: iconst_m1
     369: ireturn
     370: aload         16
     372: checkcast     #73                 // class java/lang/Iterable
     375: astore        17
     377: iconst_0
     378: istore        18
     380: aload         17
     382: astore        19
     384: new           #75                 // class java/util/ArrayList
     387: dup
     388: aload         17
     390: bipush        10
     392: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     395: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     398: checkcast     #78                 // class java/util/Collection
     401: astore        20
     403: iconst_0
     404: istore        21
     406: aload         19
     408: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     413: astore        22
     415: aload         22
     417: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     422: ifeq          697
     425: aload         22
     427: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     432: astore        23
     434: aload         20
     436: aload         23
     438: checkcast     #126                // class java/lang/String
     441: astore        24
     443: astore        36
     445: iconst_0
     446: istore        25
     448: aload         16
     450: checkcast     #73                 // class java/lang/Iterable
     453: astore        26
     455: iconst_0
     456: istore        27
     458: aload         26
     460: astore        28
     462: new           #75                 // class java/util/ArrayList
     465: dup
     466: aload         26
     468: bipush        10
     470: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     473: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     476: checkcast     #78                 // class java/util/Collection
     479: astore        29
     481: iconst_0
     482: istore        30
     484: aload         28
     486: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     491: astore        31
     493: aload         31
     495: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     500: ifeq          577
     503: aload         31
     505: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     510: astore        32
     512: aload         29
     514: aload         32
     516: checkcast     #126                // class java/lang/String
     519: astore        33
     521: astore        34
     523: iconst_0
     524: istore        35
     526: aload         24
     528: aload         33
     530: invokestatic  #255                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     533: ifeq          540
     536: iconst_m1
     537: goto          561
     540: aload_2
     541: aload_3
     542: aload         24
     544: aload         33
     546: iload         11
     548: iload         13
     550: iload         14
     552: aload         15
     554: aload         8
     556: aload         9
     558: invokestatic  #321                // Method processWithElephant:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIILjava/util/List;Ljava/util/List;Ljava/util/Map;)I
     561: nop
     562: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     565: aload         34
     567: swap
     568: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     573: pop
     574: goto          493
     577: aload         29
     579: checkcast     #104                // class java/util/List
     582: nop
     583: checkcast     #73                 // class java/lang/Iterable
     586: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     591: astore        27
     593: aload         27
     595: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     600: ifne          611
     603: new           #144                // class java/util/NoSuchElementException
     606: dup
     607: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     610: athrow
     611: aload         27
     613: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     618: checkcast     #147                // class java/lang/Number
     621: invokevirtual #150                // Method java/lang/Number.intValue:()I
     624: istore        28
     626: iconst_0
     627: istore        29
     629: iload         28
     631: istore        28
     633: aload         27
     635: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     640: ifeq          679
     643: aload         27
     645: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     650: checkcast     #147                // class java/lang/Number
     653: invokevirtual #150                // Method java/lang/Number.intValue:()I
     656: istore        29
     658: iconst_0
     659: istore        30
     661: iload         29
     663: istore        29
     665: iload         28
     667: iload         29
     669: if_icmpge     633
     672: iload         29
     674: istore        28
     676: goto          633
     679: iload         28
     681: nop
     682: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     685: aload         36
     687: swap
     688: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     693: pop
     694: goto          415
     697: aload         20
     699: checkcast     #104                // class java/util/List
     702: nop
     703: checkcast     #73                 // class java/lang/Iterable
     706: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     711: astore        18
     713: aload         18
     715: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     720: ifne          731
     723: new           #144                // class java/util/NoSuchElementException
     726: dup
     727: invokespecial #145                // Method java/util/NoSuchElementException."<init>":()V
     730: athrow
     731: aload         18
     733: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     738: checkcast     #147                // class java/lang/Number
     741: invokevirtual #150                // Method java/lang/Number.intValue:()I
     744: istore        19
     746: iconst_0
     747: istore        20
     749: iload         19
     751: istore        19
     753: aload         18
     755: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     760: ifeq          799
     763: aload         18
     765: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     770: checkcast     #147                // class java/lang/Number
     773: invokevirtual #150                // Method java/lang/Number.intValue:()I
     776: istore        20
     778: iconst_0
     779: istore        21
     781: iload         20
     783: istore        20
     785: iload         19
     787: iload         20
     789: if_icmpge     753
     792: iload         20
     794: istore        19
     796: goto          753
     799: iload         19
     801: ireturn

  private static final boolean canBeBetterThanBest(int, int, java.util.List<java.lang.String>, java.util.Map<java.lang.String, cz.wrent.advent.Valve>);
    Code:
       0: iload_0
       1: aload_2
       2: checkcast     #73                 // class java/lang/Iterable
       5: astore        5
       7: istore        17
       9: iconst_0
      10: istore        6
      12: aload         5
      14: astore        7
      16: new           #75                 // class java/util/ArrayList
      19: dup
      20: aload         5
      22: bipush        10
      24: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #78                 // class java/util/Collection
      33: astore        8
      35: iconst_0
      36: istore        9
      38: iconst_0
      39: istore        10
      41: aload         7
      43: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        11
      50: aload         11
      52: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          142
      60: aload         11
      62: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        12
      69: aload         8
      71: iload         10
      73: iinc          10, 1
      76: istore        13
      78: iload         13
      80: ifge          86
      83: invokestatic  #355                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      86: iload         13
      88: aload         12
      90: checkcast     #126                // class java/lang/String
      93: astore        14
      95: istore        15
      97: astore        18
      99: iconst_0
     100: istore        16
     102: aload_3
     103: aload         14
     105: invokeinterface #180,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     110: dup
     111: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     114: checkcast     #94                 // class cz/wrent/advent/Valve
     117: invokevirtual #98                 // Method cz/wrent/advent/Valve.getFlowRate:()I
     120: iload_1
     121: iconst_2
     122: iload         15
     124: imul
     125: isub
     126: imul
     127: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     130: aload         18
     132: swap
     133: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     138: pop
     139: goto          50
     142: aload         8
     144: checkcast     #104                // class java/util/List
     147: nop
     148: astore        18
     150: iload         17
     152: aload         18
     154: checkcast     #73                 // class java/lang/Iterable
     157: astore        5
     159: istore        17
     161: iconst_0
     162: istore        6
     164: aload         5
     166: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     171: astore        7
     173: aload         7
     175: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     180: ifeq          223
     183: aload         7
     185: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     190: astore        8
     192: iload         6
     194: aload         8
     196: checkcast     #147                // class java/lang/Number
     199: invokevirtual #150                // Method java/lang/Number.intValue:()I
     202: istore        9
     204: istore        18
     206: iconst_0
     207: istore        10
     209: iload         9
     211: istore        19
     213: iload         18
     215: iload         19
     217: iadd
     218: istore        6
     220: goto          173
     223: iload         6
     225: istore        18
     227: iload         17
     229: iload         18
     231: iadd
     232: istore        4
     234: iload         4
     236: getstatic     #332                // Field best:I
     239: if_icmple     246
     242: iconst_1
     243: goto          247
     246: iconst_0
     247: ireturn

  public static final int getBest();
    Code:
       0: getstatic     #332                // Field best:I
       3: ireturn

  public static final void setBest(int);
    Code:
       0: iload_0
       1: putstatic     #332                // Field best:I
       4: return

  private static final java.util.Map<java.lang.String, cz.wrent.advent.Valve> toValves(java.lang.String);
    Code:
       0: new           #370                // class kotlin/text/Regex
       3: dup
       4: ldc_w         #372                // String Valve (.+) has flow rate=(\\d+); tunnels? leads? to valves? (.*)
       7: invokespecial #375                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      10: astore_1
      11: aload_0
      12: checkcast     #377                // class java/lang/CharSequence
      15: iconst_1
      16: anewarray     #126                // class java/lang/String
      19: astore_2
      20: aload_2
      21: iconst_0
      22: ldc_w         #379                // String \n
      25: aastore
      26: aload_2
      27: iconst_0
      28: iconst_0
      29: bipush        6
      31: aconst_null
      32: invokestatic  #385                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      35: checkcast     #73                 // class java/lang/Iterable
      38: astore_2
      39: nop
      40: iconst_0
      41: istore_3
      42: aload_2
      43: astore        4
      45: new           #75                 // class java/util/ArrayList
      48: dup
      49: aload_2
      50: bipush        10
      52: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      55: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
      58: checkcast     #78                 // class java/util/Collection
      61: astore        5
      63: iconst_0
      64: istore        6
      66: aload         4
      68: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      73: astore        7
      75: aload         7
      77: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      82: ifeq          138
      85: aload         7
      87: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      92: astore        8
      94: aload         5
      96: aload         8
      98: checkcast     #126                // class java/lang/String
     101: astore        9
     103: astore        12
     105: iconst_0
     106: istore        10
     108: aload_1
     109: aload         9
     111: checkcast     #377                // class java/lang/CharSequence
     114: invokevirtual #389                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     117: dup
     118: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     121: invokeinterface #394,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     126: aload         12
     128: swap
     129: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     134: pop
     135: goto          75
     138: aload         5
     140: checkcast     #104                // class java/util/List
     143: nop
     144: checkcast     #73                 // class java/lang/Iterable
     147: astore_2
     148: nop
     149: iconst_0
     150: istore_3
     151: aload_2
     152: astore        4
     154: new           #75                 // class java/util/ArrayList
     157: dup
     158: aload_2
     159: bipush        10
     161: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     164: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     167: checkcast     #78                 // class java/util/Collection
     170: astore        5
     172: iconst_0
     173: istore        6
     175: aload         4
     177: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     182: astore        7
     184: aload         7
     186: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     191: ifeq          300
     194: aload         7
     196: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        8
     203: aload         5
     205: aload         8
     207: checkcast     #104                // class java/util/List
     210: astore        9
     212: astore        12
     214: iconst_0
     215: istore        10
     217: new           #94                 // class cz/wrent/advent/Valve
     220: dup
     221: aload         9
     223: iconst_1
     224: invokeinterface #235,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     229: checkcast     #126                // class java/lang/String
     232: aload         9
     234: iconst_2
     235: invokeinterface #235,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     240: checkcast     #126                // class java/lang/String
     243: invokestatic  #397                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     246: aload         9
     248: iconst_3
     249: invokeinterface #235,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #377                // class java/lang/CharSequence
     257: iconst_1
     258: anewarray     #126                // class java/lang/String
     261: astore        11
     263: aload         11
     265: iconst_0
     266: ldc_w         #399                // String ,
     269: aastore
     270: aload         11
     272: iconst_0
     273: iconst_0
     274: bipush        6
     276: aconst_null
     277: invokestatic  #385                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     280: iconst_0
     281: aconst_null
     282: bipush        24
     284: aconst_null
     285: invokespecial #402                // Method cz/wrent/advent/Valve."<init>":(Ljava/lang/String;ILjava/util/List;ZLjava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     288: aload         12
     290: swap
     291: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     296: pop
     297: goto          184
     300: aload         5
     302: checkcast     #104                // class java/util/List
     305: nop
     306: checkcast     #73                 // class java/lang/Iterable
     309: astore_2
     310: nop
     311: iconst_0
     312: istore_3
     313: aload_2
     314: astore        4
     316: new           #75                 // class java/util/ArrayList
     319: dup
     320: aload_2
     321: bipush        10
     323: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     326: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
     329: checkcast     #78                 // class java/util/Collection
     332: astore        5
     334: iconst_0
     335: istore        6
     337: aload         4
     339: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     344: astore        7
     346: aload         7
     348: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     353: ifeq          401
     356: aload         7
     358: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     363: astore        8
     365: aload         5
     367: aload         8
     369: checkcast     #94                 // class cz/wrent/advent/Valve
     372: astore        9
     374: astore        12
     376: iconst_0
     377: istore        10
     379: aload         9
     381: invokevirtual #124                // Method cz/wrent/advent/Valve.getLabel:()Ljava/lang/String;
     384: aload         9
     386: invokestatic  #273                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     389: aload         12
     391: swap
     392: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     397: pop
     398: goto          346
     401: aload         5
     403: checkcast     #104                // class java/util/List
     406: nop
     407: checkcast     #73                 // class java/lang/Iterable
     410: invokestatic  #408                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     413: areturn

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

  static {};
    Code:
       0: sipush        1488
       3: putstatic     #332                // Field best:I
       6: return
}

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day16Kt$recursiveSolution$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day16Kt$recursiveSolution$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class cz/wrent/advent/Valve
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class cz/wrent/advent/Valve
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method cz/wrent/advent/Valve.getFlowRate:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}