package leetcode

/**
 * https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/
 */
class Problem2115 {
    fun findAllRecipes(recipes: Array<String>, ingredients: List<List<String>>, supplies: Array<String>): List<String> {
        val recipeToIngredients = mutableMapOf<String, List<String>>()
        for ((index, recipe) in recipes.withIndex()) {
            recipeToIngredients[recipe] = ingredients[index]
        }
        val answer = mutableListOf<String>()
        val memo = mutableMapOf<String, Boolean>()
        val visited = mutableSetOf<String>()
        val supplySet = supplies.toSet()
        for (recipe in recipes) {
            if (findAllRecipes(recipeToIngredients, supplySet, recipe, visited, memo)) {
                answer += recipe
            }
        }
        return answer
    }

    private fun findAllRecipes(recipeToIngredients: MutableMap<String, List<String>>,
                               supplies: Set<String>,
                               recipe: String,
                               visited: MutableSet<String>,
                               memo: MutableMap<String, Boolean>): Boolean {
        if (memo[recipe] != null) {
            return memo[recipe]!!
        }
        if (recipe in visited) {
            return false
        }
        visited += recipe
        var found = true
        for (ingredient in recipeToIngredients[recipe] ?: listOf()) {
            found = if (ingredient in recipeToIngredients) {
                found && findAllRecipes(recipeToIngredients, supplies, ingredient, visited, memo)
            } else {
                found && ingredient in supplies
            }
        }
        memo[recipe] = found
        return found
    }
}

