import java.io.File
import java.util.Scanner

fun schedulePIntreeP1LMax(
    deadlines: MutableList<Int>,
    m: Int,
    fromTo: Map<Int, Int>,
    toFrom: Map<Int, List<Int>>,
): Pair<Int, List<Int>> {
    val i = deadlines.indices.find { it !in fromTo }!!

    val deque = ArrayDeque<Int>()
    deque += i

    while (deque.isNotEmpty()) {
        val j = deque.removeFirst()
        toFrom[j].orEmpty().forEach { k ->
            deadlines[k] = minOf(deadlines[k], deadlines[j] - 1)
            deque.addLast(k)
        }
    }

    var f = 0
    val r = MutableList(deadlines.size) { 0 }
    val q = MutableList(deadlines.size) { 0 }
    val x = MutableList(deadlines.size) { 0 }

    deadlines.asSequence().withIndex().sortedBy { it.value }.map { it.index }.forEach { i ->
        val t = maxOf(r[i], f)
        x[i] = t
        q[t] += 1

        if (q[t] == m) {
            f = t + 1
        }

        fromTo[i]?.let { j -> r[j] = maxOf(r[j], t + 1) }
    }

    val l = deadlines.asSequence().zip(x.asSequence()).maxOf { (d, c) -> c + 1 - d }
    return l to x
}

fun main() {
    val input = Scanner(File("pintreep1l.in").bufferedReader())

    val n = input.nextInt()
    val m = input.nextInt()
    val deadlines = MutableList(n) { input.nextInt() }
    val fromTo = mutableMapOf<Int, Int>()
    val toFrom = mutableMapOf<Int, MutableList<Int>>()
    repeat(n - 1) {
        val from = input.nextInt() - 1
        val to = input.nextInt() - 1
        fromTo[from] = to
        toFrom.getOrPut(to) { mutableListOf() }.add(from)
    }

    val (lMax, schedule) = schedulePIntreeP1LMax(deadlines, m, fromTo, toFrom)

    File("pintreep1l.out").printWriter().use { output ->
        output.println(lMax)
        schedule.forEach { output.print("$it ") }
    }
}

