fun main() = Valves.solve()

private object Valves {
    fun solve() {
        val nodes = readInput()
        val maxPressure = findMaxPressureRelease(nodes, "AA", 26)
        println("Max releasable pressure: ${maxPressure}")
    }

    private fun readInput(): Map<String, Node> = buildMap<String, Node> {
        generateSequence(::readLine).forEach {
            val groupValues =
                "Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? ([\\w ,]+)".toRegex()
                    .matchEntire(it)!!.groupValues
            val node = Node(
                groupValues[1],
                groupValues[2].toInt(10),
                groupValues[3].split(", ").toList()
            )
            put(node.label, node)
        }
    }

    private fun findMaxPressureRelease(nodes: Map<String, Node>, startPos: String, remainingTime: Int): Int {
        val distances = mutableMapOf<String, Int>()

        fun distanceKey(a: String, b: String) = listOf(a, b).sorted().joinToString("")

        fun distanceBetween(a: String, b: String): Int {
            if (a == b) {
                return 0
            }
            if (distanceKey(a, b) in distances) {
                return distances[distanceKey(a, b)]!!
            }
            val queue = mutableListOf(a)
            while (queue.isNotEmpty()) {
                val item = queue.removeFirst()
                if (item == b) {
                    return distances[distanceKey(a, item)]!!
                }
                val dist = distanceBetween(a, item)
                for (edge in nodes[item]!!.edges) {
                    if (distanceKey(a, edge) !in distances) {
                        distances[distanceKey(a, edge)] = dist + 1
                    }
                    if (edge !in queue) {
                        queue.add(edge)
                    }
                }
            }
            throw Error("Path not found $a->$b")
        }

        fun pathTime(path: List<String>): Int {
            var result = 0
            var prev = startPos
            for (item in path) {
                result += distanceBetween(prev, item) + 1
                prev = item
            }
            return result
        }

        fun pathFlowPair(first: List<String>, second: List<String>): Int {
            var result = 0
            var flow = 0
            val openValves = mutableSetOf<String>()
            fun openValve(valve: String) {
                if (valve in openValves) return
                openValves.add(valve)
                flow += nodes[valve]!!.pressure
            }

            val pathA = first.toMutableList()
            val pathB = second.toMutableList()
            var a = startPos
            var b = startPos
            var timeA = 0
            var timeB = 0
            var nextA: String? = null
            var nextB: String? = null
            for (i in 0..remainingTime) {
                result += flow
                if (i == timeA) {
                    if (i > 0 && nextA != null) {
                        a = nextA
                        openValve(a)
                    }
                    nextA = pathA.removeFirstOrNull()
                    if (nextA != null) {
                        timeA += distanceBetween(a, nextA) + 1
                    }
                }
                if (i == timeB) {
                    if (i > 0 && nextB != null) {
                        b = nextB
                        openValve(b)
                    }
                    nextB = pathB.removeFirstOrNull()
                    if (nextB != null) {
                        timeB += distanceBetween(b, nextB) + 1
                    }

                }
            }
            return result
        }

        val paths = mutableSetOf<List<String>>(listOf())
        val valves = nodes.keys.filter { nodes[it]!!.pressure > 0 }
        for (level in 0..valves.size) {
            println("$level")
            val newItems = mutableSetOf<List<String>>()
            for (valve in valves) {
                for (prefix in paths) {
                    if (valve in prefix) {
                        continue
                    }

                    val path = prefix.plus(valve)
                    if (path in paths) {
                        continue
                    }
//                    println("$valve $prefix")
                    if (pathTime(path) < remainingTime) {
                        newItems.add(path)
                    }
                }
            }

            if (!paths.addAll(newItems)) {
                break
            } else {
                //println("NI ${newItems.size}")
            }
        }
        println("Number of paths ${paths.size}")
        var max = 0
        var i = 0
        for (a in paths) {
            for (b in paths) {
                if (a != b) {
                    max = maxOf(max, pathFlowPair(a, b))
                }
            }
            i += 1
            println("$i")
        }
//        println("Distance ${distanceBetween("BB", "JJ")}")
//        val bestPath = paths.sortedBy { pathFlow(it) }.last()
//        println("Best path $bestPath")
        return max
    }