Compiled from "Problem2115.kt"
public final class leetcode.Problem2115 {
  public leetcode.Problem2115();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.lang.String> findAllRecipes(java.lang.String[], java.util.List<? extends java.util.List<java.lang.String>>, java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #16                 // String recipes
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #24                 // String ingredients
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #26                 // String supplies
      15: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: new           #28                 // class java/util/LinkedHashMap
      21: dup
      22: invokespecial #29                 // Method java/util/LinkedHashMap."<init>":()V
      25: checkcast     #31                 // class java/util/Map
      28: astore        4
      30: iconst_0
      31: istore        5
      33: aload_1
      34: arraylength
      35: istore        6
      37: iload         5
      39: iload         6
      41: if_icmpge     78
      44: iload         5
      46: istore        7
      48: aload_1
      49: iload         5
      51: aaload
      52: astore        8
      54: aload         4
      56: aload         8
      58: aload_2
      59: iload         7
      61: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      66: invokeinterface #41,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      71: pop
      72: iinc          5, 1
      75: goto          37
      78: new           #43                 // class java/util/ArrayList
      81: dup
      82: invokespecial #44                 // Method java/util/ArrayList."<init>":()V
      85: checkcast     #33                 // class java/util/List
      88: astore        5
      90: new           #28                 // class java/util/LinkedHashMap
      93: dup
      94: invokespecial #29                 // Method java/util/LinkedHashMap."<init>":()V
      97: checkcast     #31                 // class java/util/Map
     100: astore        6
     102: new           #46                 // class java/util/LinkedHashSet
     105: dup
     106: invokespecial #47                 // Method java/util/LinkedHashSet."<init>":()V
     109: checkcast     #49                 // class java/util/Set
     112: astore        7
     114: aload_3
     115: invokestatic  #55                 // Method kotlin/collections/ArraysKt.toSet:([Ljava/lang/Object;)Ljava/util/Set;
     118: astore        8
     120: iconst_0
     121: istore        9
     123: aload_1
     124: arraylength
     125: istore        10
     127: iload         9
     129: iload         10
     131: if_icmpge     176
     134: aload_1
     135: iload         9
     137: aaload
     138: astore        11
     140: aload_0
     141: aload         4
     143: aload         8
     145: aload         11
     147: aload         7
     149: aload         6
     151: invokespecial #58                 // Method findAllRecipes:(Ljava/util/Map;Ljava/util/Set;Ljava/lang/String;Ljava/util/Set;Ljava/util/Map;)Z
     154: ifeq          170
     157: aload         5
     159: checkcast     #60                 // class java/util/Collection
     162: aload         11
     164: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     169: pop
     170: iinc          9, 1
     173: goto          127
     176: aload         5
     178: areturn

  private final boolean findAllRecipes(java.util.Map<java.lang.String, java.util.List<java.lang.String>>, java.util.Set<java.lang.String>, java.lang.String, java.util.Set<java.lang.String>, java.util.Map<java.lang.String, java.lang.Boolean>);
    Code:
       0: aload         5
       2: aload_3
       3: invokeinterface #84,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       8: ifnull        30
      11: aload         5
      13: aload_3
      14: invokeinterface #84,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      19: dup
      20: invokestatic  #88                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      23: checkcast     #90                 // class java/lang/Boolean
      26: invokevirtual #94                 // Method java/lang/Boolean.booleanValue:()Z
      29: ireturn
      30: aload         4
      32: aload_3
      33: invokeinterface #97,  2           // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      38: ifeq          43
      41: iconst_0
      42: ireturn
      43: aload         4
      45: checkcast     #60                 // class java/util/Collection
      48: aload_3
      49: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      54: pop
      55: iconst_1
      56: istore        6
      58: aload_1
      59: aload_3
      60: invokeinterface #84,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      65: checkcast     #33                 // class java/util/List
      68: dup
      69: ifnonnull     76
      72: pop
      73: invokestatic  #103                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      76: invokeinterface #107,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      81: astore        7
      83: aload         7
      85: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      90: ifeq          170
      93: aload         7
      95: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     100: checkcast     #80                 // class java/lang/String
     103: astore        8
     105: aload_1
     106: aload         8
     108: invokeinterface #119,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     113: ifeq          144
     116: iload         6
     118: ifeq          140
     121: aload_0
     122: aload_1
     123: aload_2
     124: aload         8
     126: aload         4
     128: aload         5
     130: invokespecial #58                 // Method findAllRecipes:(Ljava/util/Map;Ljava/util/Set;Ljava/lang/String;Ljava/util/Set;Ljava/util/Map;)Z
     133: ifeq          140
     136: iconst_1
     137: goto          165
     140: iconst_0
     141: goto          165
     144: iload         6
     146: ifeq          164
     149: aload_2
     150: aload         8
     152: invokeinterface #97,  2           // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     157: ifeq          164
     160: iconst_1
     161: goto          165
     164: iconst_0
     165: istore        6
     167: goto          83
     170: iload         6
     172: invokestatic  #123                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     175: astore        8
     177: aload         5
     179: aload_3
     180: aload         8
     182: invokeinterface #41,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     187: pop
     188: iload         6
     190: ireturn
}


package leetcode

import java.util.*

/**
 * https://leetcode.com/problems/number-of-orders-in-the-backlog/
 */
class Problem1801 {
    fun getNumberOfBacklogOrders(orders: Array<IntArray>): Int {
        val buyMap = TreeMap<Int, Long> { a, b -> b.compareTo(a) }
        val sellMap = TreeMap<Int, Long> { a, b -> a.compareTo(b) }
        for ((price, amount, type) in orders) {
            if (type == 0) { // buy
                var remainingAmount = amount.toLong()
                while (sellMap.isNotEmpty() && sellMap.firstKey() <= price) {
                    val count = sellMap[sellMap.firstKey()] ?: 0
                    if (count - remainingAmount <= 0) {
                        remainingAmount -= count
                        sellMap.pollFirstEntry()
                    } else {
                        sellMap[sellMap.firstKey()] = count - remainingAmount
                        remainingAmount = 0
                        break
                    }
                }
                if (remainingAmount > 0) {
                    buyMap[price] = (buyMap[price] ?: 0) + remainingAmount
                }
            } else { // sell
                var remainingAmount = amount.toLong()
                while (buyMap.isNotEmpty() && buyMap.firstKey() >= price) {
                    val count = buyMap[buyMap.firstKey()] ?: 0
                    if (count - remainingAmount <= 0) {
                        remainingAmount -= count
                        buyMap.pollFirstEntry()
                    } else {
                        buyMap[buyMap.firstKey()] = count - remainingAmount
                        remainingAmount = 0
                        break
                    }
                }
                if (remainingAmount > 0) {
                    sellMap[price] = (sellMap[price] ?: 0) + remainingAmount
                }
            }
        }
        var answer = 0L
        for ((_, count) in buyMap) {
            answer = (answer + count) % 1_000_000_007
        }
        for ((_, count) in sellMap) {
            answer = (answer + count) % 1_000_000_007
        }
        return answer.toInt()
    }
}

Compiled from "Problem1801.kt"
public final class leetcode.Problem1801 {
  public leetcode.Problem1801();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int getNumberOfBacklogOrders(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String orders
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #23                 // class java/util/TreeMap
       9: dup
      10: invokedynamic #43,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
      15: invokedynamic #54,  0             // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
      20: invokespecial #57                 // Method java/util/TreeMap."<init>":(Ljava/util/Comparator;)V
      23: astore_2
      24: new           #23                 // class java/util/TreeMap
      27: dup
      28: invokedynamic #62,  0             // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;
      33: invokedynamic #67,  0             // InvokeDynamic #3:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
      38: invokespecial #57                 // Method java/util/TreeMap."<init>":(Ljava/util/Comparator;)V
      41: astore_3
      42: iconst_0
      43: istore        4
      45: aload_1
      46: checkcast     #69                 // class "[Ljava/lang/Object;"
      49: arraylength
      50: istore        5
      52: iload         4
      54: iload         5
      56: if_icmpge     467
      59: aload_1
      60: iload         4
      62: aaload
      63: astore        6
      65: aload         6
      67: iconst_0
      68: iaload
      69: istore        7
      71: aload         6
      73: iconst_1
      74: iaload
      75: istore        8
      77: aload         6
      79: iconst_2
      80: iaload
      81: istore        9
      83: iload         9
      85: ifne          276
      88: iload         8
      90: i2l
      91: lstore        10
      93: aload_3
      94: checkcast     #71                 // class java/util/Map
      97: invokeinterface #75,  1           // InterfaceMethod java/util/Map.isEmpty:()Z
     102: ifne          109
     105: iconst_1
     106: goto          110
     109: iconst_0
     110: ifeq          209
     113: aload_3
     114: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     117: checkcast     #81                 // class java/lang/Number
     120: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     123: iload         7
     125: if_icmpgt     209
     128: aload_3
     129: aload_3
     130: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     133: invokevirtual #89                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     136: checkcast     #91                 // class java/lang/Long
     139: dup
     140: ifnull        149
     143: invokevirtual #95                 // Method java/lang/Long.longValue:()J
     146: goto          151
     149: pop
     150: lconst_0
     151: lstore        12
     153: lload         12
     155: lload         10
     157: lsub
     158: lconst_0
     159: lcmp
     160: ifgt          177
     163: lload         10
     165: lload         12
     167: lsub
     168: lstore        10
     170: aload_3
     171: invokevirtual #99                 // Method java/util/TreeMap.pollFirstEntry:()Ljava/util/Map$Entry;
     174: goto          205
     177: aload_3
     178: checkcast     #71                 // class java/util/Map
     181: aload_3
     182: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     185: lload         12
     187: lload         10
     189: lsub
     190: invokestatic  #103                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     193: invokeinterface #106,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     198: pop
     199: lconst_0
     200: lstore        10
     202: goto          209
     205: pop
     206: goto          93
     209: lload         10
     211: lconst_0
     212: lcmp
     213: ifle          461
     216: aload_2
     217: checkcast     #71                 // class java/util/Map
     220: astore        12
     222: iload         7
     224: invokestatic  #111                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     227: astore        13
     229: aload_2
     230: iload         7
     232: invokestatic  #111                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     235: invokevirtual #89                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     238: checkcast     #91                 // class java/lang/Long
     241: dup
     242: ifnull        251
     245: invokevirtual #95                 // Method java/lang/Long.longValue:()J
     248: goto          253
     251: pop
     252: lconst_0
     253: lload         10
     255: ladd
     256: invokestatic  #103                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     259: astore        14
     261: aload         12
     263: aload         13
     265: aload         14
     267: invokeinterface #106,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     272: pop
     273: goto          461
     276: iload         8
     278: i2l
     279: lstore        10
     281: aload_2
     282: checkcast     #71                 // class java/util/Map
     285: invokeinterface #75,  1           // InterfaceMethod java/util/Map.isEmpty:()Z
     290: ifne          297
     293: iconst_1
     294: goto          298
     297: iconst_0
     298: ifeq          397
     301: aload_2
     302: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     305: checkcast     #81                 // class java/lang/Number
     308: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     311: iload         7
     313: if_icmplt     397
     316: aload_2
     317: aload_2
     318: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     321: invokevirtual #89                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     324: checkcast     #91                 // class java/lang/Long
     327: dup
     328: ifnull        337
     331: invokevirtual #95                 // Method java/lang/Long.longValue:()J
     334: goto          339
     337: pop
     338: lconst_0
     339: lstore        12
     341: lload         12
     343: lload         10
     345: lsub
     346: lconst_0
     347: lcmp
     348: ifgt          365
     351: lload         10
     353: lload         12
     355: lsub
     356: lstore        10
     358: aload_2
     359: invokevirtual #99                 // Method java/util/TreeMap.pollFirstEntry:()Ljava/util/Map$Entry;
     362: goto          393
     365: aload_2
     366: checkcast     #71                 // class java/util/Map
     369: aload_2
     370: invokevirtual #79                 // Method java/util/TreeMap.firstKey:()Ljava/lang/Object;
     373: lload         12
     375: lload         10
     377: lsub
     378: invokestatic  #103                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     381: invokeinterface #106,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     386: pop
     387: lconst_0
     388: lstore        10
     390: goto          397
     393: pop
     394: goto          281
     397: lload         10
     399: lconst_0
     400: lcmp
     401: ifle          461
     404: aload_3
     405: checkcast     #71                 // class java/util/Map
     408: astore        12
     410: iload         7
     412: invokestatic  #111                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     415: astore        13
     417: aload_3
     418: iload         7
     420: invokestatic  #111                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     423: invokevirtual #89                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     426: checkcast     #91                 // class java/lang/Long
     429: dup
     430: ifnull        439
     433: invokevirtual #95                 // Method java/lang/Long.longValue:()J
     436: goto          441
     439: pop
     440: lconst_0
     441: lload         10
     443: ladd
     444: invokestatic  #103                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     447: astore        14
     449: aload         12
     451: aload         13
     453: aload         14
     455: invokeinterface #106,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     460: pop
     461: iinc          4, 1
     464: goto          52
     467: lconst_0
     468: lstore        4
     470: aload_2
     471: checkcast     #71                 // class java/util/Map
     474: invokeinterface #115,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     479: invokeinterface #121,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     484: astore        6
     486: aload         6
     488: invokeinterface #126,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     493: ifeq          533
     496: aload         6
     498: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     503: checkcast     #131                // class java/util/Map$Entry
     506: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     511: checkcast     #81                 // class java/lang/Number
     514: invokevirtual #135                // Method java/lang/Number.longValue:()J
     517: lstore        8
     519: lload         4
     521: lload         8
     523: ladd
     524: ldc           #136                // int 1000000007
     526: i2l
     527: lrem
     528: lstore        4
     530: goto          486
     533: aload_3
     534: checkcast     #71                 // class java/util/Map
     537: invokeinterface #115,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     542: invokeinterface #121,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     547: astore        6
     549: aload         6
     551: invokeinterface #126,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     556: ifeq          596
     559: aload         6
     561: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     566: checkcast     #131                // class java/util/Map$Entry
     569: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     574: checkcast     #81                 // class java/lang/Number
     577: invokevirtual #135                // Method java/lang/Number.longValue:()J
     580: lstore        8
     582: lload         4
     584: lload         8
     586: ladd
     587: ldc           #136                // int 1000000007
     589: i2l
     590: lrem
     591: lstore        4
     593: goto          549
     596: lload         4
     598: l2i
     599: ireturn

  private static final int getNumberOfBacklogOrders$lambda$0(java.lang.Integer, java.lang.Integer);
    Code:
       0: aload_1
       1: invokevirtual #152                // Method java/lang/Integer.intValue:()I
       4: aload_0
       5: invokestatic  #156                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       8: aload_0
       9: invokevirtual #152                // Method java/lang/Integer.intValue:()I
      12: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      15: ireturn

  private static final int getNumberOfBacklogOrders$lambda$1(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #166,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #81                 // class java/lang/Number
      11: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      14: ireturn

  private static final int getNumberOfBacklogOrders$lambda$2(java.lang.Integer, java.lang.Integer);
    Code:
       0: aload_0
       1: invokevirtual #152                // Method java/lang/Integer.intValue:()I
       4: aload_1
       5: invokestatic  #156                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       8: aload_1
       9: invokevirtual #152                // Method java/lang/Integer.intValue:()I
      12: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      15: ireturn

  private static final int getNumberOfBacklogOrders$lambda$3(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #166,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #81                 // class java/lang/Number
      11: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      14: ireturn
}


package leetcode

/**
 * https://leetcode.com/problems/count-nodes-with-the-highest-score/
 */
class Problem2049 {
    fun countHighestScoreNodes(parents: IntArray): Int {
        val root = buildTree(parents)
        val scores = mutableMapOf<Long, Int>()
        countHighestScore(parents.size, root, scores)
        var answer = 0
        var maxScore = 0L
        for ((score, count) in scores) {
           if (score > maxScore) {
               maxScore = score
               answer = count
           }
        }
        return answer
    }

    data class Node(val value: Int, var left: Node? = null, var right: Node? = null)

    private fun buildTree(parents: IntArray): Node? {
        val nodes = Array(parents.size) { i -> Node(i) }
        var root: Node? = null
        for ((index, parentIndex) in parents.withIndex()) {
            if (parentIndex == -1) {
                root = nodes[0]
            } else {
                val parent = nodes[parentIndex]
                val child = nodes[index]
                if (parent.left == null) {
                    parent.left = child
                } else {
                    parent.right = child
                }
            }
        }
        return root
    }

    private fun countHighestScore(n: Int, root: Node?, scores: MutableMap<Long, Int>): Long {
        if (root == null) {
            return -1
        }
        val left = countHighestScore(n, root.left, scores) + 1
        val right = countHighestScore(n, root.right, scores) + 1
        val score = (if (left == 0L) 1 else left) *
                (if (right == 0L) 1 else right) *
                (if (n - (left + right + 1) == 0L) 1 else n - (left + right + 1))
        scores[score] = (scores[score] ?: 0) + 1
        return left + right
    }
}

Compiled from "Problem2049.kt"
public final class leetcode.Problem2049 {
  public leetcode.Problem2049();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int countHighestScoreNodes(int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String parents
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #25                 // Method buildTree:([I)Lleetcode/Problem2049$Node;
      11: astore_2
      12: new           #27                 // class java/util/LinkedHashMap
      15: dup
      16: invokespecial #28                 // Method java/util/LinkedHashMap."<init>":()V
      19: checkcast     #30                 // class java/util/Map
      22: astore_3
      23: aload_0
      24: aload_1
      25: arraylength
      26: aload_2
      27: aload_3
      28: invokespecial #34                 // Method countHighestScore:(ILleetcode/Problem2049$Node;Ljava/util/Map;)J
      31: pop2
      32: iconst_0
      33: istore        4
      35: lconst_0
      36: lstore        5
      38: aload_3
      39: invokeinterface #38,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      44: invokeinterface #44,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      49: astore        7
      51: aload         7
      53: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          122
      61: aload         7
      63: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: checkcast     #56                 // class java/util/Map$Entry
      71: astore        8
      73: aload         8
      75: invokeinterface #59,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      80: checkcast     #61                 // class java/lang/Number
      83: invokevirtual #65                 // Method java/lang/Number.longValue:()J
      86: lstore        9
      88: aload         8
      90: invokeinterface #68,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      95: checkcast     #61                 // class java/lang/Number
      98: invokevirtual #72                 // Method java/lang/Number.intValue:()I
     101: istore        11
     103: lload         9
     105: lload         5
     107: lcmp
     108: ifle          51
     111: lload         9
     113: lstore        5
     115: iload         11
     117: istore        4
     119: goto          51
     122: iload         4
     124: ireturn

  private final leetcode.Problem2049$Node buildTree(int[]);
    Code:
       0: iconst_0
       1: istore_3
       2: aload_1
       3: arraylength
       4: istore        4
       6: iload         4
       8: anewarray     #86                 // class leetcode/Problem2049$Node
      11: astore        5
      13: iload_3
      14: iload         4
      16: if_icmpge     47
      19: iload_3
      20: istore        6
      22: aload         5
      24: iload         6
      26: new           #86                 // class leetcode/Problem2049$Node
      29: dup
      30: iload         6
      32: aconst_null
      33: aconst_null
      34: bipush        6
      36: aconst_null
      37: invokespecial #89                 // Method leetcode/Problem2049$Node."<init>":(ILleetcode/Problem2049$Node;Lleetcode/Problem2049$Node;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      40: aastore
      41: iinc          3, 1
      44: goto          13
      47: aload         5
      49: astore_2
      50: aconst_null
      51: astore_3
      52: iconst_0
      53: istore        4
      55: aload_1
      56: arraylength
      57: istore        5
      59: iload         4
      61: iload         5
      63: if_icmpge     132
      66: iload         4
      68: istore        6
      70: aload_1
      71: iload         4
      73: iaload
      74: istore        7
      76: iload         7
      78: iconst_m1
      79: if_icmpne     89
      82: aload_2
      83: iconst_0
      84: aaload
      85: astore_3
      86: goto          126
      89: aload_2
      90: iload         7
      92: aaload
      93: astore        8
      95: aload_2
      96: iload         6
      98: aaload
      99: astore        9
     101: aload         8
     103: invokevirtual #93                 // Method leetcode/Problem2049$Node.getLeft:()Lleetcode/Problem2049$Node;
     106: ifnonnull     119
     109: aload         8
     111: aload         9
     113: invokevirtual #97                 // Method leetcode/Problem2049$Node.setLeft:(Lleetcode/Problem2049$Node;)V
     116: goto          126
     119: aload         8
     121: aload         9
     123: invokevirtual #100                // Method leetcode/Problem2049$Node.setRight:(Lleetcode/Problem2049$Node;)V
     126: iinc          4, 1
     129: goto          59
     132: aload_3
     133: areturn

  private final long countHighestScore(int, leetcode.Problem2049$Node, java.util.Map<java.lang.Long, java.lang.Integer>);
    Code:
       0: aload_2
       1: ifnonnull     8
       4: ldc2_w        #109                // long -1l
       7: lreturn
       8: aload_0
       9: iload_1
      10: aload_2
      11: invokevirtual #93                 // Method leetcode/Problem2049$Node.getLeft:()Lleetcode/Problem2049$Node;
      14: aload_3
      15: invokespecial #34                 // Method countHighestScore:(ILleetcode/Problem2049$Node;Ljava/util/Map;)J
      18: lconst_1
      19: ladd
      20: lstore        4
      22: aload_0
      23: iload_1
      24: aload_2
      25: invokevirtual #113                // Method leetcode/Problem2049$Node.getRight:()Lleetcode/Problem2049$Node;
      28: aload_3
      29: invokespecial #34                 // Method countHighestScore:(ILleetcode/Problem2049$Node;Ljava/util/Map;)J
      32: lconst_1
      33: ladd
      34: lstore        6
      36: lload         4
      38: lconst_0
      39: lcmp
      40: ifne          47
      43: lconst_1
      44: goto          49
      47: lload         4
      49: lload         6
      51: lconst_0
      52: lcmp
      53: ifne          60
      56: lconst_1
      57: goto          62
      60: lload         6
      62: lmul
      63: iload_1
      64: i2l
      65: lload         4
      67: lload         6
      69: ladd
      70: lconst_1
      71: ladd
      72: lsub
      73: lconst_0
      74: lcmp
      75: ifne          82
      78: lconst_1
      79: goto          92
      82: iload_1
      83: i2l
      84: lload         4
      86: lload         6
      88: ladd
      89: lconst_1
      90: ladd
      91: lsub
      92: lmul
      93: lstore        8
      95: aload_3
      96: astore        10
      98: lload         8
     100: invokestatic  #119                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     103: astore        11
     105: aload_3
     106: lload         8
     108: invokestatic  #119                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     111: invokeinterface #123,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     116: checkcast     #125                // class java/lang/Integer
     119: dup
     120: ifnull        129
     123: invokevirtual #126                // Method java/lang/Integer.intValue:()I
     126: goto          131
     129: pop
     130: iconst_0
     131: iconst_1
     132: iadd
     133: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     136: astore        12
     138: aload         10
     140: aload         11
     142: aload         12
     144: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     149: pop
     150: lload         4
     152: lload         6
     154: ladd
     155: lreturn
}

Compiled from "Problem2049.kt"
public final class leetcode.Problem2049$Node {
  private final int value;

  private leetcode.Problem2049$Node left;

  private leetcode.Problem2049$Node right;

  public leetcode.Problem2049$Node(int, leetcode.Problem2049$Node, leetcode.Problem2049$Node);
    Code:
       0: aload_0
       1: invokespecial #10                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #14                 // Field value:I
       9: aload_0
      10: aload_2
      11: putfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      14: aload_0
      15: aload_3
      16: putfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      19: return

  public leetcode.Problem2049$Node(int, leetcode.Problem2049$Node, leetcode.Problem2049$Node, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          9
       7: aconst_null
       8: astore_2
       9: iload         4
      11: iconst_4
      12: iand
      13: ifeq          18
      16: aconst_null
      17: astore_3
      18: aload_0
      19: iload_1
      20: aload_2
      21: aload_3
      22: invokespecial #25                 // Method "<init>":(ILleetcode/Problem2049$Node;Lleetcode/Problem2049$Node;)V
      25: return

  public final int getValue();
    Code:
       0: aload_0
       1: getfield      #14                 // Field value:I
       4: ireturn

  public final leetcode.Problem2049$Node getLeft();
    Code:
       0: aload_0
       1: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
       4: areturn

  public final void setLeft(leetcode.Problem2049$Node);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field left:Lleetcode/Problem2049$Node;
       5: return

  public final leetcode.Problem2049$Node getRight();
    Code:
       0: aload_0
       1: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
       4: areturn

  public final void setRight(leetcode.Problem2049$Node);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #21                 // Field right:Lleetcode/Problem2049$Node;
       5: return

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #14                 // Field value:I
       4: ireturn

  public final leetcode.Problem2049$Node component2();
    Code:
       0: aload_0
       1: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
       4: areturn

  public final leetcode.Problem2049$Node component3();
    Code:
       0: aload_0
       1: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
       4: areturn

  public final leetcode.Problem2049$Node copy(int, leetcode.Problem2049$Node, leetcode.Problem2049$Node);
    Code:
       0: new           #2                  // class leetcode/Problem2049$Node
       3: dup
       4: iload_1
       5: aload_2
       6: aload_3
       7: invokespecial #25                 // Method "<init>":(ILleetcode/Problem2049$Node;Lleetcode/Problem2049$Node;)V
      10: areturn

  public static leetcode.Problem2049$Node copy$default(leetcode.Problem2049$Node, int, leetcode.Problem2049$Node, leetcode.Problem2049$Node, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #14                 // Field value:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      35: astore_3
      36: aload_0
      37: iload_1
      38: aload_2
      39: aload_3
      40: invokevirtual #44                 // Method copy:(ILleetcode/Problem2049$Node;Lleetcode/Problem2049$Node;)Lleetcode/Problem2049$Node;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #48                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #49                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #51                 // String Node(value=
       9: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #14                 // Field value:I
      16: invokevirtual #58                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #60                 // String , left=
      21: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      28: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #65                 // String , right=
      33: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      40: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #68                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #14                 // Field value:I
       4: invokestatic  #76                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      16: ifnonnull     23
      19: iconst_0
      20: goto          30
      23: aload_0
      24: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      27: invokevirtual #78                 // Method hashCode:()I
      30: iadd
      31: istore_1
      32: iload_1
      33: bipush        31
      35: imul
      36: aload_0
      37: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      40: ifnonnull     47
      43: iconst_0
      44: goto          54
      47: aload_0
      48: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      51: invokevirtual #78                 // Method hashCode:()I
      54: iadd
      55: istore_1
      56: iload_1
      57: 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 leetcode/Problem2049$Node
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class leetcode/Problem2049$Node
      20: astore_2
      21: aload_0
      22: getfield      #14                 // Field value:I
      25: aload_2
      26: getfield      #14                 // Field value:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      38: aload_2
      39: getfield      #18                 // Field left:Lleetcode/Problem2049$Node;
      42: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      54: aload_2
      55: getfield      #21                 // Field right:Lleetcode/Problem2049$Node;
      58: invokestatic  #87                 // 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
}


package leetcode

/**
 * https://leetcode.com/problems/maximum-points-in-an-archery-competition/
 */
class Problem2212 {
    fun maximumBobPoints(numArrows: Int, aliceArrows: IntArray): IntArray {
        val answer = Answer()
        maximumBobPoints(numArrows, aliceArrows, IntArray(12), 0, 0, answer)
        return answer.bobArrows
    }

    private data class Answer(var max: Int = 0, var bobArrows: IntArray = IntArray(12))

    private fun maximumBobPoints(numArrows: Int, aliceArrows: IntArray,
                                 bobArrows: IntArray, index: Int, sum: Int, answer: Answer) {
        if (index == aliceArrows.size) {
            if (sum > answer.max) {
                answer.max = sum
                answer.bobArrows = bobArrows.copyOf()
                answer.bobArrows[0] = numArrows
            }
            return
        }
        maximumBobPoints(numArrows, aliceArrows, bobArrows, index + 1, sum, answer)
        if (numArrows - (aliceArrows[index] + 1) >= 0) {
            bobArrows[index] = aliceArrows[index] + 1
            maximumBobPoints(numArrows - (aliceArrows[index] + 1),
                aliceArrows, bobArrows, index + 1, sum + index, answer)
            bobArrows[index] = 0
        }
    }
}

Compiled from "Problem2212.kt"
public final class leetcode.Problem2212 {
  public leetcode.Problem2212();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] maximumBobPoints(int, int[]);
    Code:
       0: aload_2
       1: ldc           #15                 // String aliceArrows
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #23                 // class leetcode/Problem2212$Answer
       9: dup
      10: iconst_0
      11: aconst_null
      12: iconst_3
      13: aconst_null
      14: invokespecial #26                 // Method leetcode/Problem2212$Answer."<init>":(I[IILkotlin/jvm/internal/DefaultConstructorMarker;)V
      17: astore_3
      18: aload_0
      19: iload_1
      20: aload_2
      21: bipush        12
      23: newarray       int
      25: iconst_0
      26: iconst_0
      27: aload_3
      28: invokespecial #29                 // Method maximumBobPoints:(I[I[IIILleetcode/Problem2212$Answer;)V
      31: aload_3
      32: invokevirtual #33                 // Method leetcode/Problem2212$Answer.getBobArrows:()[I
      35: areturn

  private final void maximumBobPoints(int, int[], int[], int, int, leetcode.Problem2212$Answer);
    Code:
       0: iload         4
       2: aload_2
       3: arraylength
       4: if_icmpne     50
       7: iload         5
       9: aload         6
      11: invokevirtual #42                 // Method leetcode/Problem2212$Answer.getMax:()I
      14: if_icmple     49
      17: aload         6
      19: iload         5
      21: invokevirtual #46                 // Method leetcode/Problem2212$Answer.setMax:(I)V
      24: aload         6
      26: aload_3
      27: dup
      28: arraylength
      29: invokestatic  #52                 // Method java/util/Arrays.copyOf:([II)[I
      32: dup
      33: ldc           #54                 // String copyOf(...)
      35: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      38: invokevirtual #61                 // Method leetcode/Problem2212$Answer.setBobArrows:([I)V
      41: aload         6
      43: invokevirtual #33                 // Method leetcode/Problem2212$Answer.getBobArrows:()[I
      46: iconst_0
      47: iload_1
      48: iastore
      49: return
      50: aload_0
      51: iload_1
      52: aload_2
      53: aload_3
      54: iload         4
      56: iconst_1
      57: iadd
      58: iload         5
      60: aload         6
      62: invokespecial #29                 // Method maximumBobPoints:(I[I[IIILleetcode/Problem2212$Answer;)V
      65: iload_1
      66: aload_2
      67: iload         4
      69: iaload
      70: iconst_1
      71: iadd
      72: isub
      73: iflt          116
      76: aload_3
      77: iload         4
      79: aload_2
      80: iload         4
      82: iaload
      83: iconst_1
      84: iadd
      85: iastore
      86: aload_0
      87: iload_1
      88: aload_2
      89: iload         4
      91: iaload
      92: iconst_1
      93: iadd
      94: isub
      95: aload_2
      96: aload_3
      97: iload         4
      99: iconst_1
     100: iadd
     101: iload         5
     103: iload         4
     105: iadd
     106: aload         6
     108: invokespecial #29                 // Method maximumBobPoints:(I[I[IIILleetcode/Problem2212$Answer;)V
     111: aload_3
     112: iload         4
     114: iconst_0
     115: iastore
     116: return
}

Compiled from "Problem2212.kt"
final class leetcode.Problem2212$Answer {
  private int max;

  private int[] bobArrows;

  public leetcode.Problem2212$Answer(int, int[]);
    Code:
       0: aload_2
       1: ldc           #9                  // String bobArrows
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: iload_1
      12: putfield      #22                 // Field max:I
      15: aload_0
      16: aload_2
      17: putfield      #25                 // Field bobArrows:[I
      20: return

  public leetcode.Problem2212$Answer(int, int[], int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_3
       9: iconst_2
      10: iand
      11: ifeq          19
      14: bipush        12
      16: newarray       int
      18: astore_2
      19: aload_0
      20: iload_1
      21: aload_2
      22: invokespecial #30                 // Method "<init>":(I[I)V
      25: return

  public final int getMax();
    Code:
       0: aload_0
       1: getfield      #22                 // Field max:I
       4: ireturn

  public final void setMax(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #22                 // Field max:I
       5: return

  public final int[] getBobArrows();
    Code:
       0: aload_0
       1: getfield      #25                 // Field bobArrows:[I
       4: areturn

  public final void setBobArrows(int[]);
    Code:
       0: aload_1
       1: ldc           #40                 // String <set-?>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: putfield      #25                 // Field bobArrows:[I
      11: return

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field max:I
       4: ireturn

  public final int[] component2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field bobArrows:[I
       4: areturn

  public final leetcode.Problem2212$Answer copy(int, int[]);
    Code:
       0: aload_2
       1: ldc           #9                  // String bobArrows
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class leetcode/Problem2212$Answer
       9: dup
      10: iload_1
      11: aload_2
      12: invokespecial #30                 // Method "<init>":(I[I)V
      15: areturn

  public static leetcode.Problem2212$Answer copy$default(leetcode.Problem2212$Answer, int, int[], int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field max:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #25                 // Field bobArrows:[I
      21: astore_2
      22: aload_0
      23: iload_1
      24: aload_2
      25: invokevirtual #48                 // Method copy:(I[I)Lleetcode/Problem2212$Answer;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #52                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #55                 // String Answer(max=
       9: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field max:I
      16: invokevirtual #62                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #64                 // String , bobArrows=
      21: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #25                 // Field bobArrows:[I
      28: invokestatic  #69                 // Method java/util/Arrays.toString:([I)Ljava/lang/String;
      31: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      34: bipush        41
      36: invokevirtual #72                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      39: invokevirtual #74                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      42: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field max:I
       4: invokestatic  #80                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #25                 // Field bobArrows:[I
      16: invokestatic  #83                 // Method java/util/Arrays.hashCode:([I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: 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 leetcode/Problem2212$Answer
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class leetcode/Problem2212$Answer
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field max:I
      25: aload_2
      26: getfield      #22                 // Field max:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #25                 // Field bobArrows:[I
      38: aload_2
      39: getfield      #25                 // Field bobArrows:[I
      42: invokestatic  #91                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn

  public leetcode.Problem2212$Answer();
    Code:
       0: aload_0
       1: iconst_0
       2: aconst_null
       3: iconst_3
       4: aconst_null
       5: invokespecial #95                 // Method "<init>":(I[IILkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: return
}


package leetcode

/**
 * https://leetcode.com/problems/count-unguarded-cells-in-the-grid/
 */
class Problem2257 {
    fun countUnguarded(m: Int, n: Int, guards: Array<IntArray>, walls: Array<IntArray>): Int {
        val grid = Array(m) { IntArray(n) { UNGUARDED } }
        for ((r, c) in guards) {
            grid[r][c] = GUARD
        }
        for ((r, c) in walls) {
            grid[r][c] = WALL
        }
        for ((r, c) in guards) {
            // Up
            var i = r - 1
            while (i >= 0 && (grid[i][c] != WALL && grid[i][c] != GUARD)) {
                grid[i][c] = GUARDED
                i--
            }
            // Right
            i = c + 1
            while (i < n && (grid[r][i] != WALL && grid[r][i] != GUARD)) {
                grid[r][i] = GUARDED
                i++
            }
            // Down
            i = r + 1
            while (i < m && (grid[i][c] != WALL && grid[i][c] != GUARD)) {
                grid[i][c] = GUARDED
                i++
            }
            // Left
            i = c - 1
            while (i >= 0 && (grid[r][i] != WALL && grid[r][i] != GUARD)) {
                grid[r][i] = GUARDED
                i--
            }
        }
        var answer = 0
        for (i in 0 until m) {
            for (j in 0 until n) {
                if (grid[i][j] == UNGUARDED) {
                    answer++
                }
            }
        }
        return answer
    }

    companion object {
        private const val GUARD = 1
        private const val WALL = 2
        private const val GUARDED = 3
        private const val UNGUARDED = 4
    }
}

Compiled from "Problem2257.kt"
public final class leetcode.Problem2257 {
  public static final leetcode.Problem2257$Companion Companion;

  private static final int GUARD;

  private static final int WALL;

  private static final int GUARDED;

  private static final int UNGUARDED;

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

  public final int countUnguarded(int, int, int[][], int[][]);
    Code:
       0: aload_3
       1: ldc           #15                 // String guards
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload         4
       8: ldc           #23                 // String walls
      10: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: iconst_0
      14: istore        6
      16: iload_1
      17: anewarray     #25                 // class "[I"
      20: astore        7
      22: iload         6
      24: iload_1
      25: if_icmpge     83
      28: iload         6
      30: istore        8
      32: aload         7
      34: iload         8
      36: iconst_0
      37: istore        9
      39: iload_2
      40: newarray       int
      42: astore        10
      44: istore        13
      46: astore        12
      48: iload         9
      50: iload_2
      51: if_icmpge     70
      54: iload         9
      56: istore        11
      58: aload         10
      60: iload         11
      62: iconst_4
      63: iastore
      64: iinc          9, 1
      67: goto          48
      70: aload         12
      72: iload         13
      74: aload         10
      76: aastore
      77: iinc          6, 1
      80: goto          22
      83: aload         7
      85: astore        5
      87: iconst_0
      88: istore        6
      90: aload_3
      91: checkcast     #27                 // class "[Ljava/lang/Object;"
      94: arraylength
      95: istore        7
      97: iload         6
      99: iload         7
     101: if_icmpge     137
     104: aload_3
     105: iload         6
     107: aaload
     108: astore        8
     110: aload         8
     112: iconst_0
     113: iaload
     114: istore        9
     116: aload         8
     118: iconst_1
     119: iaload
     120: istore        10
     122: aload         5
     124: iload         9
     126: aaload
     127: iload         10
     129: iconst_1
     130: iastore
     131: iinc          6, 1
     134: goto          97
     137: iconst_0
     138: istore        6
     140: aload         4
     142: checkcast     #27                 // class "[Ljava/lang/Object;"
     145: arraylength
     146: istore        7
     148: iload         6
     150: iload         7
     152: if_icmpge     189
     155: aload         4
     157: iload         6
     159: aaload
     160: astore        8
     162: aload         8
     164: iconst_0
     165: iaload
     166: istore        9
     168: aload         8
     170: iconst_1
     171: iaload
     172: istore        10
     174: aload         5
     176: iload         9
     178: aaload
     179: iload         10
     181: iconst_2
     182: iastore
     183: iinc          6, 1
     186: goto          148
     189: iconst_0
     190: istore        6
     192: aload_3
     193: checkcast     #27                 // class "[Ljava/lang/Object;"
     196: arraylength
     197: istore        7
     199: iload         6
     201: iload         7
     203: if_icmpge     432
     206: aload_3
     207: iload         6
     209: aaload
     210: astore        8
     212: aload         8
     214: iconst_0
     215: iaload
     216: istore        9
     218: aload         8
     220: iconst_1
     221: iaload
     222: istore        10
     224: iload         9
     226: iconst_1
     227: isub
     228: istore        11
     230: iload         11
     232: iflt          274
     235: aload         5
     237: iload         11
     239: aaload
     240: iload         10
     242: iaload
     243: iconst_2
     244: if_icmpeq     274
     247: aload         5
     249: iload         11
     251: aaload
     252: iload         10
     254: iaload
     255: iconst_1
     256: if_icmpeq     274
     259: aload         5
     261: iload         11
     263: aaload
     264: iload         10
     266: iconst_3
     267: iastore
     268: iinc          11, -1
     271: goto          230
     274: iload         10
     276: iconst_1
     277: iadd
     278: istore        11
     280: iload         11
     282: iload_2
     283: if_icmpge     325
     286: aload         5
     288: iload         9
     290: aaload
     291: iload         11
     293: iaload
     294: iconst_2
     295: if_icmpeq     325
     298: aload         5
     300: iload         9
     302: aaload
     303: iload         11
     305: iaload
     306: iconst_1
     307: if_icmpeq     325
     310: aload         5
     312: iload         9
     314: aaload
     315: iload         11
     317: iconst_3
     318: iastore
     319: iinc          11, 1
     322: goto          280
     325: iload         9
     327: iconst_1
     328: iadd
     329: istore        11
     331: iload         11
     333: iload_1
     334: if_icmpge     376
     337: aload         5
     339: iload         11
     341: aaload
     342: iload         10
     344: iaload
     345: iconst_2
     346: if_icmpeq     376
     349: aload         5
     351: iload         11
     353: aaload
     354: iload         10
     356: iaload
     357: iconst_1
     358: if_icmpeq     376
     361: aload         5
     363: iload         11
     365: aaload
     366: iload         10
     368: iconst_3
     369: iastore
     370: iinc          11, 1
     373: goto          331
     376: iload         10
     378: iconst_1
     379: isub
     380: istore        11
     382: iload         11
     384: iflt          426
     387: aload         5
     389: iload         9
     391: aaload
     392: iload         11
     394: iaload
     395: iconst_2
     396: if_icmpeq     426
     399: aload         5
     401: iload         9
     403: aaload
     404: iload         11
     406: iaload
     407: iconst_1
     408: if_icmpeq     426
     411: aload         5
     413: iload         9
     415: aaload
     416: iload         11
     418: iconst_3
     419: iastore
     420: iinc          11, -1
     423: goto          382
     426: iinc          6, 1
     429: goto          199
     432: iconst_0
     433: istore        6
     435: iconst_0
     436: istore        7
     438: iload         7
     440: iload_1
     441: if_icmpge     480
     444: iconst_0
     445: istore        8
     447: iload         8
     449: iload_2
     450: if_icmpge     474
     453: aload         5
     455: iload         7
     457: aaload
     458: iload         8
     460: iaload
     461: iconst_4
     462: if_icmpne     468
     465: iinc          6, 1
     468: iinc          8, 1
     471: goto          447
     474: iinc          7, 1
     477: goto          438
     480: iload         6
     482: ireturn

  static {};
    Code:
       0: new           #41                 // class leetcode/Problem2257$Companion
       3: dup
       4: aconst_null
       5: invokespecial #44                 // Method leetcode/Problem2257$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #48                 // Field Companion:Lleetcode/Problem2257$Companion;
      11: return
}

Compiled from "Problem2257.kt"
public final class leetcode.Problem2257$Companion {
  private leetcode.Problem2257$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public leetcode.Problem2257$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #12                 // Method "<init>":()V
       4: return
}


package leetcode

import java.util.TreeSet

/**
 * https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/
 */
class Problem1878 {
    fun getBiggestThree(grid: Array<IntArray>): IntArray {
        val rightDiagonalSums = mutableMapOf<RowCol, Int>()
        val maxRow = grid.size
        val maxCol = if (maxRow > 0) grid[0].size else 0
        for (row in 0 until maxRow) {
            rightDiagonalSums(grid, rightDiagonalSums, row, 0)
        }
        for (col in 0 until maxCol) {
            rightDiagonalSums(grid, rightDiagonalSums, 0, col)
        }
        val leftDiagonalSums = mutableMapOf<RowCol, Int>()
        for (row in 0 until maxRow) {
            leftDiagonalSums(grid, leftDiagonalSums, row, maxCol - 1)
        }
        for (col in maxCol - 1 downTo 0) {
            leftDiagonalSums(grid, leftDiagonalSums, 0, col)
        }
        val set = TreeSet<Int>()
        for (row in 0 until maxRow) {
            for (col in 0 until maxCol) {
                set += rhombusSum(grid, leftDiagonalSums, rightDiagonalSums, row, col)
            }
        }
        var list = mutableListOf<Int>()
        var i = 0
        while (set.isNotEmpty() && i < 3) {
            list.add(set.pollLast())
            i++
        }
        return list.toIntArray()
    }

    private data class RowCol(val row: Int, val col: Int)

    private fun rightDiagonalSums(grid: Array<IntArray>,
                                  rightDiagonalSums: MutableMap<RowCol, Int>,
                                  row: Int, col: Int) {
        val maxRow = grid.size
        val maxCol = if (maxRow > 0) grid[0].size else 0
        var r = row
        var c = col
        while (r < maxRow && c < maxCol) {
            rightDiagonalSums[RowCol(r, c)] = if (rightDiagonalSums[RowCol(r - 1, c - 1)] == null) {
                grid[r][c]
            } else {
                rightDiagonalSums[RowCol(r - 1, c - 1)]!! + grid[r][c]
            }
            r++
            c++
        }
    }

    private fun leftDiagonalSums(grid: Array<IntArray>,
                                 leftDiagonalSums: MutableMap<RowCol, Int>,
                                 row: Int, col: Int) {
        val maxRow = grid.size
        var r = row
        var c = col
        while (r < maxRow && c >= 0) {
            leftDiagonalSums[RowCol(r, c)] = if (leftDiagonalSums[RowCol(r - 1, c + 1)] == null) {
                grid[r][c]
            } else {
                leftDiagonalSums[RowCol(r - 1, c + 1)]!! + grid[r][c]
            }
            r++
            c--
        }
    }

    private fun rhombusSum(grid: Array<IntArray>,
                           leftDiagonalSums: MutableMap<RowCol, Int>,
                           rightDiagonalSums: MutableMap<RowCol, Int>,
                           row: Int, col: Int): MutableSet<Int> {
        val set = mutableSetOf(grid[row][col])
        val maxRow = grid.size
        val maxCol = if (maxRow > 0) grid[0].size else 0
        var r = row
        val c = col
        var length = 1
        while (r + (length * 2) < maxRow && c - length >= 0 && c + length < maxCol) {
            val topLeft = leftDiagonalSums[RowCol(r + length, c - length)]!! -
                    leftDiagonalSums[RowCol(r, c)]!! + grid[r][c]
            val topRight = rightDiagonalSums[RowCol(r + length, c + length)]!! -
                    rightDiagonalSums[RowCol(r, c)]!! + grid[r][c]
            val bottomLeft = rightDiagonalSums[RowCol(r + length * 2, c)]!! -
                    rightDiagonalSums[RowCol(r + length, c - length)]!! +
                    grid[r + length][c - length]
            val bottomRight = leftDiagonalSums[RowCol(r + length * 2, c)]!! -
                    leftDiagonalSums[RowCol(r + length, c + length)]!! +
                    grid[r + length][c + length]
            val sum = topLeft + topRight + bottomLeft + bottomRight -
                    (grid[r][c] + grid[r + length][c - length] +
                            grid[r + length][c + length] + grid[r + length * 2][c])
            set += sum
            length++
        }
        return set
    }
}

Compiled from "Problem1878.kt"
final class leetcode.Problem1878$RowCol {
  private final int row;

  private final int col;

  public leetcode.Problem1878$RowCol(int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field row:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field col:I
      14: return

  public final int getRow();
    Code:
       0: aload_0
       1: getfield      #13                 // Field row:I
       4: ireturn

  public final int getCol();
    Code:
       0: aload_0
       1: getfield      #16                 // Field col:I
       4: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field row:I
       4: ireturn

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

  public final leetcode.Problem1878$RowCol copy(int, int);
    Code:
       0: new           #2                  // class leetcode/Problem1878$RowCol
       3: dup
       4: iload_1
       5: iload_2
       6: invokespecial #28                 // Method "<init>":(II)V
       9: areturn

  public static leetcode.Problem1878$RowCol copy$default(leetcode.Problem1878$RowCol, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #13                 // Field row:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #16                 // Field col:I
      21: istore_2
      22: aload_0
      23: iload_1
      24: iload_2
      25: invokevirtual #32                 // Method copy:(II)Lleetcode/Problem1878$RowCol;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #39                 // String RowCol(row=
       9: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field row:I
      16: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #48                 // String , col=
      21: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field col:I
      28: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #51                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field row:I
       4: invokestatic  #59                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field col:I
      16: invokestatic  #59                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: 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 leetcode/Problem1878$RowCol
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class leetcode/Problem1878$RowCol
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field row:I
      25: aload_2
      26: getfield      #13                 // Field row:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field col:I
      38: aload_2
      39: getfield      #16                 // Field col:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: iconst_1
      48: ireturn
}

Compiled from "Problem1878.kt"
public final class leetcode.Problem1878 {
  public leetcode.Problem1878();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] getBiggestThree(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String grid
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #23                 // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #24                 // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #26                 // class java/util/Map
      16: astore_2
      17: aload_1
      18: checkcast     #28                 // class "[Ljava/lang/Object;"
      21: arraylength
      22: istore_3
      23: iload_3
      24: ifle          34
      27: aload_1
      28: iconst_0
      29: aaload
      30: arraylength
      31: goto          35
      34: iconst_0
      35: istore        4
      37: iconst_0
      38: istore        5
      40: iload         5
      42: iload_3
      43: if_icmpge     61
      46: aload_0
      47: aload_1
      48: aload_2
      49: iload         5
      51: iconst_0
      52: invokespecial #32                 // Method rightDiagonalSums:([[ILjava/util/Map;II)V
      55: iinc          5, 1
      58: goto          40
      61: iconst_0
      62: istore        5
      64: iload         5
      66: iload         4
      68: if_icmpge     86
      71: aload_0
      72: aload_1
      73: aload_2
      74: iconst_0
      75: iload         5
      77: invokespecial #32                 // Method rightDiagonalSums:([[ILjava/util/Map;II)V
      80: iinc          5, 1
      83: goto          64
      86: new           #23                 // class java/util/LinkedHashMap
      89: dup
      90: invokespecial #24                 // Method java/util/LinkedHashMap."<init>":()V
      93: checkcast     #26                 // class java/util/Map
      96: astore        5
      98: iconst_0
      99: istore        6
     101: iload         6
     103: iload_3
     104: if_icmpge     126
     107: aload_0
     108: aload_1
     109: aload         5
     111: iload         6
     113: iload         4
     115: iconst_1
     116: isub
     117: invokespecial #35                 // Method leftDiagonalSums:([[ILjava/util/Map;II)V
     120: iinc          6, 1
     123: goto          101
     126: iload         4
     128: iconst_1
     129: isub
     130: istore        6
     132: iconst_m1
     133: iload         6
     135: if_icmpge     154
     138: aload_0
     139: aload_1
     140: aload         5
     142: iconst_0
     143: iload         6
     145: invokespecial #35                 // Method leftDiagonalSums:([[ILjava/util/Map;II)V
     148: iinc          6, -1
     151: goto          132
     154: new           #37                 // class java/util/TreeSet
     157: dup
     158: invokespecial #38                 // Method java/util/TreeSet."<init>":()V
     161: astore        6
     163: iconst_0
     164: istore        7
     166: iload         7
     168: iload_3
     169: if_icmpge     218
     172: iconst_0
     173: istore        8
     175: iload         8
     177: iload         4
     179: if_icmpge     212
     182: aload         6
     184: checkcast     #40                 // class java/util/Collection
     187: aload_0
     188: aload_1
     189: aload         5
     191: aload_2
     192: iload         7
     194: iload         8
     196: invokespecial #44                 // Method rhombusSum:([[ILjava/util/Map;Ljava/util/Map;II)Ljava/util/Set;
     199: checkcast     #46                 // class java/lang/Iterable
     202: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     205: pop
     206: iinc          8, 1
     209: goto          175
     212: iinc          7, 1
     215: goto          166
     218: new           #54                 // class java/util/ArrayList
     221: dup
     222: invokespecial #55                 // Method java/util/ArrayList."<init>":()V
     225: checkcast     #57                 // class java/util/List
     228: astore        7
     230: iconst_0
     231: istore        8
     233: aload         6
     235: checkcast     #40                 // class java/util/Collection
     238: invokeinterface #61,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     243: ifne          250
     246: iconst_1
     247: goto          251
     250: iconst_0
     251: ifeq          285
     254: iload         8
     256: iconst_3
     257: if_icmpge     285
     260: aload         7
     262: aload         6
     264: invokevirtual #65                 // Method java/util/TreeSet.pollLast:()Ljava/lang/Object;
     267: dup
     268: ldc           #67                 // String pollLast(...)
     270: invokestatic  #70                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     273: invokeinterface #74,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     278: pop
     279: iinc          8, 1
     282: goto          233
     285: aload         7
     287: checkcast     #40                 // class java/util/Collection
     290: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     293: areturn

  private final void rightDiagonalSums(int[][], java.util.Map<leetcode.Problem1878$RowCol, java.lang.Integer>, int, int);
    Code:
       0: aload_1
       1: checkcast     #28                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore        5
       7: iload         5
       9: ifle          19
      12: aload_1
      13: iconst_0
      14: aaload
      15: arraylength
      16: goto          20
      19: iconst_0
      20: istore        6
      22: iload_3
      23: istore        7
      25: iload         4
      27: istore        8
      29: iload         7
      31: iload         5
      33: if_icmpge     147
      36: iload         8
      38: iload         6
      40: if_icmpge     147
      43: nop
      44: aload_2
      45: new           #94                 // class leetcode/Problem1878$RowCol
      48: dup
      49: iload         7
      51: iload         8
      53: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
      56: aload_2
      57: new           #94                 // class leetcode/Problem1878$RowCol
      60: dup
      61: iload         7
      63: iconst_1
      64: isub
      65: iload         8
      67: iconst_1
      68: isub
      69: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
      72: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      77: ifnonnull     90
      80: aload_1
      81: iload         7
      83: aaload
      84: iload         8
      86: iaload
      87: goto          129
      90: aload_2
      91: new           #94                 // class leetcode/Problem1878$RowCol
      94: dup
      95: iload         7
      97: iconst_1
      98: isub
      99: iload         8
     101: iconst_1
     102: isub
     103: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     106: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     111: dup
     112: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     115: checkcast     #107                // class java/lang/Number
     118: invokevirtual #111                // Method java/lang/Number.intValue:()I
     121: aload_1
     122: iload         7
     124: aaload
     125: iload         8
     127: iaload
     128: iadd
     129: invokestatic  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: invokeinterface #121,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     137: pop
     138: iinc          7, 1
     141: iinc          8, 1
     144: goto          29
     147: return

  private final void leftDiagonalSums(int[][], java.util.Map<leetcode.Problem1878$RowCol, java.lang.Integer>, int, int);
    Code:
       0: aload_1
       1: checkcast     #28                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore        5
       7: iload_3
       8: istore        6
      10: iload         4
      12: istore        7
      14: iload         6
      16: iload         5
      18: if_icmpge     130
      21: iload         7
      23: iflt          130
      26: nop
      27: aload_2
      28: new           #94                 // class leetcode/Problem1878$RowCol
      31: dup
      32: iload         6
      34: iload         7
      36: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
      39: aload_2
      40: new           #94                 // class leetcode/Problem1878$RowCol
      43: dup
      44: iload         6
      46: iconst_1
      47: isub
      48: iload         7
      50: iconst_1
      51: iadd
      52: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
      55: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      60: ifnonnull     73
      63: aload_1
      64: iload         6
      66: aaload
      67: iload         7
      69: iaload
      70: goto          112
      73: aload_2
      74: new           #94                 // class leetcode/Problem1878$RowCol
      77: dup
      78: iload         6
      80: iconst_1
      81: isub
      82: iload         7
      84: iconst_1
      85: iadd
      86: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
      89: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      94: dup
      95: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      98: checkcast     #107                // class java/lang/Number
     101: invokevirtual #111                // Method java/lang/Number.intValue:()I
     104: aload_1
     105: iload         6
     107: aaload
     108: iload         7
     110: iaload
     111: iadd
     112: invokestatic  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: invokeinterface #121,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     120: pop
     121: iinc          6, 1
     124: iinc          7, -1
     127: goto          14
     130: return

  private final java.util.Set<java.lang.Integer> rhombusSum(int[][], java.util.Map<leetcode.Problem1878$RowCol, java.lang.Integer>, java.util.Map<leetcode.Problem1878$RowCol, java.lang.Integer>, int, int);
    Code:
       0: iconst_1
       1: anewarray     #113                // class java/lang/Integer
       4: astore        7
       6: aload         7
       8: iconst_0
       9: aload_1
      10: iload         4
      12: aaload
      13: iload         5
      15: iaload
      16: invokestatic  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: aastore
      20: aload         7
      22: invokestatic  #130                // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      25: astore        6
      27: aload_1
      28: checkcast     #28                 // class "[Ljava/lang/Object;"
      31: arraylength
      32: istore        7
      34: iload         7
      36: ifle          46
      39: aload_1
      40: iconst_0
      41: aaload
      42: arraylength
      43: goto          47
      46: iconst_0
      47: istore        8
      49: iload         4
      51: istore        9
      53: iload         5
      55: istore        10
      57: iconst_1
      58: istore        11
      60: iload         9
      62: iload         11
      64: iconst_2
      65: imul
      66: iadd
      67: iload         7
      69: if_icmpge     484
      72: iload         10
      74: iload         11
      76: isub
      77: iflt          484
      80: iload         10
      82: iload         11
      84: iadd
      85: iload         8
      87: if_icmpge     484
      90: aload_2
      91: new           #94                 // class leetcode/Problem1878$RowCol
      94: dup
      95: iload         9
      97: iload         11
      99: iadd
     100: iload         10
     102: iload         11
     104: isub
     105: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     108: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     113: dup
     114: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     117: checkcast     #107                // class java/lang/Number
     120: invokevirtual #111                // Method java/lang/Number.intValue:()I
     123: aload_2
     124: new           #94                 // class leetcode/Problem1878$RowCol
     127: dup
     128: iload         9
     130: iload         10
     132: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     135: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     140: dup
     141: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     144: checkcast     #107                // class java/lang/Number
     147: invokevirtual #111                // Method java/lang/Number.intValue:()I
     150: isub
     151: aload_1
     152: iload         9
     154: aaload
     155: iload         10
     157: iaload
     158: iadd
     159: istore        12
     161: aload_3
     162: new           #94                 // class leetcode/Problem1878$RowCol
     165: dup
     166: iload         9
     168: iload         11
     170: iadd
     171: iload         10
     173: iload         11
     175: iadd
     176: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     179: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     184: dup
     185: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     188: checkcast     #107                // class java/lang/Number
     191: invokevirtual #111                // Method java/lang/Number.intValue:()I
     194: aload_3
     195: new           #94                 // class leetcode/Problem1878$RowCol
     198: dup
     199: iload         9
     201: iload         10
     203: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     206: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     211: dup
     212: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     215: checkcast     #107                // class java/lang/Number
     218: invokevirtual #111                // Method java/lang/Number.intValue:()I
     221: isub
     222: aload_1
     223: iload         9
     225: aaload
     226: iload         10
     228: iaload
     229: iadd
     230: istore        13
     232: aload_3
     233: new           #94                 // class leetcode/Problem1878$RowCol
     236: dup
     237: iload         9
     239: iload         11
     241: iconst_2
     242: imul
     243: iadd
     244: iload         10
     246: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     249: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     254: dup
     255: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     258: checkcast     #107                // class java/lang/Number
     261: invokevirtual #111                // Method java/lang/Number.intValue:()I
     264: aload_3
     265: new           #94                 // class leetcode/Problem1878$RowCol
     268: dup
     269: iload         9
     271: iload         11
     273: iadd
     274: iload         10
     276: iload         11
     278: isub
     279: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     282: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     287: dup
     288: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     291: checkcast     #107                // class java/lang/Number
     294: invokevirtual #111                // Method java/lang/Number.intValue:()I
     297: isub
     298: aload_1
     299: iload         9
     301: iload         11
     303: iadd
     304: aaload
     305: iload         10
     307: iload         11
     309: isub
     310: iaload
     311: iadd
     312: istore        14
     314: aload_2
     315: new           #94                 // class leetcode/Problem1878$RowCol
     318: dup
     319: iload         9
     321: iload         11
     323: iconst_2
     324: imul
     325: iadd
     326: iload         10
     328: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     331: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     336: dup
     337: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     340: checkcast     #107                // class java/lang/Number
     343: invokevirtual #111                // Method java/lang/Number.intValue:()I
     346: aload_2
     347: new           #94                 // class leetcode/Problem1878$RowCol
     350: dup
     351: iload         9
     353: iload         11
     355: iadd
     356: iload         10
     358: iload         11
     360: iadd
     361: invokespecial #97                 // Method leetcode/Problem1878$RowCol."<init>":(II)V
     364: invokeinterface #101,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     369: dup
     370: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     373: checkcast     #107                // class java/lang/Number
     376: invokevirtual #111                // Method java/lang/Number.intValue:()I
     379: isub
     380: aload_1
     381: iload         9
     383: iload         11
     385: iadd
     386: aaload
     387: iload         10
     389: iload         11
     391: iadd
     392: iaload
     393: iadd
     394: istore        15
     396: iload         12
     398: iload         13
     400: iadd
     401: iload         14
     403: iadd
     404: iload         15
     406: iadd
     407: aload_1
     408: iload         9
     410: aaload
     411: iload         10
     413: iaload
     414: aload_1
     415: iload         9
     417: iload         11
     419: iadd
     420: aaload
     421: iload         10
     423: iload         11
     425: isub
     426: iaload
     427: iadd
     428: aload_1
     429: iload         9
     431: iload         11
     433: iadd
     434: aaload
     435: iload         10
     437: iload         11
     439: iadd
     440: iaload
     441: iadd
     442: aload_1
     443: iload         9
     445: iload         11
     447: iconst_2
     448: imul
     449: iadd
     450: aaload
     451: iload         10
     453: iaload
     454: iadd
     455: isub
     456: istore        16
     458: iload         16
     460: invokestatic  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     463: astore        17
     465: aload         6
     467: checkcast     #40                 // class java/util/Collection
     470: aload         17
     472: invokeinterface #131,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     477: pop
     478: iinc          11, 1
     481: goto          60
     484: aload         6
     486: areturn
}