Compiled from "Comparisons.kt"
public final class LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$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_1
       1: checkcast     #23                 // class kotlin/collections/IndexedValue
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Integer
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/collections/IndexedValue
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Integer
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "lPIntreeP1LMax.kt"
public final class LPIntreeP1LMaxKt {
  public static final kotlin.Pair<java.lang.Integer, java.util.List<java.lang.Integer>> schedulePIntreeP1LMax(java.util.List<java.lang.Integer>, int, java.util.Map<java.lang.Integer, java.lang.Integer>, java.util.Map<java.lang.Integer, ? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #10                 // String deadlines
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #18                 // String fromTo
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #20                 // String toFrom
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: checkcast     #22                 // class java/util/Collection
      22: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      25: checkcast     #30                 // class java/lang/Iterable
      28: astore        6
      30: aload         6
      32: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        7
      39: aload         7
      41: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          99
      49: aload         7
      51: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        8
      58: aload         8
      60: checkcast     #46                 // class java/lang/Number
      63: invokevirtual #50                 // Method java/lang/Number.intValue:()I
      66: istore        9
      68: iconst_0
      69: istore        10
      71: iload         9
      73: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: aload_2
      77: swap
      78: invokeinterface #62,  2           // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      83: ifne          90
      86: iconst_1
      87: goto          91
      90: iconst_0
      91: ifeq          39
      94: aload         8
      96: goto          100
      99: aconst_null
     100: dup
     101: invokestatic  #66                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     104: checkcast     #46                 // class java/lang/Number
     107: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     110: istore        4
     112: new           #68                 // class kotlin/collections/ArrayDeque
     115: dup
     116: invokespecial #72                 // Method kotlin/collections/ArrayDeque."<init>":()V
     119: astore        5
     121: iload         4
     123: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     126: astore        7
     128: aload         5
     130: checkcast     #22                 // class java/util/Collection
     133: aload         7
     135: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     140: pop
     141: aload         5
     143: checkcast     #22                 // class java/util/Collection
     146: invokeinterface #78,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     151: ifne          158
     154: iconst_1
     155: goto          159
     158: iconst_0
     159: ifeq          311
     162: aload         5
     164: invokevirtual #81                 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;
     167: checkcast     #46                 // class java/lang/Number
     170: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     173: istore        6
     175: aload_3
     176: iload         6
     178: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     181: invokeinterface #85,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     186: checkcast     #87                 // class java/util/List
     189: dup
     190: ifnonnull     197
     193: pop
     194: invokestatic  #91                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     197: checkcast     #30                 // class java/lang/Iterable
     200: astore        7
     202: nop
     203: iconst_0
     204: istore        8
     206: aload         7
     208: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     213: astore        9
     215: aload         9
     217: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     222: ifeq          307
     225: aload         9
     227: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     232: astore        10
     234: aload         10
     236: checkcast     #46                 // class java/lang/Number
     239: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     242: istore        11
     244: iconst_0
     245: istore        12
     247: aload_0
     248: iload         11
     250: aload_0
     251: iload         11
     253: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     258: checkcast     #46                 // class java/lang/Number
     261: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     264: aload_0
     265: iload         6
     267: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     272: checkcast     #46                 // class java/lang/Number
     275: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     278: iconst_1
     279: isub
     280: invokestatic  #100                // Method java/lang/Math.min:(II)I
     283: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     286: invokeinterface #104,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     291: pop
     292: aload         5
     294: iload         11
     296: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     299: invokevirtual #107                // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V
     302: nop
     303: nop
     304: goto          215
     307: nop
     308: goto          141
     311: iconst_0
     312: istore        6
     314: aload_0
     315: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     320: istore        8
     322: new           #112                // class java/util/ArrayList
     325: dup
     326: iload         8
     328: invokespecial #115                // Method java/util/ArrayList."<init>":(I)V
     331: astore        9
     333: iconst_0
     334: istore        10
     336: iload         10
     338: iload         8
     340: if_icmpge     375
     343: iload         10
     345: istore        11
     347: aload         9
     349: iload         11
     351: istore        12
     353: astore        19
     355: iconst_0
     356: istore        13
     358: iconst_0
     359: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     362: aload         19
     364: swap
     365: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     368: pop
     369: iinc          10, 1
     372: goto          336
     375: aload         9
     377: checkcast     #87                 // class java/util/List
     380: astore        7
     382: aload_0
     383: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     388: istore        9
     390: new           #112                // class java/util/ArrayList
     393: dup
     394: iload         9
     396: invokespecial #115                // Method java/util/ArrayList."<init>":(I)V
     399: astore        10
     401: iconst_0
     402: istore        11
     404: iload         11
     406: iload         9
     408: if_icmpge     443
     411: iload         11
     413: istore        12
     415: aload         10
     417: iload         12
     419: istore        13
     421: astore        19
     423: iconst_0
     424: istore        14
     426: iconst_0
     427: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     430: aload         19
     432: swap
     433: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     436: pop
     437: iinc          11, 1
     440: goto          404
     443: aload         10
     445: checkcast     #87                 // class java/util/List
     448: astore        8
     450: aload_0
     451: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     456: istore        10
     458: new           #112                // class java/util/ArrayList
     461: dup
     462: iload         10
     464: invokespecial #115                // Method java/util/ArrayList."<init>":(I)V
     467: astore        11
     469: iconst_0
     470: istore        12
     472: iload         12
     474: iload         10
     476: if_icmpge     511
     479: iload         12
     481: istore        13
     483: aload         11
     485: iload         13
     487: istore        14
     489: astore        19
     491: iconst_0
     492: istore        15
     494: iconst_0
     495: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     498: aload         19
     500: swap
     501: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     504: pop
     505: iinc          12, 1
     508: goto          472
     511: aload         11
     513: checkcast     #87                 // class java/util/List
     516: astore        9
     518: aload_0
     519: checkcast     #30                 // class java/lang/Iterable
     522: invokestatic  #120                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     525: invokestatic  #126                // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
     528: astore        10
     530: iconst_0
     531: istore        11
     533: aload         10
     535: new           #128                // class LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1
     538: dup
     539: invokespecial #129                // Method LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1."<init>":()V
     542: checkcast     #131                // class java/util/Comparator
     545: invokestatic  #135                // Method kotlin/sequences/SequencesKt.sortedWith:(Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Lkotlin/sequences/Sequence;
     548: invokedynamic #154,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     553: invokestatic  #158                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     556: astore        10
     558: iconst_0
     559: istore        11
     561: aload         10
     563: invokeinterface #161,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     568: astore        12
     570: aload         12
     572: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     577: ifeq          768
     580: aload         12
     582: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     587: astore        13
     589: aload         13
     591: checkcast     #46                 // class java/lang/Number
     594: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     597: istore        14
     599: iconst_0
     600: istore        15
     602: aload         7
     604: iload         14
     606: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     611: checkcast     #46                 // class java/lang/Number
     614: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     617: iload         6
     619: invokestatic  #164                // Method java/lang/Math.max:(II)I
     622: istore        16
     624: aload         9
     626: iload         14
     628: iload         16
     630: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     633: invokeinterface #104,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     638: pop
     639: aload         8
     641: iload         16
     643: aload         8
     645: iload         16
     647: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     652: checkcast     #46                 // class java/lang/Number
     655: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     658: iconst_1
     659: iadd
     660: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     663: invokeinterface #104,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     668: pop
     669: aload         8
     671: iload         16
     673: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     678: checkcast     #46                 // class java/lang/Number
     681: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     684: iload_1
     685: if_icmpne     694
     688: iload         16
     690: iconst_1
     691: iadd
     692: istore        6
     694: aload_2
     695: iload         14
     697: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     700: invokeinterface #85,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     705: checkcast     #52                 // class java/lang/Integer
     708: dup
     709: ifnull        761
     712: checkcast     #46                 // class java/lang/Number
     715: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     718: istore        17
     720: iconst_0
     721: istore        18
     723: aload         7
     725: iload         17
     727: aload         7
     729: iload         17
     731: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     736: checkcast     #46                 // class java/lang/Number
     739: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     742: iload         16
     744: iconst_1
     745: iadd
     746: invokestatic  #164                // Method java/lang/Math.max:(II)I
     749: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     752: invokeinterface #104,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     757: pop
     758: goto          763
     761: pop
     762: nop
     763: nop
     764: nop
     765: goto          570
     768: nop
     769: aload_0
     770: checkcast     #30                 // class java/lang/Iterable
     773: invokestatic  #120                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     776: aload         9
     778: checkcast     #30                 // class java/lang/Iterable
     781: invokestatic  #120                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     784: invokestatic  #168                // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
     787: invokeinterface #161,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     792: astore        12
     794: aload         12
     796: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     801: ifne          812
     804: new           #170                // class java/util/NoSuchElementException
     807: dup
     808: invokespecial #171                // Method java/util/NoSuchElementException."<init>":()V
     811: athrow
     812: aload         12
     814: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     819: checkcast     #173                // class kotlin/Pair
     822: astore        13
     824: iconst_0
     825: istore        14
     827: aload         13
     829: invokevirtual #176                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     832: checkcast     #46                 // class java/lang/Number
     835: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     838: istore        15
     840: aload         13
     842: invokevirtual #179                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     845: checkcast     #46                 // class java/lang/Number
     848: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     851: istore        16
     853: iload         16
     855: iconst_1
     856: iadd
     857: iload         15
     859: isub
     860: istore        13
     862: aload         12
     864: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     869: ifeq          936
     872: aload         12
     874: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     879: checkcast     #173                // class kotlin/Pair
     882: astore        14
     884: iconst_0
     885: istore        15
     887: aload         14
     889: invokevirtual #176                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     892: checkcast     #46                 // class java/lang/Number
     895: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     898: istore        16
     900: aload         14
     902: invokevirtual #179                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     905: checkcast     #46                 // class java/lang/Number
     908: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     911: istore        17
     913: iload         17
     915: iconst_1
     916: iadd
     917: iload         16
     919: isub
     920: istore        14
     922: iload         13
     924: iload         14
     926: if_icmpge     862
     929: iload         14
     931: istore        13
     933: goto          862
     936: iload         13
     938: istore        10
     940: iload         10
     942: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     945: aload         9
     947: invokestatic  #185                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     950: areturn

  public static final void main();
    Code:
       0: new           #224                // class java/util/Scanner
       3: dup
       4: new           #226                // class java/io/File
       7: dup
       8: ldc           #228                // String pintreep1l.in
      10: invokespecial #231                // Method java/io/File."<init>":(Ljava/lang/String;)V
      13: astore_1
      14: getstatic     #237                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      17: astore_2
      18: sipush        8192
      21: istore_3
      22: aload_1
      23: astore        4
      25: new           #239                // class java/io/InputStreamReader
      28: dup
      29: new           #241                // class java/io/FileInputStream
      32: dup
      33: aload         4
      35: invokespecial #244                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      38: checkcast     #246                // class java/io/InputStream
      41: aload_2
      42: invokespecial #249                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      45: checkcast     #251                // class java/io/Reader
      48: astore        4
      50: aload         4
      52: instanceof    #253                // class java/io/BufferedReader
      55: ifeq          66
      58: aload         4
      60: checkcast     #253                // class java/io/BufferedReader
      63: goto          76
      66: new           #253                // class java/io/BufferedReader
      69: dup
      70: aload         4
      72: iload_3
      73: invokespecial #256                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      76: checkcast     #258                // class java/lang/Readable
      79: invokespecial #261                // Method java/util/Scanner."<init>":(Ljava/lang/Readable;)V
      82: astore_0
      83: aload_0
      84: invokevirtual #264                // Method java/util/Scanner.nextInt:()I
      87: istore_1
      88: aload_0
      89: invokevirtual #264                // Method java/util/Scanner.nextInt:()I
      92: istore_2
      93: new           #112                // class java/util/ArrayList
      96: dup
      97: iload_1
      98: invokespecial #115                // Method java/util/ArrayList."<init>":(I)V
     101: astore        4
     103: iconst_0
     104: istore        5
     106: iload         5
     108: iload_1
     109: if_icmpge     147
     112: iload         5
     114: istore        6
     116: aload         4
     118: iload         6
     120: istore        7
     122: astore        19
     124: iconst_0
     125: istore        8
     127: aload_0
     128: invokevirtual #264                // Method java/util/Scanner.nextInt:()I
     131: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     134: aload         19
     136: swap
     137: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     140: pop
     141: iinc          5, 1
     144: goto          106
     147: aload         4
     149: checkcast     #87                 // class java/util/List
     152: astore_3
     153: new           #266                // class java/util/LinkedHashMap
     156: dup
     157: invokespecial #267                // Method java/util/LinkedHashMap."<init>":()V
     160: checkcast     #58                 // class java/util/Map
     163: astore        4
     165: new           #266                // class java/util/LinkedHashMap
     168: dup
     169: invokespecial #267                // Method java/util/LinkedHashMap."<init>":()V
     172: checkcast     #58                 // class java/util/Map
     175: astore        5
     177: iload_1
     178: iconst_1
     179: isub
     180: istore        6
     182: iconst_0
     183: istore        7
     185: iload         7
     187: iload         6
     189: if_icmpge     328
     192: iload         7
     194: istore        8
     196: iconst_0
     197: istore        9
     199: aload_0
     200: invokevirtual #264                // Method java/util/Scanner.nextInt:()I
     203: iconst_1
     204: isub
     205: istore        10
     207: aload_0
     208: invokevirtual #264                // Method java/util/Scanner.nextInt:()I
     211: iconst_1
     212: isub
     213: istore        11
     215: iload         10
     217: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     220: astore        12
     222: iload         11
     224: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     227: astore        13
     229: aload         4
     231: aload         12
     233: aload         13
     235: invokeinterface #271,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     240: pop
     241: aload         5
     243: astore        14
     245: iload         11
     247: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     250: astore        12
     252: iconst_0
     253: istore        13
     255: aload         14
     257: aload         12
     259: invokeinterface #85,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     264: astore        15
     266: aload         15
     268: ifnonnull     304
     271: iconst_0
     272: istore        16
     274: new           #112                // class java/util/ArrayList
     277: dup
     278: invokespecial #272                // Method java/util/ArrayList."<init>":()V
     281: checkcast     #87                 // class java/util/List
     284: nop
     285: astore        16
     287: aload         14
     289: aload         12
     291: aload         16
     293: invokeinterface #271,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     298: pop
     299: aload         16
     301: goto          306
     304: aload         15
     306: nop
     307: checkcast     #87                 // class java/util/List
     310: iload         10
     312: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     315: invokeinterface #273,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     320: pop
     321: nop
     322: iinc          7, 1
     325: goto          185
     328: aload_3
     329: iload_2
     330: aload         4
     332: aload         5
     334: invokestatic  #275                // Method schedulePIntreeP1LMax:(Ljava/util/List;ILjava/util/Map;Ljava/util/Map;)Lkotlin/Pair;
     337: astore        6
     339: aload         6
     341: invokevirtual #176                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     344: checkcast     #46                 // class java/lang/Number
     347: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     350: istore        7
     352: aload         6
     354: invokevirtual #179                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     357: checkcast     #87                 // class java/util/List
     360: astore        8
     362: new           #226                // class java/io/File
     365: dup
     366: ldc_w         #277                // String pintreep1l.out
     369: invokespecial #231                // Method java/io/File."<init>":(Ljava/lang/String;)V
     372: astore        9
     374: getstatic     #237                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     377: astore        10
     379: new           #279                // class java/io/PrintWriter
     382: dup
     383: aload         9
     385: astore        11
     387: sipush        8192
     390: istore        12
     392: aload         11
     394: astore        13
     396: new           #281                // class java/io/OutputStreamWriter
     399: dup
     400: new           #283                // class java/io/FileOutputStream
     403: dup
     404: aload         13
     406: invokespecial #284                // Method java/io/FileOutputStream."<init>":(Ljava/io/File;)V
     409: checkcast     #286                // class java/io/OutputStream
     412: aload         10
     414: invokespecial #289                // Method java/io/OutputStreamWriter."<init>":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V
     417: checkcast     #291                // class java/io/Writer
     420: astore        13
     422: aload         13
     424: instanceof    #293                // class java/io/BufferedWriter
     427: ifeq          438
     430: aload         13
     432: checkcast     #293                // class java/io/BufferedWriter
     435: goto          449
     438: new           #293                // class java/io/BufferedWriter
     441: dup
     442: aload         13
     444: iload         12
     446: invokespecial #296                // Method java/io/BufferedWriter."<init>":(Ljava/io/Writer;I)V
     449: checkcast     #291                // class java/io/Writer
     452: invokespecial #299                // Method java/io/PrintWriter."<init>":(Ljava/io/Writer;)V
     455: checkcast     #301                // class java/io/Closeable
     458: astore        9
     460: aconst_null
     461: astore        10
     463: nop
     464: aload         9
     466: checkcast     #279                // class java/io/PrintWriter
     469: astore        11
     471: iconst_0
     472: istore        12
     474: aload         11
     476: iload         7
     478: invokevirtual #304                // Method java/io/PrintWriter.println:(I)V
     481: aload         8
     483: checkcast     #30                 // class java/lang/Iterable
     486: astore        13
     488: iconst_0
     489: istore        14
     491: aload         13
     493: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     498: astore        15
     500: aload         15
     502: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     507: ifeq          561
     510: aload         15
     512: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     517: astore        16
     519: aload         16
     521: checkcast     #46                 // class java/lang/Number
     524: invokevirtual #50                 // Method java/lang/Number.intValue:()I
     527: istore        17
     529: iconst_0
     530: istore        18
     532: aload         11
     534: new           #306                // class java/lang/StringBuilder
     537: dup
     538: invokespecial #307                // Method java/lang/StringBuilder."<init>":()V
     541: iload         17
     543: invokevirtual #311                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     546: bipush        32
     548: invokevirtual #314                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     551: invokevirtual #318                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     554: invokevirtual #321                // Method java/io/PrintWriter.print:(Ljava/lang/String;)V
     557: nop
     558: goto          500
     561: nop
     562: nop
     563: getstatic     #327                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     566: astore        11
     568: aload         9
     570: aload         10
     572: invokestatic  #333                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     575: goto          599
     578: astore        12
     580: aload         12
     582: astore        10
     584: aload         12
     586: athrow
     587: astore        12
     589: aload         9
     591: aload         10
     593: invokestatic  #333                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     596: aload         12
     598: athrow
     599: return
    Exception table:
       from    to  target type
         463   568   578   Class java/lang/Throwable
         463   568   587   any
         578   587   587   any
         587   589   587   any

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

  private static final int schedulePIntreeP1LMax$lambda$6(kotlin.collections.IndexedValue);
    Code:
       0: aload_0
       1: ldc_w         #359                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #364                // Method kotlin/collections/IndexedValue.getIndex:()I
      11: ireturn
}


import java.io.File
import java.math.BigInteger
import java.util.Scanner

private fun scheduleP1PrecFMax(
    times: List<Int>,
    functions: List<(Int) -> BigInteger>,
    prec: Map<Int, List<Int>>,
): Pair<BigInteger, List<Int>> {
    val n = times.size
    val children = MutableList(n) { 0 }
    prec.forEach { (_, row) -> row.forEach { i -> children[i] += 1 } }

    val excluded = (0 until n).toMutableSet()
    var p = times.sum()
    val reverseSchedule = MutableList(n) { 0 }

    for (k in n - 1 downTo 0) {
        val j = excluded.asSequence().filter { children[it] == 0 }.minBy { functions[it](p) }
        excluded.remove(j)
        reverseSchedule[k] = j
        p -= times[j]

        prec[j]?.forEach { children[it] -= 1 }
    }

    val schedule = MutableList(n) { 0 }
    reverseSchedule.fold(0) { sum, it ->
        schedule[it] = sum
        sum + times[it]
    }

    val fMaxMin = (0 until n)
        .maxOfOrNull { functions[it](schedule[it] + times[it]) } ?: 0.toBigInteger()

    return fMaxMin to schedule
}

fun main() {
    val inputFile = Scanner(File("p1precfmax.in").bufferedReader())
    val n = inputFile.nextInt()
    val times = List(n) { inputFile.nextInt() }

    val functions = List(n) {
        val m = inputFile.nextInt()
        val coefficients = List(m + 1) { inputFile.nextInt() };
        { x: Int ->
            coefficients.asSequence()
                .withIndex()
                .sumOf { (i, it) -> x.toBigInteger().pow(coefficients.size - 1 - i) * it.toBigInteger() }
        }
    }

    val d = inputFile.nextInt()
    val prec = buildMap {
        for (i in 0 until d) {
            val from = inputFile.nextInt() - 1
            val to = inputFile.nextInt() - 1

            val list: MutableList<Int> = getOrPut(to) { mutableListOf() }
            list += from
        }
    }

    val (fMaxMin, schedule) = scheduleP1PrecFMax(times, functions, prec)

    File("p1precfmax.out").printWriter().use { output ->
        output.println(fMaxMin.toString())

        for (i in schedule) {
            output.print("$i ")
        }
    }
}

Compiled from "fP1PrecFMax.kt"
public final class FP1PrecFMaxKt {
  private static final kotlin.Pair<java.math.BigInteger, java.util.List<java.lang.Integer>> scheduleP1PrecFMax(java.util.List<java.lang.Integer>, java.util.List<? extends kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.math.BigInteger>>, java.util.Map<java.lang.Integer, ? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: invokeinterface #13,  1           // InterfaceMethod java/util/List.size:()I
       6: istore_3
       7: new           #15                 // class java/util/ArrayList
      10: dup
      11: iload_3
      12: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
      15: astore        5
      17: iconst_0
      18: istore        6
      20: iload         6
      22: iload_3
      23: if_icmpge     58
      26: iload         6
      28: istore        7
      30: aload         5
      32: iload         7
      34: istore        8
      36: astore        18
      38: iconst_0
      39: istore        9
      41: iconst_0
      42: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      45: aload         18
      47: swap
      48: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      51: pop
      52: iinc          6, 1
      55: goto          20
      58: aload         5
      60: checkcast     #9                  // class java/util/List
      63: astore        4
      65: aload_2
      66: astore        5
      68: iconst_0
      69: istore        6
      71: aload         5
      73: invokeinterface #35,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      78: invokeinterface #41,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      83: astore        7
      85: aload         7
      87: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      92: ifeq          217
      95: aload         7
      97: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     102: checkcast     #53                 // class java/util/Map$Entry
     105: astore        8
     107: aload         8
     109: astore        9
     111: iconst_0
     112: istore        10
     114: aload         9
     116: invokeinterface #56,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     121: checkcast     #9                  // class java/util/List
     124: astore        11
     126: aload         11
     128: checkcast     #58                 // class java/lang/Iterable
     131: astore        12
     133: iconst_0
     134: istore        13
     136: aload         12
     138: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     143: astore        14
     145: aload         14
     147: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          211
     155: aload         14
     157: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     162: astore        15
     164: aload         15
     166: checkcast     #61                 // class java/lang/Number
     169: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     172: istore        16
     174: iconst_0
     175: istore        17
     177: aload         4
     179: iload         16
     181: aload         4
     183: iload         16
     185: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     190: checkcast     #61                 // class java/lang/Number
     193: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     196: iconst_1
     197: iadd
     198: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: invokeinterface #72,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     206: pop
     207: nop
     208: goto          145
     211: nop
     212: nop
     213: nop
     214: goto          85
     217: nop
     218: iconst_0
     219: iload_3
     220: invokestatic  #78                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     223: checkcast     #58                 // class java/lang/Iterable
     226: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     229: astore        5
     231: iconst_0
     232: istore        6
     234: aload_0
     235: checkcast     #58                 // class java/lang/Iterable
     238: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     241: istore        6
     243: new           #15                 // class java/util/ArrayList
     246: dup
     247: iload_3
     248: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
     251: astore        8
     253: iconst_0
     254: istore        9
     256: iload         9
     258: iload_3
     259: if_icmpge     294
     262: iload         9
     264: istore        10
     266: aload         8
     268: iload         10
     270: istore        11
     272: astore        18
     274: iconst_0
     275: istore        12
     277: iconst_0
     278: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     281: aload         18
     283: swap
     284: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     287: pop
     288: iinc          9, 1
     291: goto          256
     294: aload         8
     296: checkcast     #9                  // class java/util/List
     299: astore        7
     301: iload_3
     302: iconst_1
     303: isub
     304: istore        8
     306: iconst_m1
     307: iload         8
     309: if_icmpge     679
     312: aload         5
     314: checkcast     #58                 // class java/lang/Iterable
     317: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     320: aload         4
     322: invokedynamic #112,  0            // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;
     327: invokestatic  #118                // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     330: astore        10
     332: iconst_0
     333: istore        11
     335: aload         10
     337: invokeinterface #121,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     342: astore        12
     344: aload         12
     346: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     351: ifne          362
     354: new           #123                // class java/util/NoSuchElementException
     357: dup
     358: invokespecial #126                // Method java/util/NoSuchElementException."<init>":()V
     361: athrow
     362: aload         12
     364: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     369: astore        13
     371: aload         12
     373: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     378: ifne          386
     381: aload         13
     383: goto          511
     386: aload         13
     388: checkcast     #61                 // class java/lang/Number
     391: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     394: istore        14
     396: iconst_0
     397: istore        15
     399: aload_1
     400: iload         14
     402: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     407: checkcast     #128                // class kotlin/jvm/functions/Function1
     410: iload         6
     412: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     415: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     420: checkcast     #132                // class java/math/BigInteger
     423: checkcast     #134                // class java/lang/Comparable
     426: astore        14
     428: aload         12
     430: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     435: astore        15
     437: aload         15
     439: checkcast     #61                 // class java/lang/Number
     442: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     445: istore        16
     447: iconst_0
     448: istore        17
     450: aload_1
     451: iload         16
     453: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     458: checkcast     #128                // class kotlin/jvm/functions/Function1
     461: iload         6
     463: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     466: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     471: checkcast     #132                // class java/math/BigInteger
     474: checkcast     #134                // class java/lang/Comparable
     477: astore        16
     479: aload         14
     481: aload         16
     483: invokeinterface #138,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     488: ifle          499
     491: aload         15
     493: astore        13
     495: aload         16
     497: astore        14
     499: aload         12
     501: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     506: ifne          428
     509: aload         13
     511: checkcast     #61                 // class java/lang/Number
     514: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     517: istore        9
     519: aload         5
     521: iload         9
     523: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     526: invokeinterface #141,  2          // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     531: pop
     532: aload         7
     534: iload         8
     536: iload         9
     538: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     541: invokeinterface #72,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     546: pop
     547: iload         6
     549: aload_0
     550: iload         9
     552: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     557: checkcast     #61                 // class java/lang/Number
     560: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     563: isub
     564: istore        6
     566: aload_2
     567: iload         9
     569: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     572: invokeinterface #143,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     577: checkcast     #9                  // class java/util/List
     580: dup
     581: ifnull        671
     584: checkcast     #58                 // class java/lang/Iterable
     587: astore        11
     589: iconst_0
     590: istore        12
     592: aload         11
     594: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     599: astore        13
     601: aload         13
     603: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     608: ifeq          667
     611: aload         13
     613: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     618: astore        14
     620: aload         14
     622: checkcast     #61                 // class java/lang/Number
     625: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     628: istore        15
     630: iconst_0
     631: istore        16
     633: aload         4
     635: iload         15
     637: aload         4
     639: iload         15
     641: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     646: checkcast     #61                 // class java/lang/Number
     649: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     652: iconst_1
     653: isub
     654: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     657: invokeinterface #72,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     662: pop
     663: nop
     664: goto          601
     667: nop
     668: goto          673
     671: pop
     672: nop
     673: iinc          8, -1
     676: goto          306
     679: new           #15                 // class java/util/ArrayList
     682: dup
     683: iload_3
     684: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
     687: astore        9
     689: iconst_0
     690: istore        10
     692: iload         10
     694: iload_3
     695: if_icmpge     730
     698: iload         10
     700: istore        11
     702: aload         9
     704: iload         11
     706: istore        12
     708: astore        18
     710: iconst_0
     711: istore        13
     713: iconst_0
     714: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     717: aload         18
     719: swap
     720: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     723: pop
     724: iinc          10, 1
     727: goto          692
     730: aload         9
     732: checkcast     #9                  // class java/util/List
     735: astore        8
     737: aload         7
     739: checkcast     #58                 // class java/lang/Iterable
     742: astore        9
     744: iconst_0
     745: istore        10
     747: iconst_0
     748: istore        11
     750: iload         10
     752: istore        12
     754: aload         9
     756: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     761: astore        13
     763: aload         13
     765: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     770: ifeq          836
     773: aload         13
     775: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     780: astore        14
     782: iload         12
     784: aload         14
     786: checkcast     #61                 // class java/lang/Number
     789: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     792: istore        15
     794: istore        16
     796: iconst_0
     797: istore        17
     799: aload         8
     801: iload         15
     803: iload         16
     805: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     808: invokeinterface #72,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     813: pop
     814: iload         16
     816: aload_0
     817: iload         15
     819: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     824: checkcast     #61                 // class java/lang/Number
     827: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     830: iadd
     831: istore        12
     833: goto          763
     836: nop
     837: iconst_0
     838: iload_3
     839: invokestatic  #78                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     842: checkcast     #58                 // class java/lang/Iterable
     845: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     850: astore        12
     852: aload         12
     854: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     859: ifne          866
     862: aconst_null
     863: goto          1037
     866: aload         12
     868: checkcast     #145                // class kotlin/collections/IntIterator
     871: invokevirtual #148                // Method kotlin/collections/IntIterator.nextInt:()I
     874: istore        13
     876: iconst_0
     877: istore        14
     879: aload_1
     880: iload         13
     882: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     887: checkcast     #128                // class kotlin/jvm/functions/Function1
     890: aload         8
     892: iload         13
     894: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     899: checkcast     #61                 // class java/lang/Number
     902: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     905: aload_0
     906: iload         13
     908: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     913: checkcast     #61                 // class java/lang/Number
     916: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     919: iadd
     920: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     923: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     928: checkcast     #132                // class java/math/BigInteger
     931: checkcast     #134                // class java/lang/Comparable
     934: astore        13
     936: aload         12
     938: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     943: ifeq          1035
     946: aload         12
     948: checkcast     #145                // class kotlin/collections/IntIterator
     951: invokevirtual #148                // Method kotlin/collections/IntIterator.nextInt:()I
     954: istore        14
     956: iconst_0
     957: istore        15
     959: aload_1
     960: iload         14
     962: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     967: checkcast     #128                // class kotlin/jvm/functions/Function1
     970: aload         8
     972: iload         14
     974: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     979: checkcast     #61                 // class java/lang/Number
     982: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     985: aload_0
     986: iload         14
     988: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     993: checkcast     #61                 // class java/lang/Number
     996: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     999: iadd
    1000: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1003: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
    1008: checkcast     #132                // class java/math/BigInteger
    1011: checkcast     #134                // class java/lang/Comparable
    1014: astore        14
    1016: aload         13
    1018: aload         14
    1020: invokeinterface #138,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
    1025: ifge          936
    1028: aload         14
    1030: astore        13
    1032: goto          936
    1035: aload         13
    1037: checkcast     #132                // class java/math/BigInteger
    1040: dup
    1041: ifnonnull     1055
    1044: pop
    1045: lconst_0
    1046: invokestatic  #151                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
    1049: dup
    1050: ldc           #153                // String valueOf(...)
    1052: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
    1055: astore        9
    1057: aload         9
    1059: aload         8
    1061: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1064: areturn

  public static final void main();
    Code:
       0: new           #220                // class java/util/Scanner
       3: dup
       4: new           #222                // class java/io/File
       7: dup
       8: ldc           #224                // String p1precfmax.in
      10: invokespecial #227                // Method java/io/File."<init>":(Ljava/lang/String;)V
      13: astore_1
      14: getstatic     #233                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      17: astore_2
      18: sipush        8192
      21: istore_3
      22: aload_1
      23: astore        4
      25: new           #235                // class java/io/InputStreamReader
      28: dup
      29: new           #237                // class java/io/FileInputStream
      32: dup
      33: aload         4
      35: invokespecial #240                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      38: checkcast     #242                // class java/io/InputStream
      41: aload_2
      42: invokespecial #245                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      45: checkcast     #247                // class java/io/Reader
      48: astore        4
      50: aload         4
      52: instanceof    #249                // class java/io/BufferedReader
      55: ifeq          66
      58: aload         4
      60: checkcast     #249                // class java/io/BufferedReader
      63: goto          76
      66: new           #249                // class java/io/BufferedReader
      69: dup
      70: aload         4
      72: iload_3
      73: invokespecial #252                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      76: checkcast     #254                // class java/lang/Readable
      79: invokespecial #257                // Method java/util/Scanner."<init>":(Ljava/lang/Readable;)V
      82: astore_0
      83: aload_0
      84: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
      87: istore_1
      88: new           #15                 // class java/util/ArrayList
      91: dup
      92: iload_1
      93: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
      96: astore_3
      97: iconst_0
      98: istore        4
     100: iload         4
     102: iload_1
     103: if_icmpge     140
     106: iload         4
     108: istore        5
     110: aload_3
     111: iload         5
     113: istore        6
     115: astore        18
     117: iconst_0
     118: istore        7
     120: aload_0
     121: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     124: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: aload         18
     129: swap
     130: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     133: pop
     134: iinc          4, 1
     137: goto          100
     140: aload_3
     141: checkcast     #9                  // class java/util/List
     144: astore_2
     145: new           #15                 // class java/util/ArrayList
     148: dup
     149: iload_1
     150: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
     153: astore        4
     155: iconst_0
     156: istore        5
     158: iload         5
     160: iload_1
     161: if_icmpge     275
     164: iload         5
     166: istore        6
     168: aload         4
     170: iload         6
     172: istore        7
     174: astore        18
     176: iconst_0
     177: istore        8
     179: aload_0
     180: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     183: istore        9
     185: iload         9
     187: iconst_1
     188: iadd
     189: istore        10
     191: new           #15                 // class java/util/ArrayList
     194: dup
     195: iload         10
     197: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
     200: astore        11
     202: iconst_0
     203: istore        12
     205: iload         12
     207: iload         10
     209: if_icmpge     247
     212: iload         12
     214: istore        13
     216: aload         11
     218: iload         13
     220: istore        14
     222: astore        15
     224: iconst_0
     225: istore        16
     227: aload_0
     228: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     231: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     234: aload         15
     236: swap
     237: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     240: pop
     241: iinc          12, 1
     244: goto          205
     247: aload         11
     249: checkcast     #9                  // class java/util/List
     252: astore        17
     254: aload         17
     256: invokedynamic #266,  0            // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;
     261: nop
     262: aload         18
     264: swap
     265: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     268: pop
     269: iinc          5, 1
     272: goto          158
     275: aload         4
     277: checkcast     #9                  // class java/util/List
     280: astore_3
     281: aload_0
     282: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     285: istore        4
     287: invokestatic  #272                // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;
     290: astore        6
     292: aload         6
     294: astore        7
     296: iconst_0
     297: istore        8
     299: iconst_0
     300: istore        9
     302: iload         9
     304: iload         4
     306: if_icmpge     422
     309: aload_0
     310: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     313: iconst_1
     314: isub
     315: istore        10
     317: aload_0
     318: invokevirtual #258                // Method java/util/Scanner.nextInt:()I
     321: iconst_1
     322: isub
     323: istore        11
     325: aload         7
     327: astore        12
     329: iload         11
     331: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     334: astore        13
     336: iconst_0
     337: istore        14
     339: aload         12
     341: aload         13
     343: invokeinterface #143,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     348: astore        15
     350: aload         15
     352: ifnonnull     388
     355: iconst_0
     356: istore        16
     358: new           #15                 // class java/util/ArrayList
     361: dup
     362: invokespecial #273                // Method java/util/ArrayList."<init>":()V
     365: checkcast     #9                  // class java/util/List
     368: nop
     369: astore        16
     371: aload         12
     373: aload         13
     375: aload         16
     377: invokeinterface #277,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     382: pop
     383: aload         16
     385: goto          390
     388: aload         15
     390: nop
     391: checkcast     #9                  // class java/util/List
     394: astore        17
     396: iload         10
     398: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     401: astore        13
     403: aload         17
     405: checkcast     #279                // class java/util/Collection
     408: aload         13
     410: invokeinterface #280,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     415: pop
     416: iinc          9, 1
     419: goto          302
     422: nop
     423: aload         6
     425: invokestatic  #284                // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;
     428: astore        5
     430: aload_2
     431: aload_3
     432: aload         5
     434: invokestatic  #286                // Method scheduleP1PrecFMax:(Ljava/util/List;Ljava/util/List;Ljava/util/Map;)Lkotlin/Pair;
     437: astore        6
     439: aload         6
     441: invokevirtual #291                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     444: checkcast     #132                // class java/math/BigInteger
     447: astore        7
     449: aload         6
     451: invokevirtual #294                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     454: checkcast     #9                  // class java/util/List
     457: astore        8
     459: new           #222                // class java/io/File
     462: dup
     463: ldc_w         #296                // String p1precfmax.out
     466: invokespecial #227                // Method java/io/File."<init>":(Ljava/lang/String;)V
     469: astore        9
     471: getstatic     #233                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     474: astore        10
     476: new           #298                // class java/io/PrintWriter
     479: dup
     480: aload         9
     482: astore        11
     484: sipush        8192
     487: istore        12
     489: aload         11
     491: astore        13
     493: new           #300                // class java/io/OutputStreamWriter
     496: dup
     497: new           #302                // class java/io/FileOutputStream
     500: dup
     501: aload         13
     503: invokespecial #303                // Method java/io/FileOutputStream."<init>":(Ljava/io/File;)V
     506: checkcast     #305                // class java/io/OutputStream
     509: aload         10
     511: invokespecial #308                // Method java/io/OutputStreamWriter."<init>":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V
     514: checkcast     #310                // class java/io/Writer
     517: astore        13
     519: aload         13
     521: instanceof    #312                // class java/io/BufferedWriter
     524: ifeq          535
     527: aload         13
     529: checkcast     #312                // class java/io/BufferedWriter
     532: goto          546
     535: new           #312                // class java/io/BufferedWriter
     538: dup
     539: aload         13
     541: iload         12
     543: invokespecial #315                // Method java/io/BufferedWriter."<init>":(Ljava/io/Writer;I)V
     546: checkcast     #310                // class java/io/Writer
     549: invokespecial #318                // Method java/io/PrintWriter."<init>":(Ljava/io/Writer;)V
     552: checkcast     #320                // class java/io/Closeable
     555: astore        9
     557: aconst_null
     558: astore        10
     560: nop
     561: aload         9
     563: checkcast     #298                // class java/io/PrintWriter
     566: astore        11
     568: iconst_0
     569: istore        12
     571: aload         11
     573: aload         7
     575: invokevirtual #324                // Method java/math/BigInteger.toString:()Ljava/lang/String;
     578: invokevirtual #327                // Method java/io/PrintWriter.println:(Ljava/lang/String;)V
     581: aload         8
     583: invokeinterface #328,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     588: astore        13
     590: aload         13
     592: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     597: ifeq          643
     600: aload         13
     602: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     607: checkcast     #61                 // class java/lang/Number
     610: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     613: istore        14
     615: aload         11
     617: new           #330                // class java/lang/StringBuilder
     620: dup
     621: invokespecial #331                // Method java/lang/StringBuilder."<init>":()V
     624: iload         14
     626: invokevirtual #335                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     629: bipush        32
     631: invokevirtual #338                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     634: invokevirtual #339                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     637: invokevirtual #342                // Method java/io/PrintWriter.print:(Ljava/lang/String;)V
     640: goto          590
     643: nop
     644: getstatic     #348                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     647: astore        11
     649: aload         9
     651: aload         10
     653: invokestatic  #354                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     656: goto          680
     659: astore        12
     661: aload         12
     663: astore        10
     665: aload         12
     667: athrow
     668: astore        12
     670: aload         9
     672: aload         10
     674: invokestatic  #354                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     677: aload         12
     679: athrow
     680: return
    Exception table:
       from    to  target type
         560   649   659   Class java/lang/Throwable
         560   649   668   any
         659   668   668   any
         668   670   668   any

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

  private static final boolean scheduleP1PrecFMax$lambda$4(java.util.List, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #61                 // class java/lang/Number
      10: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      13: ifne          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private static final java.math.BigInteger main$lambda$14$lambda$13(java.util.List, int);
    Code:
       0: aload_0
       1: checkcast     #58                 // class java/lang/Iterable
       4: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
       7: invokestatic  #387                // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      10: astore_2
      11: lconst_0
      12: invokestatic  #151                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
      15: dup
      16: ldc           #153                // String valueOf(...)
      18: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      21: astore_3
      22: aload_2
      23: invokeinterface #121,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      28: astore        4
      30: aload         4
      32: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      37: ifeq          159
      40: aload         4
      42: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      47: aload_3
      48: swap
      49: checkcast     #389                // class kotlin/collections/IndexedValue
      52: astore        5
      54: astore        11
      56: iconst_0
      57: istore        6
      59: aload         5
      61: invokevirtual #391                // Method kotlin/collections/IndexedValue.component1:()I
      64: istore        7
      66: aload         5
      68: invokevirtual #392                // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;
      71: checkcast     #61                 // class java/lang/Number
      74: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      77: istore        8
      79: iload_1
      80: i2l
      81: invokestatic  #151                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
      84: dup
      85: ldc           #153                // String valueOf(...)
      87: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      90: aload_0
      91: invokeinterface #13,  1           // InterfaceMethod java/util/List.size:()I
      96: iconst_1
      97: isub
      98: iload         7
     100: isub
     101: invokevirtual #396                // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
     104: dup
     105: ldc_w         #398                // String pow(...)
     108: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     111: astore        9
     113: iload         8
     115: i2l
     116: invokestatic  #151                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
     119: dup
     120: ldc           #153                // String valueOf(...)
     122: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     125: astore        10
     127: aload         9
     129: aload         10
     131: invokevirtual #402                // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     134: dup
     135: ldc_w         #404                // String multiply(...)
     138: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     141: nop
     142: aload         11
     144: swap
     145: invokevirtual #406                // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     148: dup
     149: ldc_w         #408                // String add(...)
     152: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     155: astore_3
     156: goto          30
     159: aload_3
     160: areturn
}