    data class Node(val label: String, val pressure: Int, val edges: List<String>)
}

Compiled from "Valves.kt"
final class Valves$readInput$1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {
  public static final Valves$readInput$1$1 INSTANCE;

  Valves$readInput$1$1();
    Code:
       0: aload_0
       1: iconst_0
       2: ldc           #11                 // class kotlin/io/ConsoleKt
       4: ldc           #13                 // String readLine
       6: ldc           #15                 // String readLine()Ljava/lang/String;
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.String invoke();
    Code:
       0: invokestatic  #24                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: areturn

  public java.lang.Object invoke();
    Code:
       0: aload_0
       1: invokevirtual #27                 // Method invoke:()Ljava/lang/String;
       4: areturn

  static {};
    Code:
       0: new           #2                  // class Valves$readInput$1$1
       3: dup
       4: invokespecial #30                 // Method "<init>":()V
       7: putstatic     #33                 // Field INSTANCE:LValves$readInput$1$1;
      10: return
}

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

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

  public final void solve();
    Code:
       0: aload_0
       1: invokespecial #15                 // Method readInput:()Ljava/util/Map;
       4: astore_1
       5: aload_0
       6: aload_1
       7: ldc           #17                 // String AA
       9: bipush        26
      11: invokespecial #21                 // Method findMaxPressureRelease:(Ljava/util/Map;Ljava/lang/String;I)I
      14: istore_2
      15: new           #23                 // class java/lang/StringBuilder
      18: dup
      19: invokespecial #24                 // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #26                 // String Max releasable pressure:
      24: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: invokevirtual #33                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      34: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      37: swap
      38: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      41: return

  private final java.util.Map<java.lang.String, Valves$Node> readInput();
    Code:
       0: invokestatic  #59                 // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;
       3: astore_1
       4: aload_1
       5: astore_2
       6: iconst_0
       7: istore_3
       8: getstatic     #65                 // Field Valves$readInput$1$1.INSTANCE:LValves$readInput$1$1;
      11: checkcast     #67                 // class kotlin/jvm/functions/Function0
      14: invokestatic  #73                 // Method kotlin/sequences/SequencesKt.generateSequence:(Lkotlin/jvm/functions/Function0;)Lkotlin/sequences/Sequence;
      17: astore        4
      19: iconst_0
      20: istore        5
      22: aload         4
      24: invokeinterface #79,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      29: astore        6
      31: aload         6
      33: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      38: ifeq          185
      41: aload         6
      43: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      48: astore        7
      50: aload         7
      52: checkcast     #91                 // class java/lang/String
      55: astore        8
      57: iconst_0
      58: istore        9
      60: new           #93                 // class kotlin/text/Regex
      63: dup
      64: ldc           #95                 // String Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? ([\\w ,]+)
      66: invokespecial #98                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      69: aload         8
      71: checkcast     #100                // class java/lang/CharSequence
      74: invokevirtual #104                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      77: dup
      78: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      81: invokeinterface #115,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      86: astore        10
      88: new           #117                // class Valves$Node
      91: dup
      92: aload         10
      94: iconst_1
      95: invokeinterface #123,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     100: checkcast     #91                 // class java/lang/String
     103: aload         10
     105: iconst_2
     106: invokeinterface #123,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     111: checkcast     #91                 // class java/lang/String
     114: bipush        10
     116: invokestatic  #129                // Method kotlin/text/CharsKt.checkRadix:(I)I
     119: invokestatic  #135                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
     122: aload         10
     124: iconst_3
     125: invokeinterface #123,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #100                // class java/lang/CharSequence
     133: iconst_1
     134: anewarray     #91                 // class java/lang/String
     137: astore        11
     139: aload         11
     141: iconst_0
     142: ldc           #137                // String ,
     144: aastore
     145: aload         11
     147: iconst_0
     148: iconst_0
     149: bipush        6
     151: aconst_null
     152: invokestatic  #143                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     155: checkcast     #145                // class java/lang/Iterable
     158: invokestatic  #151                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     161: invokespecial #154                // Method Valves$Node."<init>":(Ljava/lang/String;ILjava/util/List;)V
     164: astore        12
     166: aload_2
     167: aload         12
     169: invokevirtual #157                // Method Valves$Node.getLabel:()Ljava/lang/String;
     172: aload         12
     174: invokeinterface #163,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     179: pop
     180: nop
     181: nop
     182: goto          31
     185: nop
     186: nop
     187: aload_1
     188: invokestatic  #167                // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;
     191: areturn

  private final int findMaxPressureRelease(java.util.Map<java.lang.String, Valves$Node>, java.lang.String, int);
    Code:
       0: new           #184                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #185                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #159                // class java/util/Map
      10: astore        4
      12: iconst_1
      13: anewarray     #119                // class java/util/List
      16: astore        6
      18: aload         6
      20: iconst_0
      21: invokestatic  #188                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      24: aastore
      25: aload         6
      27: invokestatic  #194                // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      30: astore        5
      32: aload_1
      33: invokeinterface #198,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
      38: checkcast     #145                // class java/lang/Iterable
      41: astore        7
      43: iconst_0
      44: istore        8
      46: aload         7
      48: astore        9
      50: new           #200                // class java/util/ArrayList
      53: dup
      54: invokespecial #201                // Method java/util/ArrayList."<init>":()V
      57: checkcast     #203                // class java/util/Collection
      60: astore        10
      62: iconst_0
      63: istore        11
      65: aload         9
      67: invokeinterface #204,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      72: astore        12
      74: aload         12
      76: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      81: ifeq          145
      84: aload         12
      86: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      91: astore        13
      93: aload         13
      95: checkcast     #91                 // class java/lang/String
      98: astore        14
     100: iconst_0
     101: istore        15
     103: aload_1
     104: aload         14
     106: invokeinterface #207,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     111: dup
     112: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     115: checkcast     #117                // class Valves$Node
     118: invokevirtual #211                // Method Valves$Node.getPressure:()I
     121: ifle          128
     124: iconst_1
     125: goto          129
     128: iconst_0
     129: ifeq          74
     132: aload         10
     134: aload         13
     136: invokeinterface #215,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     141: pop
     142: goto          74
     145: aload         10
     147: checkcast     #119                // class java/util/List
     150: nop
     151: astore        6
     153: iconst_0
     154: istore        7
     156: aload         6
     158: invokeinterface #218,  1          // InterfaceMethod java/util/List.size:()I
     163: istore        8
     165: iload         7
     167: iload         8
     169: if_icmpgt     357
     172: iload         7
     174: invokestatic  #222                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     177: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     180: swap
     181: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     184: new           #224                // class java/util/LinkedHashSet
     187: dup
     188: invokespecial #225                // Method java/util/LinkedHashSet."<init>":()V
     191: checkcast     #227                // class java/util/Set
     194: astore        9
     196: aload         6
     198: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     203: astore        10
     205: aload         10
     207: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     212: ifeq          326
     215: aload         10
     217: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     222: checkcast     #91                 // class java/lang/String
     225: astore        11
     227: aload         5
     229: invokeinterface #229,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     234: astore        12
     236: aload         12
     238: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     243: ifeq          205
     246: aload         12
     248: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     253: checkcast     #119                // class java/util/List
     256: astore        13
     258: aload         13
     260: aload         11
     262: invokeinterface #232,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     267: ifeq          273
     270: goto          236
     273: aload         13
     275: checkcast     #203                // class java/util/Collection
     278: aload         11
     280: invokestatic  #236                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     283: astore        14
     285: aload         5
     287: aload         14
     289: invokeinterface #237,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     294: ifeq          300
     297: goto          236
     300: aload_2
     301: aload         4
     303: aload_1
     304: aload         14
     306: invokestatic  #241                // Method findMaxPressureRelease$pathTime:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;)I
     309: iload_3
     310: if_icmpge     236
     313: aload         9
     315: aload         14
     317: invokeinterface #242,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     322: pop
     323: goto          236
     326: aload         5
     328: aload         9
     330: checkcast     #203                // class java/util/Collection
     333: invokeinterface #246,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     338: ifne          344
     341: goto          357
     344: iload         7
     346: iload         8
     348: if_icmpeq     357
     351: iinc          7, 1
     354: goto          172
     357: new           #23                 // class java/lang/StringBuilder
     360: dup
     361: invokespecial #24                 // Method java/lang/StringBuilder."<init>":()V
     364: ldc           #248                // String Number of paths
     366: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     369: aload         5
     371: invokeinterface #249,  1          // InterfaceMethod java/util/Set.size:()I
     376: invokevirtual #33                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     379: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     382: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     385: swap
     386: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     389: iconst_0
     390: istore        7
     392: iconst_0
     393: istore        8
     395: aload         5
     397: invokeinterface #229,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     402: astore        9
     404: aload         9
     406: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     411: ifeq          507
     414: aload         9
     416: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     421: checkcast     #119                // class java/util/List
     424: astore        10
     426: aload         5
     428: invokeinterface #229,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     433: astore        11
     435: aload         11
     437: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     442: ifeq          489
     445: aload         11
     447: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     452: checkcast     #119                // class java/util/List
     455: astore        12
     457: aload         10
     459: aload         12
     461: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     464: ifne          435
     467: iload         7
     469: aload_2
     470: iload_3
     471: aload_1
     472: aload         4
     474: aload         10
     476: aload         12
     478: invokestatic  #257                // Method findMaxPressureRelease$pathFlowPair:(Ljava/lang/String;ILjava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;)I
     481: invokestatic  #263                // Method java/lang/Math.max:(II)I
     484: istore        7
     486: goto          435
     489: iinc          8, 1
     492: iload         8
     494: invokestatic  #222                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     497: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     500: swap
     501: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     504: goto          404
     507: iload         7
     509: ireturn

  private static final java.lang.String findMaxPressureRelease$distanceKey(java.lang.String, java.lang.String);
    Code:
       0: iconst_2
       1: anewarray     #91                 // class java/lang/String
       4: astore_2
       5: aload_2
       6: iconst_0
       7: aload_0
       8: aastore
       9: aload_2
      10: iconst_1
      11: aload_1
      12: aastore
      13: aload_2
      14: invokestatic  #294                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      17: checkcast     #145                // class java/lang/Iterable
      20: invokestatic  #297                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      23: checkcast     #145                // class java/lang/Iterable
      26: ldc_w         #299                // String
      29: checkcast     #100                // class java/lang/CharSequence
      32: aconst_null
      33: aconst_null
      34: iconst_0
      35: aconst_null
      36: aconst_null
      37: bipush        62
      39: aconst_null
      40: invokestatic  #303                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      43: areturn

  private static final int findMaxPressureRelease$distanceBetween(java.util.Map<java.lang.String, java.lang.Integer>, java.util.Map<java.lang.String, Valves$Node>, java.lang.String, java.lang.String);
    Code:
       0: aload_2
       1: aload_3
       2: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       5: ifeq          10
       8: iconst_0
       9: ireturn
      10: aload_0
      11: aload_2
      12: aload_3
      13: invokestatic  #308                // Method findMaxPressureRelease$distanceKey:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
      16: invokeinterface #311,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      21: ifeq          46
      24: aload_0
      25: aload_2
      26: aload_3
      27: invokestatic  #308                // Method findMaxPressureRelease$distanceKey:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
      30: invokeinterface #207,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      35: dup
      36: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      39: checkcast     #313                // class java/lang/Number
      42: invokevirtual #316                // Method java/lang/Number.intValue:()I
      45: ireturn
      46: iconst_1
      47: anewarray     #91                 // class java/lang/String
      50: astore        5
      52: aload         5
      54: iconst_0
      55: aload_2
      56: aastore
      57: aload         5
      59: invokestatic  #319                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      62: astore        4
      64: aload         4
      66: checkcast     #203                // class java/util/Collection
      69: invokeinterface #322,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      74: ifne          81
      77: iconst_1
      78: goto          82
      81: iconst_0
      82: ifeq          253
      85: aload         4
      87: invokeinterface #325,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      92: dup
      93: ldc_w         #327                // String removeFirst(...)
      96: invokestatic  #331                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      99: checkcast     #91                 // class java/lang/String
     102: astore        5
     104: aload         5
     106: aload_3
     107: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     110: ifeq          136
     113: aload_0
     114: aload_2
     115: aload         5
     117: invokestatic  #308                // Method findMaxPressureRelease$distanceKey:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
     120: invokeinterface #207,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     125: dup
     126: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     129: checkcast     #313                // class java/lang/Number
     132: invokevirtual #316                // Method java/lang/Number.intValue:()I
     135: ireturn
     136: aload_0
     137: aload_1
     138: aload_2
     139: aload         5
     141: invokestatic  #333                // Method findMaxPressureRelease$distanceBetween:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;)I
     144: istore        6
     146: aload_1
     147: aload         5
     149: invokeinterface #207,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     154: dup
     155: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     158: checkcast     #117                // class Valves$Node
     161: invokevirtual #336                // Method Valves$Node.getEdges:()Ljava/util/List;
     164: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     169: astore        7
     171: aload         7
     173: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          64
     181: aload         7
     183: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: checkcast     #91                 // class java/lang/String
     191: astore        8
     193: aload_0
     194: aload_2
     195: aload         8
     197: invokestatic  #308                // Method findMaxPressureRelease$distanceKey:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
     200: invokeinterface #311,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     205: ifne          228
     208: aload_0
     209: aload_2
     210: aload         8
     212: invokestatic  #308                // Method findMaxPressureRelease$distanceKey:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
     215: iload         6
     217: iconst_1
     218: iadd
     219: invokestatic  #339                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     222: invokeinterface #163,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     227: pop
     228: aload         4
     230: aload         8
     232: invokeinterface #232,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     237: ifne          171
     240: aload         4
     242: aload         8
     244: invokeinterface #340,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     249: pop
     250: goto          171
     253: new           #342                // class java/lang/Error
     256: dup
     257: new           #23                 // class java/lang/StringBuilder
     260: dup
     261: invokespecial #24                 // Method java/lang/StringBuilder."<init>":()V
     264: ldc_w         #344                // String Path not found
     267: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     270: aload_2
     271: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     274: ldc_w         #346                // String ->
     277: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     280: aload_3
     281: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     284: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     287: invokespecial #347                // Method java/lang/Error."<init>":(Ljava/lang/String;)V
     290: athrow

  private static final int findMaxPressureRelease$pathTime(java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>, java.util.Map<java.lang.String, Valves$Node>, java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore        4
       3: aload_0
       4: astore        5
       6: aload_3
       7: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      12: astore        6
      14: aload         6
      16: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          59
      24: aload         6
      26: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      31: checkcast     #91                 // class java/lang/String
      34: astore        7
      36: iload         4
      38: aload_1
      39: aload_2
      40: aload         5
      42: aload         7
      44: invokestatic  #333                // Method findMaxPressureRelease$distanceBetween:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;)I
      47: iconst_1
      48: iadd
      49: iadd
      50: istore        4
      52: aload         7
      54: astore        5
      56: goto          14
      59: iload         4
      61: ireturn

  private static final void findMaxPressureRelease$pathFlowPair$openValve(java.util.Set<java.lang.String>, kotlin.jvm.internal.Ref$IntRef, java.util.Map<java.lang.String, Valves$Node>, java.lang.String);
    Code:
       0: aload_0
       1: aload_3
       2: invokeinterface #237,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
       7: ifeq          11
      10: return
      11: aload_0
      12: aload_3
      13: invokeinterface #242,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
      18: pop
      19: aload_1
      20: aload_1
      21: getfield      #364                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      24: aload_2
      25: aload_3
      26: invokeinterface #207,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      31: dup
      32: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      35: checkcast     #117                // class Valves$Node
      38: invokevirtual #211                // Method Valves$Node.getPressure:()I
      41: iadd
      42: putfield      #364                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      45: return

  private static final int findMaxPressureRelease$pathFlowPair(java.lang.String, int, java.util.Map<java.lang.String, Valves$Node>, java.util.Map<java.lang.String, java.lang.Integer>, java.util.List<java.lang.String>, java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore        6
       3: new           #361                // class kotlin/jvm/internal/Ref$IntRef
       6: dup
       7: invokespecial #369                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
      10: astore        7
      12: new           #224                // class java/util/LinkedHashSet
      15: dup
      16: invokespecial #225                // Method java/util/LinkedHashSet."<init>":()V
      19: checkcast     #227                // class java/util/Set
      22: astore        8
      24: aload         4
      26: checkcast     #203                // class java/util/Collection
      29: invokestatic  #373                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      32: astore        9
      34: aload         5
      36: checkcast     #203                // class java/util/Collection
      39: invokestatic  #373                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      42: astore        10
      44: aload_0
      45: astore        11
      47: aload_0
      48: astore        12
      50: iconst_0
      51: istore        13
      53: iconst_0
      54: istore        14
      56: aconst_null
      57: astore        15
      59: aconst_null
      60: astore        16
      62: iconst_0
      63: istore        17
      65: iload         17
      67: iload_1
      68: if_icmpgt     217
      71: iload         6
      73: aload         7
      75: getfield      #364                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      78: iadd
      79: istore        6
      81: iload         17
      83: iload         13
      85: if_icmpne     143
      88: iload         17
      90: ifle          112
      93: aload         15
      95: ifnull        112
      98: aload         15
     100: astore        11
     102: aload         8
     104: aload         7
     106: aload_2
     107: aload         11
     109: invokestatic  #375                // Method findMaxPressureRelease$pathFlowPair$openValve:(Ljava/util/Set;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/Map;Ljava/lang/String;)V
     112: aload         9
     114: invokestatic  #379                // Method kotlin/collections/CollectionsKt.removeFirstOrNull:(Ljava/util/List;)Ljava/lang/Object;
     117: checkcast     #91                 // class java/lang/String
     120: astore        15
     122: aload         15
     124: ifnull        143
     127: iload         13
     129: aload_3
     130: aload_2
     131: aload         11
     133: aload         15
     135: invokestatic  #333                // Method findMaxPressureRelease$distanceBetween:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;)I
     138: iconst_1
     139: iadd
     140: iadd
     141: istore        13
     143: iload         17
     145: iload         14
     147: if_icmpne     205
     150: iload         17
     152: ifle          174
     155: aload         16
     157: ifnull        174
     160: aload         16
     162: astore        12
     164: aload         8
     166: aload         7
     168: aload_2
     169: aload         12
     171: invokestatic  #375                // Method findMaxPressureRelease$pathFlowPair$openValve:(Ljava/util/Set;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/Map;Ljava/lang/String;)V
     174: aload         10
     176: invokestatic  #379                // Method kotlin/collections/CollectionsKt.removeFirstOrNull:(Ljava/util/List;)Ljava/lang/Object;
     179: checkcast     #91                 // class java/lang/String
     182: astore        16
     184: aload         16
     186: ifnull        205
     189: iload         14
     191: aload_3
     192: aload_2
     193: aload         12
     195: aload         16
     197: invokestatic  #333                // Method findMaxPressureRelease$distanceBetween:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;)I
     200: iconst_1
     201: iadd
     202: iadd
     203: istore        14
     205: iload         17
     207: iload_1
     208: if_icmpeq     217
     211: iinc          17, 1
     214: goto          71
     217: iload         6
     219: ireturn

  static {};
    Code:
       0: new           #2                  // class Valves
       3: dup
       4: invokespecial #390                // Method "<init>":()V
       7: putstatic     #392                // Field INSTANCE:LValves;
      10: return
}

Compiled from "Valves.kt"
public final class ValvesKt {
  public static final void main();
    Code:
       0: getstatic     #12                 // Field Valves.INSTANCE:LValves;
       3: invokevirtual #15                 // Method Valves.solve:()V
       6: return

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

Compiled from "Valves.kt"
public final class Valves$Node {
  private final java.lang.String label;

  private final int pressure;

  private final java.util.List<java.lang.String> edges;

  public Valves$Node(java.lang.String, int, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String label
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #18                 // String edges
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokespecial #21                 // Method java/lang/Object."<init>":()V
      16: aload_0
      17: aload_1
      18: putfield      #24                 // Field label:Ljava/lang/String;
      21: aload_0
      22: iload_2
      23: putfield      #28                 // Field pressure:I
      26: aload_0
      27: aload_3
      28: putfield      #31                 // Field edges:Ljava/util/List;
      31: return

  public final java.lang.String getLabel();
    Code:
       0: aload_0
       1: getfield      #24                 // Field label:Ljava/lang/String;
       4: areturn

  public final int getPressure();
    Code:
       0: aload_0
       1: getfield      #28                 // Field pressure:I
       4: ireturn

  public final java.util.List<java.lang.String> getEdges();
    Code:
       0: aload_0
       1: getfield      #31                 // Field edges:Ljava/util/List;
       4: areturn

  public final java.lang.String component1();
    Code:
       0: aload_0
       1: getfield      #24                 // Field label:Ljava/lang/String;
       4: areturn

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

  public final java.util.List<java.lang.String> component3();
    Code:
       0: aload_0
       1: getfield      #31                 // Field edges:Ljava/util/List;
       4: areturn

  public final Valves$Node copy(java.lang.String, int, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String label
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #18                 // String edges
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class Valves$Node
      15: dup
      16: aload_1
      17: iload_2
      18: aload_3
      19: invokespecial #48                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
      22: areturn

  public static Valves$Node copy$default(Valves$Node, java.lang.String, int, java.util.List, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #24                 // Field label:Ljava/lang/String;
      11: astore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #28                 // Field pressure:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #31                 // Field edges:Ljava/util/List;
      35: astore_3
      36: aload_0
      37: aload_1
      38: iload_2
      39: aload_3
      40: invokevirtual #52                 // Method copy:(Ljava/lang/String;ILjava/util/List;)LValves$Node;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #55                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #58                 // String Node(label=
       9: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #24                 // Field label:Ljava/lang/String;
      16: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: ldc           #64                 // String , pressure=
      21: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #28                 // Field pressure:I
      28: invokevirtual #67                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #69                 // String , edges=
      33: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #31                 // Field edges:Ljava/util/List;
      40: invokevirtual #72                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #75                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #24                 // Field label:Ljava/lang/String;
       4: invokevirtual #82                 // Method java/lang/String.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #28                 // Field pressure:I
      16: invokestatic  #87                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #31                 // Field edges:Ljava/util/List;
      29: invokevirtual #88                 // Method java/lang/Object.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Valves$Node
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Valves$Node
      20: astore_2
      21: aload_0
      22: getfield      #24                 // Field label:Ljava/lang/String;
      25: aload_2
      26: getfield      #24                 // Field label:Ljava/lang/String;
      29: invokestatic  #96                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #28                 // Field pressure:I
      41: aload_2
      42: getfield      #28                 // Field pressure:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #31                 // Field edges:Ljava/util/List;
      54: aload_2
      55: getfield      #31                 // Field edges:Ljava/util/List;
      58: invokestatic  #96                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      61: ifne          66
      64: iconst_0
      65: ireturn
      66: iconst_1
      67: ireturn
}