package ean.estructuradedatos.taller

/**
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Universidad EAN (Bogotá - Colombia)
 * Departamento de Sistemas
 * Faculta de Ingeniería
 *
 * Taller Funciones Recursivas
 * Fecha: 18 de abril de 2023
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
               //Realizado por: <NAME> y <NAME>
import kotlin.math.pow
import kotlin.math.sqrt

/**
 * Halla el factorial del número entero n
 * n! = n * (n-1) * (n-2) * ... * 2 * 1
 */
fun factorial(n: Int): Int =
    when(n){
        1->1
        else-> factorial(n-1)*n
    }

/**
 * Halla el n-ésimo término de la serie de fibonacci
 */ //Recursión binaria
fun fibonacci(n: Int): Int =
    when(n){
        1,2->1
        else-> fibonacci(n-1) + fibonacci(n-2)
    }

/**
 * Permite determinar el término n,m del triángulo de Pascal
 * n = fila, m = término
 */
fun pascal(n: Int, m: Int): Int {
    if (m==1 || m==n+1) {
        return 1
    }
    return pascal (n-1,m) + pascal(n-1,m-1)
}
/**
 * Halla el valor de x^y =
 * si y es cero entonces retorne 1
 * sino retorne x multiplicado por elevar x a la y - 1
 */
fun elevar(x: Int, y: Int): Int =
    when(y){
        0->1
        else->x* elevar(x,y-1)
    }

/**
 * Halla la suma de todos los números enteros entre 1 y n
 */
fun sumatoria(n: Int): Int =
    when (n){
        1->1
        else-> sumatoria(n-1) + n
    }

/**
 * Halla la suma de los cuadrados de los números de 1 hasta n
 */
fun sumaCuadrados(n: Int): Int =
    when(n) {
        0->0
        else-> sumaCuadrados(n-1) + (n*n)
    }

/**
 * Hallar el valor de la sumatoria de 1/(2i+1) desde  1 hasta n
 */
fun serie(n: Int): Double =
    when(n) {
        1->1.0/3.0
        else-> serie(n-1) + 1.0/(2*n+1.0)
    }

/**
 * Hallar el valor de la sumatoria de 1 hasta n de i/(i^2+1)
 */
fun sumatoria2(n: Int): Double =
    when (n){
        1->1.0/2.0
        else-> sumatoria2(n-1) + n/((n*n)+1.0)
    }

/**
 * Permite saber la cantidad de digitos que posee un número entero positivo n
 */
fun contarDigitos(n: Int): Int =
    when(n) {
        in 0 .. 9->1 //Tiene un dígito
        else->{
            val resto= n / 10 //le quito el último dígito
            val c= contarDigitos(resto)
            c+1 //le sumo uno para tenerelos completos
        }
    }

/**
 * Permite saber el número de ceros que tiene un número.
 * Por ejemplo: 2020 tiene dos ceros.
 */
fun numeroDeCeros(n: Int): Int =
    if (n < 10) {
        if (n == 0) {
            1
        } else {
            0
        }
    } else {
        val ult=n%10
        val resto=n/10
        val c= numeroDeCeros(resto)
        if (ult == 0) {
            c + 1
        } else {
            c
        }
    }

/**
 * Permite hallar la suma de los dígitos de un número entero positivo n
 */
fun sumarDigitos(n: Int): Int =
    when(n){
        0->0
        in 0 .. 9->n
        else-> {
            val ult = n % 10
            val resto = n / 10
            val c = sumarDigitos(resto)
            c + ult
        }
    }

/**
 * Un número entero positivo en múltiplo de 3 si:
 *  - tiene una cifra y es 0, 3, 6, o 9
 *  - tiene más de una cifra y la suma de sus dígitos es múltiplo de 3 (recursion)
 *  - en cualquier otro caso, el número no es múltiplo de 3
 *
 *  - NO PUEDEN USAR LA OPERACIÓN MÓDULO (%) PARA SABER SI ES DIVISIBLE
 */
fun esMultiploDe3(n: Int): Boolean {
    if (n == 0 || n == 3 || n == 6 || n == 9) {
        return true
    } else if (n > 10) {
        val m = (sumarDigitos(n))
        if (esMultiploDe3(m)==true) {
            return true
        }
    }
    return false
}
/**
 * Cuenta el número de dígitos pares que tiene un número entero positivo >= 1
 */
fun cantidadDigitosPares(n: Int): Int =
    if (n < 10) {
        if (n == 0 || n==2 || n==4 || n == 6 || n==8 ) {
            1
        } else {
            0
        }
    } else {
        val ult=n%10
        val resto=n/10
        val c= cantidadDigitosPares(resto)
        if (ult == 0 || ult==2 || ult==4 || ult == 6 || ult==8) {
            c + 1
        } else {
            c
        }
    }

/**
 * Determina si el número dado es binario o no.
 * Los números binarios solo contienen los dígitos 1 y 0
 * Por ejemplo: el numero 100011110 es binario, pero 231 no lo es
 */
fun esNumeroBinario(n: Int): Boolean {
    if (n==0 ||n==1){
        return true
    }
    if (n%10 > 1) {
        return false
    }
    return esNumeroBinario(n/10)
}

/**
 * Permite saber si el número dado posee el dígito indicado
 */
fun poseeDigito(n: Int, digito: Int): Boolean {
    /*
    si el numero n posee un solo digito, entonces
       si n y el digito son iguales -> retorne true sino retorne false
    sino si el número n tiene más de un dígito, entonces
       si el ultimo dígito del número n es igual al dígito, entonces
         listo, lo encontramos, retorne true
       sino
         halle el resto de n
         mire si el resto de n posee el dígito indicado
     */
    if (n in 0 .. 9) {
        return n == digito
    }else {
        val ult = n % 10
        if (ult == digito) {
            return true
        } else {
            val sobra = n / 10
            return poseeDigito(sobra, digito)
        }
    }
}

/**
 * Retorna el dígito más grande que hace parte del número n
 * Ejemplo: el dígito más grande del númer 381704 es el 8
 * si el número tiene un solo dígito, el digito más grande es el numero
 * sino
 *    halle el resto y el último
 *    halla el digito mas grande del resto
 *    retorne el mayor entre el último y el dígito más grande del resto
 */
fun digitoMasGrande(n: Int): Int {
    if (contarDigitos(n) == 1) {
        return n
    } else {
        val ult=n%10
        val resto=n/10
        var digitoMasGrande=digitoMasGrande(resto)
        if (digitoMasGrande>ult) {
            return digitoMasGrande
        }
        return ult
    }
}

/**
 * Halla el máximo común divisor entre m y n, utilizando el método de
 * Euclides.
 */
fun mcd(m: Int, n: Int): Int =
    when(n) {
        0->m
        else-> mcd(n,m%n)
    }

/**
 * Imprimir cada elemento de la lista, pero de manera recursiva
 */
fun <T> imprimirLista(lista: List<T>) {
    if (lista.isEmpty()) { //si está vacía
        println()
    } else {
        val prim = lista.first()
        val resto=lista.subList(1,lista.size)//Desde la posición uno hasta la última
        println(prim) //Imprimir
        imprimirLista(resto)
    }
}

/**
 * Obtiene recursivamente la lista de los dígitos del número entero positivo n
 * Ejemplo: digitos(351804) == [3, 5, 1, 8, 0, 4]
 */
fun digitos(n: Int): List<Int> {
    if (n in 0 .. 9) {
        return listOf(n)
    }else{
        val ult=n%10
        val resto=n/10
        var lst= digitos(resto)
        lst += ult
        return lst
    }
}

/**
 * Dado un número entero positivo >= 0, retorna una lista con la representación binaria
 * del número dado.
 * Ejemplo: convertirDecimalBinario(231) = List(1, 1, 0, 0, 1, 1, 1, 1, 1, 1)
 */
fun convertirDecimalBinario(n: Int): List<Int> {
    if (n > 1) {
        val ult = n % 2
        val resto = n / 2
        var deci = convertirDecimalBinario(resto)
        deci += ult
        return deci
    }else if (n == 0) {
        return listOf(0)
    }
        return listOf(1)
}
/**
 * Determina cuantas palabras en la lista son verbos.
 * Recursivamente.
 */
fun contarVerbos(palabras: List<String>): Int {
    if (palabras.isEmpty()) { //si está vacía
        return 0
    } else {
        var prim= palabras.first() //se toma el primer elemento
        val resto= palabras.subList(1,palabras.size) //que "recora" la lista desde el 1 hasta el final
        var sonVerbos= contarVerbos(resto) //que obtenga los verbos del resto
        if (prim.endsWith("ar") || prim.endsWith("er") || prim.endsWith("ir")) {
            sonVerbos += 1 // si el prim es un verbo que lo sume al resto
        }
        return sonVerbos
    }
}
/**
 * Recursion con listas: Hallar la suma de los números pares de la lista que se recibe
 * como parámetro.
 * Ejemplo: sumarParesLista([40, 21, 8, 31, 6]) == 54
 */
fun sumarParesLista(lista: List<Int>): Int {
    if (lista.isEmpty()) { //si está vacía
        return 0
    } else {
        val prim= lista.first()
        val resto= lista.subList(1,lista.size)
        var sum= sumarParesLista(resto)
        if (prim%2==0){
            sum+=prim
        }
        return sum
    }
}

/**
 * Recursión con listas: construir una función recursiva que retorne la posición del elemento en la lista
 * Si la lista está vacía, retorne -1. No se puede usar indexOf o lastIndexOf
 */
fun buscarElementoEnUnaLista(lista: List<Int>, elem: Int): Int {
    if (lista.isEmpty()) { //si está vacía
        return -1
    } else {
        var prim= lista.first()
        val resto= lista.subList(1,lista.size)
        var busc= buscarElementoEnUnaLista(resto,elem)
        if (prim == elem) {
            return 0
        }else if (busc == -1) {
            return -1
        } else {
            return busc + 1
        }
    }
}

/**
 * Traduce los diversos dígitos de la lista a un número entero
 * Ejemplo: convertirListaDigitosNumero([3, 4, 1, 7, 9]) == 34179
 */
fun convertirListaDigitosNumero(digitos: List<Int>): Int {
    if (digitos.isEmpty()) {
        return 0
    } else {
        val ult = digitos.last()
        val resto = digitos.subList(0, digitos.size - 1) //para llegar antes del último
        return ult + 10 * convertirListaDigitosNumero(resto) // es para mover el valor en el que esta hasta el último
    }
}

/**
 * Función genérica y recursiva que permite saber si un elemento está dentro
 * de la lista. No debe usarse la función indexOf o contains. Debe ser
 * recursiva. Para buscar un elemento hay que tener en cuenta
 * - si la lista está vacía, el elemento no está
 * - si el primero de la lista es igual al elemento, retornamos true (el elemento está)
 * - sino es igual al primero, entonces hay que ver si el elemento está en el resto de la lista
 */
fun <T> existeElemento(lista: List<T>, elem: T): Boolean {
    if (lista.isEmpty()) { //si está vacía
        return false
    } else {
        var prim= lista.first()
        val resto= lista.subList(1,lista.size)
        var exis= existeElemento(resto,elem)
        if (prim == elem) {
            return true
        }else if (exis == true) {
            return true
        } else {
            return false
        }
    }
}

/** Escribir una función recursiva que, sin usar pilas ni colas
 * ni ninguna otra lista, obtenga la misma lista, pero invertida
 */
fun invertirLista(lista: List<Char>): List<Char> {
    if (lista.isEmpty()) {
        return lista
    } else {
        val ult = lista.last()
        val resto = lista.subList(0, lista.size - 1) //toma del primero hasta el anterior al último
        return listOf(ult) + invertirLista(resto)
    }
}

/**
 * Una palabra es palíndrome si se lee igual de izquierda a derecha y de derecha
 * a izquierda. Esta función recibe la palabra (sin espacios) y de forma recursiva
 * determina si la palabra es palíndrome.
 */
fun esPalindrome(palabra: String): Boolean =
    if (palabra.length <= 1) {
        true
    } else {
        val primera = palabra.first()
        val ultima = palabra.last()
        if (primera == ultima) {
            esPalindrome(palabra.substring(1, palabra.length - 1))// substring invierte las letras desde la pos 1 hasta la anterior a la última
        } else {
            false
        }
    }

/**
 * Recursividad con listas. Escriba una función recursiva
 * Obtiene el número más grande de la lista. Si la lista está vacía retorne el número
 * entero más pequeño.
 */
fun mayorDeUnaLista(lista: List<Int>): Int {
    if (lista.isEmpty()) {
        return Int.MIN_VALUE
    } else {
        val prim = lista.first()
        val resto = lista.subList(1, lista.size)
        val mayorResto = mayorDeUnaLista(resto)
        if (prim > mayorResto) {
            return prim
        } else {
            return mayorResto
        }
    }
}

/**
 * Una clase auxiliar
 */
data class Punto(val x: Int, val y: Int) {
    fun distanciaAlOrigen(): Double = sqrt(x.toDouble().pow(2) + y.toDouble().pow(2))
}

/**
 * Recursivamente, obtener una lista con aquellos puntos que están en el origen o
 * que hacen parte del primer cuadrante.
 */
fun puntosPrimerCuadrante(puntos: List<Punto>): List<Punto> {
    if (puntos.isEmpty()) {
        return listOf()
    } else {
        val prim=puntos.first()
        val resto = puntos.subList(1, puntos.size)
        var c= puntosPrimerCuadrante(resto)
        if (prim.x >= 0 && prim.y >= 0) {
            return listOf(prim) + c
        } else {
            return c
        }
    }
}

/**
 * Recursivamente, obtiene el punto que está más lejano del origen.
 * Si la lista esta vacía, retorne null
 * Si la lista tiene un solo elemento, retorne ese elemento
 * si la lista tiene más de un elemento, tome el primer elemento y
 * compárelo con el punto más lejano del resto de la lista.
 */
fun puntoMasLejano(puntos: List<Punto>): Punto? {
    if (puntos.isEmpty()) {
        return null
    } else if(puntos.size==1) {
        return puntos[0]
    }else{
        val prim=puntos.first()
        val resto = puntos.subList(1, puntos.size)
        var m= puntoMasLejano(resto)
        if (m==null) {
            return null
        } else {
            if (prim.distanciaAlOrigen() > m.distanciaAlOrigen()) {
                return prim
            } else {
                return m
            }
        }
    }

}

Compiled from "TallerRecursion.kt"
public final class ean.estructuradedatos.taller.TallerRecursionKt {
  public static final int factorial(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmpne     9
       5: iconst_1
       6: goto          17
       9: iload_0
      10: iconst_1
      11: isub
      12: invokestatic  #8                  // Method factorial:(I)I
      15: iload_0
      16: imul
      17: ireturn

  public static final int fibonacci(int);
    Code:
       0: iload_0
       1: tableswitch   { // 1 to 2
                     1: 24
                     2: 24
               default: 28
          }
      24: iconst_1
      25: goto          41
      28: iload_0
      29: iconst_1
      30: isub
      31: invokestatic  #13                 // Method fibonacci:(I)I
      34: iload_0
      35: iconst_2
      36: isub
      37: invokestatic  #13                 // Method fibonacci:(I)I
      40: iadd
      41: ireturn

  public static final int pascal(int, int);
    Code:
       0: iload_1
       1: iconst_1
       2: if_icmpeq     12
       5: iload_1
       6: iload_0
       7: iconst_1
       8: iadd
       9: if_icmpne     14
      12: iconst_1
      13: ireturn
      14: iload_0
      15: iconst_1
      16: isub
      17: iload_1
      18: invokestatic  #17                 // Method pascal:(II)I
      21: iload_0
      22: iconst_1
      23: isub
      24: iload_1
      25: iconst_1
      26: isub
      27: invokestatic  #17                 // Method pascal:(II)I
      30: iadd
      31: ireturn

  public static final int elevar(int, int);
    Code:
       0: iload_1
       1: ifne          8
       4: iconst_1
       5: goto          17
       8: iload_0
       9: iload_0
      10: iload_1
      11: iconst_1
      12: isub
      13: invokestatic  #21                 // Method elevar:(II)I
      16: imul
      17: ireturn

  public static final int sumatoria(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmpne     9
       5: iconst_1
       6: goto          17
       9: iload_0
      10: iconst_1
      11: isub
      12: invokestatic  #26                 // Method sumatoria:(I)I
      15: iload_0
      16: iadd
      17: ireturn

  public static final int sumaCuadrados(int);
    Code:
       0: iload_0
       1: ifne          8
       4: iconst_0
       5: goto          18
       8: iload_0
       9: iconst_1
      10: isub
      11: invokestatic  #29                 // Method sumaCuadrados:(I)I
      14: iload_0
      15: iload_0
      16: imul
      17: iadd
      18: ireturn

  public static final double serie(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmpne     11
       5: ldc2_w        #32                 // double 0.3333333333333333d
       8: goto          26
      11: iload_0
      12: iconst_1
      13: isub
      14: invokestatic  #35                 // Method serie:(I)D
      17: dconst_1
      18: iconst_2
      19: iload_0
      20: imul
      21: i2d
      22: dconst_1
      23: dadd
      24: ddiv
      25: dadd
      26: dreturn

  public static final double sumatoria2(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmpne     11
       5: ldc2_w        #37                 // double 0.5d
       8: goto          27
      11: iload_0
      12: iconst_1
      13: isub
      14: invokestatic  #40                 // Method sumatoria2:(I)D
      17: iload_0
      18: i2d
      19: iload_0
      20: iload_0
      21: imul
      22: i2d
      23: dconst_1
      24: dadd
      25: ddiv
      26: dadd
      27: dreturn

  public static final int contarDigitos(int);
    Code:
       0: iload_0
       1: istore_1
       2: iconst_0
       3: iload_1
       4: if_icmpgt     21
       7: iload_1
       8: bipush        10
      10: if_icmpge     17
      13: iconst_1
      14: goto          22
      17: iconst_0
      18: goto          22
      21: iconst_0
      22: ifeq          29
      25: iconst_1
      26: goto          42
      29: iload_0
      30: bipush        10
      32: idiv
      33: istore_2
      34: iload_2
      35: invokestatic  #43                 // Method contarDigitos:(I)I
      38: istore_3
      39: iload_3
      40: iconst_1
      41: iadd
      42: ireturn

  public static final int numeroDeCeros(int);
    Code:
       0: iload_0
       1: bipush        10
       3: if_icmpge     18
       6: iload_0
       7: ifne          14
      10: iconst_1
      11: goto          44
      14: iconst_0
      15: goto          44
      18: iload_0
      19: bipush        10
      21: irem
      22: istore_1
      23: iload_0
      24: bipush        10
      26: idiv
      27: istore_2
      28: iload_2
      29: invokestatic  #48                 // Method numeroDeCeros:(I)I
      32: istore_3
      33: iload_1
      34: ifne          43
      37: iload_3
      38: iconst_1
      39: iadd
      40: goto          44
      43: iload_3
      44: ireturn

  public static final int sumarDigitos(int);
    Code:
       0: iload_0
       1: istore_1
       2: iload_1
       3: ifne          10
       6: iconst_0
       7: goto          57
      10: iconst_0
      11: iload_1
      12: if_icmpgt     29
      15: iload_1
      16: bipush        10
      18: if_icmpge     25
      21: iconst_1
      22: goto          30
      25: iconst_0
      26: goto          30
      29: iconst_0
      30: ifeq          37
      33: iload_0
      34: goto          57
      37: iload_0
      38: bipush        10
      40: irem
      41: istore_2
      42: iload_0
      43: bipush        10
      45: idiv
      46: istore_3
      47: iload_3
      48: invokestatic  #52                 // Method sumarDigitos:(I)I
      51: istore        4
      53: iload         4
      55: iload_2
      56: iadd
      57: ireturn

  public static final boolean esMultiploDe3(int);
    Code:
       0: iload_0
       1: ifeq          21
       4: iload_0
       5: iconst_3
       6: if_icmpeq     21
       9: iload_0
      10: bipush        6
      12: if_icmpeq     21
      15: iload_0
      16: bipush        9
      18: if_icmpne     23
      21: iconst_1
      22: ireturn
      23: iload_0
      24: bipush        10
      26: if_icmple     44
      29: iload_0
      30: invokestatic  #52                 // Method sumarDigitos:(I)I
      33: istore_1
      34: iload_1
      35: invokestatic  #56                 // Method esMultiploDe3:(I)Z
      38: iconst_1
      39: if_icmpne     44
      42: iconst_1
      43: ireturn
      44: iconst_0
      45: ireturn

  public static final int cantidadDigitosPares(int);
    Code:
       0: iload_0
       1: bipush        10
       3: if_icmpge     64
       6: iload_0
       7: tableswitch   { // 0 to 8
                     0: 56
                     1: 60
                     2: 56
                     3: 60
                     4: 56
                     5: 60
                     6: 56
                     7: 60
                     8: 56
               default: 60
          }
      56: iconst_1
      57: goto          139
      60: iconst_0
      61: goto          139
      64: iload_0
      65: bipush        10
      67: irem
      68: istore_1
      69: iload_0
      70: bipush        10
      72: idiv
      73: istore_2
      74: iload_2
      75: invokestatic  #59                 // Method cantidadDigitosPares:(I)I
      78: istore_3
      79: iload_1
      80: tableswitch   { // 0 to 8
                     0: 132
                     1: 138
                     2: 132
                     3: 138
                     4: 132
                     5: 138
                     6: 132
                     7: 138
                     8: 132
               default: 138
          }
     132: iload_3
     133: iconst_1
     134: iadd
     135: goto          139
     138: iload_3
     139: ireturn

  public static final boolean esNumeroBinario(int);
    Code:
       0: iload_0
       1: tableswitch   { // 0 to 1
                     0: 24
                     1: 24
               default: 26
          }
      24: iconst_1
      25: ireturn
      26: iload_0
      27: bipush        10
      29: irem
      30: iconst_1
      31: if_icmple     36
      34: iconst_0
      35: ireturn
      36: iload_0
      37: bipush        10
      39: idiv
      40: invokestatic  #62                 // Method esNumeroBinario:(I)Z
      43: ireturn

  public static final boolean poseeDigito(int, int);
    Code:
       0: iconst_0
       1: iload_0
       2: if_icmpgt     19
       5: iload_0
       6: bipush        10
       8: if_icmpge     15
      11: iconst_1
      12: goto          20
      15: iconst_0
      16: goto          20
      19: iconst_0
      20: ifeq          34
      23: iload_0
      24: iload_1
      25: if_icmpne     32
      28: iconst_1
      29: goto          33
      32: iconst_0
      33: ireturn
      34: iload_0
      35: bipush        10
      37: irem
      38: istore_2
      39: iload_2
      40: iload_1
      41: if_icmpne     46
      44: iconst_1
      45: ireturn
      46: iload_0
      47: bipush        10
      49: idiv
      50: istore_3
      51: iload_3
      52: iload_1
      53: invokestatic  #66                 // Method poseeDigito:(II)Z
      56: ireturn

  public static final int digitoMasGrande(int);
    Code:
       0: iload_0
       1: invokestatic  #43                 // Method contarDigitos:(I)I
       4: iconst_1
       5: if_icmpne     10
       8: iload_0
       9: ireturn
      10: iload_0
      11: bipush        10
      13: irem
      14: istore_1
      15: iload_0
      16: bipush        10
      18: idiv
      19: istore_2
      20: iload_2
      21: invokestatic  #71                 // Method digitoMasGrande:(I)I
      24: istore_3
      25: iload_3
      26: iload_1
      27: if_icmple     32
      30: iload_3
      31: ireturn
      32: iload_1
      33: ireturn

  public static final int mcd(int, int);
    Code:
       0: iload_1
       1: ifne          8
       4: iload_0
       5: goto          15
       8: iload_1
       9: iload_0
      10: iload_1
      11: irem
      12: invokestatic  #74                 // Method mcd:(II)I
      15: ireturn

  public static final <T> void imprimirLista(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          24
      15: getstatic     #98                 // Field java/lang/System.out:Ljava/io/PrintStream;
      18: invokevirtual #104                // Method java/io/PrintStream.println:()V
      21: goto          54
      24: aload_0
      25: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      28: astore_1
      29: aload_0
      30: iconst_1
      31: aload_0
      32: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      37: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      42: astore_2
      43: getstatic     #98                 // Field java/lang/System.out:Ljava/io/PrintStream;
      46: aload_1
      47: invokevirtual #121                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      50: aload_2
      51: invokestatic  #123                // Method imprimirLista:(Ljava/util/List;)V
      54: return

  public static final java.util.List<java.lang.Integer> digitos(int);
    Code:
       0: iconst_0
       1: iload_0
       2: if_icmpgt     19
       5: iload_0
       6: bipush        10
       8: if_icmpge     15
      11: iconst_1
      12: goto          20
      15: iconst_0
      16: goto          20
      19: iconst_0
      20: ifeq          31
      23: iload_0
      24: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      30: areturn
      31: iload_0
      32: bipush        10
      34: irem
      35: istore_1
      36: iload_0
      37: bipush        10
      39: idiv
      40: istore_2
      41: iload_2
      42: invokestatic  #141                // Method digitos:(I)Ljava/util/List;
      45: astore_3
      46: aload_3
      47: checkcast     #143                // class java/util/Collection
      50: iload_1
      51: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      54: invokestatic  #147                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      57: astore_3
      58: aload_3
      59: areturn

  public static final java.util.List<java.lang.Integer> convertirDecimalBinario(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmple     32
       5: iload_0
       6: iconst_2
       7: irem
       8: istore_1
       9: iload_0
      10: iconst_2
      11: idiv
      12: istore_2
      13: iload_2
      14: invokestatic  #151                // Method convertirDecimalBinario:(I)Ljava/util/List;
      17: astore_3
      18: aload_3
      19: checkcast     #143                // class java/util/Collection
      22: iload_1
      23: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: invokestatic  #147                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      29: astore_3
      30: aload_3
      31: areturn
      32: iload_0
      33: ifne          44
      36: iconst_0
      37: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      40: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      43: areturn
      44: iconst_1
      45: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      51: areturn

  public static final int contarVerbos(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #157                // String palabras
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: iconst_0
      16: ireturn
      17: aload_0
      18: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      21: checkcast     #159                // class java/lang/String
      24: astore_1
      25: aload_0
      26: iconst_1
      27: aload_0
      28: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      33: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      38: astore_2
      39: aload_2
      40: invokestatic  #161                // Method contarVerbos:(Ljava/util/List;)I
      43: istore_3
      44: aload_1
      45: ldc           #163                // String ar
      47: iconst_0
      48: iconst_2
      49: aconst_null
      50: invokestatic  #169                // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      53: ifne          80
      56: aload_1
      57: ldc           #171                // String er
      59: iconst_0
      60: iconst_2
      61: aconst_null
      62: invokestatic  #169                // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      65: ifne          80
      68: aload_1
      69: ldc           #173                // String ir
      71: iconst_0
      72: iconst_2
      73: aconst_null
      74: invokestatic  #169                // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      77: ifeq          83
      80: iinc          3, 1
      83: iload_3
      84: ireturn

  public static final int sumarParesLista(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: iconst_0
      16: ireturn
      17: aload_0
      18: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      21: checkcast     #179                // class java/lang/Number
      24: invokevirtual #182                // Method java/lang/Number.intValue:()I
      27: istore_1
      28: aload_0
      29: iconst_1
      30: aload_0
      31: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      36: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      41: astore_2
      42: aload_2
      43: invokestatic  #184                // Method sumarParesLista:(Ljava/util/List;)I
      46: istore_3
      47: iload_1
      48: iconst_2
      49: irem
      50: ifne          57
      53: iload_3
      54: iload_1
      55: iadd
      56: istore_3
      57: iload_3
      58: ireturn

  public static final int buscarElementoEnUnaLista(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: iconst_m1
      16: ireturn
      17: aload_0
      18: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      21: checkcast     #179                // class java/lang/Number
      24: invokevirtual #182                // Method java/lang/Number.intValue:()I
      27: istore_2
      28: aload_0
      29: iconst_1
      30: aload_0
      31: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      36: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      41: astore_3
      42: aload_3
      43: iload_1
      44: invokestatic  #190                // Method buscarElementoEnUnaLista:(Ljava/util/List;I)I
      47: istore        4
      49: iload_2
      50: iload_1
      51: if_icmpne     56
      54: iconst_0
      55: ireturn
      56: iload         4
      58: iconst_m1
      59: if_icmpne     64
      62: iconst_m1
      63: ireturn
      64: iload         4
      66: iconst_1
      67: iadd
      68: ireturn

  public static final int convertirListaDigitosNumero(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #194                // String digitos
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: iconst_0
      16: ireturn
      17: aload_0
      18: invokestatic  #197                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      21: checkcast     #179                // class java/lang/Number
      24: invokevirtual #182                // Method java/lang/Number.intValue:()I
      27: istore_1
      28: aload_0
      29: iconst_0
      30: aload_0
      31: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      36: iconst_1
      37: isub
      38: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      43: astore_2
      44: iload_1
      45: bipush        10
      47: aload_2
      48: invokestatic  #199                // Method convertirListaDigitosNumero:(Ljava/util/List;)I
      51: imul
      52: iadd
      53: ireturn

  public static final <T> boolean existeElemento(java.util.List<? extends T>, T);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: iconst_0
      16: ireturn
      17: aload_0
      18: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      21: astore_2
      22: aload_0
      23: iconst_1
      24: aload_0
      25: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      30: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      35: astore_3
      36: aload_3
      37: aload_1
      38: invokestatic  #204                // Method existeElemento:(Ljava/util/List;Ljava/lang/Object;)Z
      41: istore        4
      43: aload_2
      44: aload_1
      45: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifeq          53
      51: iconst_1
      52: ireturn
      53: iload         4
      55: iconst_1
      56: if_icmpne     61
      59: iconst_1
      60: ireturn
      61: iconst_0
      62: ireturn

  public static final java.util.List<java.lang.Character> invertirLista(java.util.List<java.lang.Character>);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          17
      15: aload_0
      16: areturn
      17: aload_0
      18: invokestatic  #197                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      21: checkcast     #215                // class java/lang/Character
      24: invokevirtual #219                // Method java/lang/Character.charValue:()C
      27: istore_1
      28: aload_0
      29: iconst_0
      30: aload_0
      31: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      36: iconst_1
      37: isub
      38: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      43: astore_2
      44: iload_1
      45: invokestatic  #222                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      48: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      51: checkcast     #143                // class java/util/Collection
      54: aload_2
      55: invokestatic  #224                // Method invertirLista:(Ljava/util/List;)Ljava/util/List;
      58: checkcast     #226                // class java/lang/Iterable
      61: invokestatic  #229                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      64: areturn

  public static final boolean esPalindrome(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #234                // String palabra
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #237                // Method java/lang/String.length:()I
      10: iconst_1
      11: if_icmpgt     18
      14: iconst_1
      15: goto          63
      18: aload_0
      19: checkcast     #239                // class java/lang/CharSequence
      22: invokestatic  #242                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
      25: istore_1
      26: aload_0
      27: checkcast     #239                // class java/lang/CharSequence
      30: invokestatic  #244                // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C
      33: istore_2
      34: iload_1
      35: iload_2
      36: if_icmpne     62
      39: aload_0
      40: iconst_1
      41: aload_0
      42: invokevirtual #237                // Method java/lang/String.length:()I
      45: iconst_1
      46: isub
      47: invokevirtual #248                // Method java/lang/String.substring:(II)Ljava/lang/String;
      50: dup
      51: ldc           #250                // String substring(...)
      53: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      56: invokestatic  #255                // Method esPalindrome:(Ljava/lang/String;)Z
      59: goto          63
      62: iconst_0
      63: ireturn

  public static final int mayorDeUnaLista(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #80                 // String lista
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: ifeq          19
      15: ldc_w         #259                // int -2147483648
      18: ireturn
      19: aload_0
      20: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      23: checkcast     #179                // class java/lang/Number
      26: invokevirtual #182                // Method java/lang/Number.intValue:()I
      29: istore_1
      30: aload_0
      31: iconst_1
      32: aload_0
      33: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      38: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      43: astore_2
      44: aload_2
      45: invokestatic  #261                // Method mayorDeUnaLista:(Ljava/util/List;)I
      48: istore_3
      49: iload_1
      50: iload_3
      51: if_icmple     56
      54: iload_1
      55: ireturn
      56: iload_3
      57: ireturn

  public static final java.util.List<ean.estructuradedatos.taller.Punto> puntosPrimerCuadrante(java.util.List<ean.estructuradedatos.taller.Punto>);
    Code:
       0: aload_0
       1: ldc_w         #266                // String puntos
       4: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifeq          20
      16: invokestatic  #270                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      19: areturn
      20: aload_0
      21: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      24: checkcast     #272                // class ean/estructuradedatos/taller/Punto
      27: astore_1
      28: aload_0
      29: iconst_1
      30: aload_0
      31: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      36: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      41: astore_2
      42: aload_2
      43: invokestatic  #274                // Method puntosPrimerCuadrante:(Ljava/util/List;)Ljava/util/List;
      46: astore_3
      47: aload_1
      48: invokevirtual #277                // Method ean/estructuradedatos/taller/Punto.getX:()I
      51: iflt          76
      54: aload_1
      55: invokevirtual #280                // Method ean/estructuradedatos/taller/Punto.getY:()I
      58: iflt          76
      61: aload_1
      62: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      65: checkcast     #143                // class java/util/Collection
      68: aload_3
      69: checkcast     #226                // class java/lang/Iterable
      72: invokestatic  #229                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      75: areturn
      76: aload_3
      77: areturn

  public static final ean.estructuradedatos.taller.Punto puntoMasLejano(java.util.List<ean.estructuradedatos.taller.Punto>);
    Code:
       0: aload_0
       1: ldc_w         #266                // String puntos
       4: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #92,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifeq          18
      16: aconst_null
      17: areturn
      18: aload_0
      19: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      24: iconst_1
      25: if_icmpne     39
      28: aload_0
      29: iconst_0
      30: invokeinterface #289,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      35: checkcast     #272                // class ean/estructuradedatos/taller/Punto
      38: areturn
      39: aload_0
      40: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      43: checkcast     #272                // class ean/estructuradedatos/taller/Punto
      46: astore_1
      47: aload_0
      48: iconst_1
      49: aload_0
      50: invokeinterface #114,  1          // InterfaceMethod java/util/List.size:()I
      55: invokeinterface #118,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      60: astore_2
      61: aload_2
      62: invokestatic  #291                // Method puntoMasLejano:(Ljava/util/List;)Lean/estructuradedatos/taller/Punto;
      65: astore_3
      66: aload_3
      67: ifnonnull     72
      70: aconst_null
      71: areturn
      72: aload_1
      73: invokevirtual #295                // Method ean/estructuradedatos/taller/Punto.distanciaAlOrigen:()D
      76: aload_3
      77: invokevirtual #295                // Method ean/estructuradedatos/taller/Punto.distanciaAlOrigen:()D
      80: dcmpl
      81: ifle          86
      84: aload_1
      85: areturn
      86: aload_3
      87: areturn
}


package leetcode

import kotlin.math.abs

/**
 * https://leetcode.com/problems/detect-squares/
 */
class Problem2013 {
    class DetectSquares() {
        private val map = mutableMapOf<Int, MutableMap<Int, Int>>()

        fun add(point: IntArray) {
            val x = point[0]
            val y = point[1]
            val m = map[x] ?: mutableMapOf()
            m[y] = (m[y] ?: 0) + 1
            map[x] = m
        }

        fun count(point: IntArray): Int {
            var count = 0
            val x1 = point[0]
            val y1 = point[1]
            for ((y2, _) in map[x1] ?: mapOf<Int, Int>()) {
                val length = abs(y1 - y2)
                if (length == 0) {
                    continue
                }
                count += numSquares(x1 = x1, y1 = y1, x2 = x1 - length, y2 = y2)
                count += numSquares(x1 = x1, y1 = y1, x2 = x1 + length, y2 = y2)
            }
            return count
        }

        private fun numSquares(x1: Int, y1: Int, x2: Int, y2: Int): Int {
            val p1 = if (map[x1] != null) map[x1]!![y2] ?: 0 else 0
            val p2 = if (map[x2] != null) map[x2]!![y1] ?: 0 else 0
            val p3 = if (map[x2] != null) map[x2]!![y2] ?: 0 else 0
            return p1 * p2 * p3
        }
    }
}

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

Compiled from "Problem2013.kt"
public final class leetcode.Problem2013$DetectSquares {
  private final java.util.Map<java.lang.Integer, java.util.Map<java.lang.Integer, java.lang.Integer>> map;

  public leetcode.Problem2013$DetectSquares();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: new           #10                 // class java/util/LinkedHashMap
       8: dup
       9: invokespecial #11                 // Method java/util/LinkedHashMap."<init>":()V
      12: checkcast     #13                 // class java/util/Map
      15: putfield      #17                 // Field map:Ljava/util/Map;
      18: return

  public final void add(int[]);
    Code:
       0: aload_1
       1: ldc           #24                 // String point
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_0
       8: iaload
       9: istore_2
      10: aload_1
      11: iconst_1
      12: iaload
      13: istore_3
      14: aload_0
      15: getfield      #17                 // Field map:Ljava/util/Map;
      18: iload_2
      19: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      22: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      27: checkcast     #13                 // class java/util/Map
      30: dup
      31: ifnonnull     45
      34: pop
      35: new           #10                 // class java/util/LinkedHashMap
      38: dup
      39: invokespecial #11                 // Method java/util/LinkedHashMap."<init>":()V
      42: checkcast     #13                 // class java/util/Map
      45: astore        4
      47: aload         4
      49: astore        5
      51: iload_3
      52: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      55: astore        6
      57: aload         4
      59: iload_3
      60: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      68: checkcast     #32                 // class java/lang/Integer
      71: dup
      72: ifnull        81
      75: invokevirtual #44                 // Method java/lang/Integer.intValue:()I
      78: goto          83
      81: pop
      82: iconst_0
      83: iconst_1
      84: iadd
      85: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      88: astore        7
      90: aload         5
      92: aload         6
      94: aload         7
      96: invokeinterface #48,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     101: pop
     102: iload_2
     103: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     106: astore        6
     108: aload_0
     109: getfield      #17                 // Field map:Ljava/util/Map;
     112: aload         6
     114: aload         4
     116: invokeinterface #48,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     121: pop
     122: return

  public final int count(int[]);
    Code:
       0: aload_1
       1: ldc           #24                 // String point
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_1
       9: iconst_0
      10: iaload
      11: istore_3
      12: aload_1
      13: iconst_1
      14: iaload
      15: istore        4
      17: aload_0
      18: getfield      #17                 // Field map:Ljava/util/Map;
      21: iload_3
      22: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      30: checkcast     #13                 // class java/util/Map
      33: dup
      34: ifnonnull     41
      37: pop
      38: invokestatic  #62                 // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;
      41: invokeinterface #66,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      46: invokeinterface #72,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      51: astore        5
      53: aload         5
      55: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          139
      63: aload         5
      65: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: checkcast     #84                 // class java/util/Map$Entry
      73: invokeinterface #87,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      78: checkcast     #89                 // class java/lang/Number
      81: invokevirtual #90                 // Method java/lang/Number.intValue:()I
      84: istore        6
      86: iload         4
      88: iload         6
      90: isub
      91: invokestatic  #96                 // Method java/lang/Math.abs:(I)I
      94: istore        7
      96: iload         7
      98: ifne          104
     101: goto          53
     104: iload_2
     105: aload_0
     106: iload_3
     107: iload         4
     109: iload_3
     110: iload         7
     112: isub
     113: iload         6
     115: invokespecial #100                // Method numSquares:(IIII)I
     118: iadd
     119: istore_2
     120: iload_2
     121: aload_0
     122: iload_3
     123: iload         4
     125: iload_3
     126: iload         7
     128: iadd
     129: iload         6
     131: invokespecial #100                // Method numSquares:(IIII)I
     134: iadd
     135: istore_2
     136: goto          53
     139: iload_2
     140: ireturn

  private final int numSquares(int, int, int, int);
    Code:
       0: aload_0
       1: getfield      #17                 // Field map:Ljava/util/Map;
       4: iload_1
       5: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      13: ifnull        64
      16: aload_0
      17: getfield      #17                 // Field map:Ljava/util/Map;
      20: iload_1
      21: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      24: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      29: dup
      30: invokestatic  #108                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      33: checkcast     #13                 // class java/util/Map
      36: iload         4
      38: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      46: checkcast     #32                 // class java/lang/Integer
      49: dup
      50: ifnull        59
      53: invokevirtual #44                 // Method java/lang/Integer.intValue:()I
      56: goto          65
      59: pop
      60: iconst_0
      61: goto          65
      64: iconst_0
      65: istore        5
      67: aload_0
      68: getfield      #17                 // Field map:Ljava/util/Map;
      71: iload_3
      72: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      75: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      80: ifnull        130
      83: aload_0
      84: getfield      #17                 // Field map:Ljava/util/Map;
      87: iload_3
      88: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      91: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      96: dup
      97: invokestatic  #108                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     100: checkcast     #13                 // class java/util/Map
     103: iload_2
     104: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     107: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     112: checkcast     #32                 // class java/lang/Integer
     115: dup
     116: ifnull        125
     119: invokevirtual #44                 // Method java/lang/Integer.intValue:()I
     122: goto          131
     125: pop
     126: iconst_0
     127: goto          131
     130: iconst_0
     131: istore        6
     133: aload_0
     134: getfield      #17                 // Field map:Ljava/util/Map;
     137: iload_3
     138: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     146: ifnull        197
     149: aload_0
     150: getfield      #17                 // Field map:Ljava/util/Map;
     153: iload_3
     154: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     157: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     162: dup
     163: invokestatic  #108                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     166: checkcast     #13                 // class java/util/Map
     169: iload         4
     171: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     174: invokeinterface #40,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     179: checkcast     #32                 // class java/lang/Integer
     182: dup
     183: ifnull        192
     186: invokevirtual #44                 // Method java/lang/Integer.intValue:()I
     189: goto          198
     192: pop
     193: iconst_0
     194: goto          198
     197: iconst_0
     198: istore        7
     200: iload         5
     202: iload         6
     204: imul
     205: iload         7
     207: imul
     208: ireturn
}


package leetcode

/**
 * https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/
 */
class Problem1718 {
    fun constructDistancedSequence(n: Int): IntArray {
        return constructDistancedSequence(n, 0, HashSet(), IntArray(n * 2 - 1)).array
    }

    private class Answer(val found: Boolean, val array: IntArray)

    private fun constructDistancedSequence(n: Int, index: Int,
                                           visited: MutableSet<Int>, array: IntArray): Answer {
        if (visited.size == n) {
            return Answer(true, array)
        }
        if (array[index] != 0) {
            return constructDistancedSequence(n, index + 1, visited, array)
        }
        for (i in n downTo 1) {
            if (i in visited) {
                continue
            }
            if (i == 1) {
                array[index] = i
            } else {
                if (index + i >= array.size || array[index + i] != 0) {
                    continue
                }
                array[index] = i
                array[index + i] = i
            }
            visited += i
            val answer = constructDistancedSequence(n, index + 1, visited, array)
            if (answer.found) {
                return answer
            }
            visited -= i
            array[index] = 0
            if (i != 1) {
                array[index + i] = 0
            }
        }
        return Answer(false, array)
    }
}

Compiled from "Problem1718.kt"
final class leetcode.Problem1718$Answer {
  private final boolean found;

  private final int[] array;

  public leetcode.Problem1718$Answer(boolean, int[]);
    Code:
       0: aload_2
       1: ldc           #9                  // String array
       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 found:Z
      15: aload_0
      16: aload_2
      17: putfield      #25                 // Field array:[I
      20: return

  public final boolean getFound();
    Code:
       0: aload_0
       1: getfield      #22                 // Field found:Z
       4: ireturn

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

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

  public final int[] constructDistancedSequence(int);
    Code:
       0: aload_0
       1: iload_1
       2: iconst_0
       3: new           #15                 // class java/util/HashSet
       6: dup
       7: invokespecial #16                 // Method java/util/HashSet."<init>":()V
      10: checkcast     #18                 // class java/util/Set
      13: iload_1
      14: iconst_2
      15: imul
      16: iconst_1
      17: isub
      18: newarray       int
      20: invokespecial #21                 // Method constructDistancedSequence:(IILjava/util/Set;[I)Lleetcode/Problem1718$Answer;
      23: invokevirtual #27                 // Method leetcode/Problem1718$Answer.getArray:()[I
      26: areturn

  private final leetcode.Problem1718$Answer constructDistancedSequence(int, int, java.util.Set<java.lang.Integer>, int[]);
    Code:
       0: aload_3
       1: invokeinterface #34,  1           // InterfaceMethod java/util/Set.size:()I
       6: iload_1
       7: if_icmpne     21
      10: new           #23                 // class leetcode/Problem1718$Answer
      13: dup
      14: iconst_1
      15: aload         4
      17: invokespecial #37                 // Method leetcode/Problem1718$Answer."<init>":(Z[I)V
      20: areturn
      21: aload         4
      23: iload_2
      24: iaload
      25: ifeq          40
      28: aload_0
      29: iload_1
      30: iload_2
      31: iconst_1
      32: iadd
      33: aload_3
      34: aload         4
      36: invokespecial #21                 // Method constructDistancedSequence:(IILjava/util/Set;[I)Lleetcode/Problem1718$Answer;
      39: areturn
      40: iload_1
      41: istore        5
      43: iconst_0
      44: iload         5
      46: if_icmpge     206
      49: aload_3
      50: iload         5
      52: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      55: invokeinterface #47,  2           // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      60: ifeq          66
      63: goto          200
      66: iload         5
      68: iconst_1
      69: if_icmpne     81
      72: aload         4
      74: iload_2
      75: iload         5
      77: iastore
      78: goto          119
      81: iload_2
      82: iload         5
      84: iadd
      85: aload         4
      87: arraylength
      88: if_icmpge     101
      91: aload         4
      93: iload_2
      94: iload         5
      96: iadd
      97: iaload
      98: ifeq          104
     101: goto          200
     104: aload         4
     106: iload_2
     107: iload         5
     109: iastore
     110: aload         4
     112: iload_2
     113: iload         5
     115: iadd
     116: iload         5
     118: iastore
     119: iload         5
     121: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     124: astore        7
     126: aload_3
     127: checkcast     #49                 // class java/util/Collection
     130: aload         7
     132: invokeinterface #52,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     137: pop
     138: aload_0
     139: iload_1
     140: iload_2
     141: iconst_1
     142: iadd
     143: aload_3
     144: aload         4
     146: invokespecial #21                 // Method constructDistancedSequence:(IILjava/util/Set;[I)Lleetcode/Problem1718$Answer;
     149: astore        6
     151: aload         6
     153: invokevirtual #56                 // Method leetcode/Problem1718$Answer.getFound:()Z
     156: ifeq          162
     159: aload         6
     161: areturn
     162: iload         5
     164: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     167: astore        8
     169: aload_3
     170: checkcast     #49                 // class java/util/Collection
     173: aload         8
     175: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.remove:(Ljava/lang/Object;)Z
     180: pop
     181: aload         4
     183: iload_2
     184: iconst_0
     185: iastore
     186: iload         5
     188: iconst_1
     189: if_icmpeq     200
     192: aload         4
     194: iload_2
     195: iload         5
     197: iadd
     198: iconst_0
     199: iastore
     200: iinc          5, -1
     203: goto          43
     206: new           #23                 // class leetcode/Problem1718$Answer
     209: dup
     210: iconst_0
     211: aload         4
     213: invokespecial #37                 // Method leetcode/Problem1718$Answer."<init>":(Z[I)V
     216: areturn
}


package leetcode

import java.util.*

/**
 * https://leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/
 */
class Problem2192 {
    fun getAncestors(n: Int, edges: Array<IntArray>): List<List<Int>> {
        val adjList = reverse(n, edges)
        val answer = mutableListOf<List<Int>>()
        for (i in 0 until n) {
            val ancestors = mutableListOf<Int>()
            val visited = BooleanArray(n)
            getAncestors(i, adjList, ancestors, visited)
            ancestors.sort()
            answer += ancestors
        }
        return answer
    }

    private fun reverse(n: Int, edges: Array<IntArray>): Array<MutableList<Int>> {
        val adjList = Array<MutableList<Int>>(n) { mutableListOf() }
        for (edge in edges) {
            val from = edge[0]
            val to = edge[1]
            adjList[to].add(from)
        }
        return adjList
    }

    private fun getAncestors(i: Int, adjList: Array<MutableList<Int>>,
                             ancestors: MutableList<Int>, visited: BooleanArray) {
        visited[i] = true
        for (adjacent in adjList[i]) {
            if (!visited[adjacent]) {
                ancestors += adjacent
                getAncestors(adjacent, adjList, ancestors, visited)
            }
        }
    }
}

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

  public final java.util.List<java.util.List<java.lang.Integer>> getAncestors(int, int[][]);
    Code:
       0: aload_2
       1: ldc           #16                 // String edges
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: aload_2
       9: invokespecial #26                 // Method reverse:(I[[I)[Ljava/util/List;
      12: astore_3
      13: new           #28                 // class java/util/ArrayList
      16: dup
      17: invokespecial #29                 // Method java/util/ArrayList."<init>":()V
      20: checkcast     #31                 // class java/util/List
      23: astore        4
      25: iconst_0
      26: istore        5
      28: iload         5
      30: iload_1
      31: if_icmpge     86
      34: new           #28                 // class java/util/ArrayList
      37: dup
      38: invokespecial #29                 // Method java/util/ArrayList."<init>":()V
      41: checkcast     #31                 // class java/util/List
      44: astore        6
      46: iload_1
      47: newarray       boolean
      49: astore        7
      51: aload_0
      52: iload         5
      54: aload_3
      55: aload         6
      57: aload         7
      59: invokespecial #34                 // Method getAncestors:(I[Ljava/util/List;Ljava/util/List;[Z)V
      62: aload         6
      64: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.sort:(Ljava/util/List;)V
      67: aload         4
      69: checkcast     #42                 // class java/util/Collection
      72: aload         6
      74: invokeinterface #46,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      79: pop
      80: iinc          5, 1
      83: goto          28
      86: aload         4
      88: areturn

  private final java.util.List<java.lang.Integer>[] reverse(int, int[][]);
    Code:
       0: iconst_0
       1: istore        4
       3: iload_1
       4: anewarray     #31                 // class java/util/List
       7: astore        5
       9: iload         4
      11: iload_1
      12: if_icmpge     40
      15: iload         4
      17: istore        6
      19: aload         5
      21: iload         6
      23: new           #28                 // class java/util/ArrayList
      26: dup
      27: invokespecial #29                 // Method java/util/ArrayList."<init>":()V
      30: checkcast     #31                 // class java/util/List
      33: aastore
      34: iinc          4, 1
      37: goto          9
      40: aload         5
      42: astore_3
      43: iconst_0
      44: istore        4
      46: aload_2
      47: checkcast     #61                 // class "[Ljava/lang/Object;"
      50: arraylength
      51: istore        5
      53: iload         4
      55: iload         5
      57: if_icmpge     99
      60: aload_2
      61: iload         4
      63: aaload
      64: astore        6
      66: aload         6
      68: iconst_0
      69: iaload
      70: istore        7
      72: aload         6
      74: iconst_1
      75: iaload
      76: istore        8
      78: aload_3
      79: iload         8
      81: aaload
      82: iload         7
      84: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      87: invokeinterface #68,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      92: pop
      93: iinc          4, 1
      96: goto          53
      99: aload_3
     100: areturn

  private final void getAncestors(int, java.util.List<java.lang.Integer>[], java.util.List<java.lang.Integer>, boolean[]);
    Code:
       0: aload         4
       2: iload_1
       3: iconst_1
       4: bastore
       5: aload_2
       6: iload_1
       7: aaload
       8: invokeinterface #78,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      13: astore        5
      15: aload         5
      17: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifeq          80
      25: aload         5
      27: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: checkcast     #90                 // class java/lang/Number
      35: invokevirtual #94                 // Method java/lang/Number.intValue:()I
      38: istore        6
      40: aload         4
      42: iload         6
      44: baload
      45: ifne          15
      48: iload         6
      50: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: astore        7
      55: aload_3
      56: checkcast     #42                 // class java/util/Collection
      59: aload         7
      61: invokeinterface #46,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      66: pop
      67: aload_0
      68: iload         6
      70: aload_2
      71: aload_3
      72: aload         4
      74: invokespecial #34                 // Method getAncestors:(I[Ljava/util/List;Ljava/util/List;[Z)V
      77: goto          15
      80: return
}


package leetcode

import java.util.PriorityQueue

/**
 * https://leetcode.com/problems/path-with-maximum-probability/
 */
class Problem1514 {
    fun maxProbability(n: Int, edges: Array<IntArray>, succProb: DoubleArray, start: Int,
                       end: Int): Double {
        val adjList = buildAdjList(n, edges, succProb)
        val dist = DoubleArray(n) { Double.NEGATIVE_INFINITY }
        val queue = PriorityQueue<Node>()
        queue += Node(start, dist[start])
        while (queue.isNotEmpty()) {
            val node = queue.remove()
            for (edge in adjList[node.n]) {
                val prob = if (dist[edge.from] == Double.NEGATIVE_INFINITY) edge.prob
                    else dist[edge.from] * edge.prob
                if (prob > dist[edge.to]) {
                    dist[edge.to] = prob
                    queue += Node(edge.to, prob)
                }
            }
        }
        return if (dist[end] == Double.NEGATIVE_INFINITY) 0.0 else dist[end]
    }

    private fun buildAdjList(n: Int, edges: Array<IntArray>, succProb: DoubleArray): Array<MutableList<Edge>> {
        val adjList = Array(n) { mutableListOf<Edge>() }
        for ((i, e) in edges.withIndex()) {
            val (from, to) = e
            adjList[from].add(Edge(from, to, succProb[i]))
            adjList[to].add(Edge(to, from, succProb[i]))
        }
        return adjList
    }

    private data class Node(val n: Int, val prob: Double) : Comparable<Node> {
        override fun compareTo(other: Node): Int {
            return other.prob.compareTo(prob)
        }
    }

    private data class Edge(val from: Int, val to: Int, val prob: Double)
}

Compiled from "Problem1514.kt"
final class leetcode.Problem1514$Node implements java.lang.Comparable<leetcode.Problem1514$Node> {
  private final int n;

  private final double prob;

  public leetcode.Problem1514$Node(int, double);
    Code:
       0: aload_0
       1: invokespecial #12                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #16                 // Field n:I
       9: aload_0
      10: dload_2
      11: putfield      #20                 // Field prob:D
      14: return

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

  public final double getProb();
    Code:
       0: aload_0
       1: getfield      #20                 // Field prob:D
       4: dreturn

  public int compareTo(leetcode.Problem1514$Node);
    Code:
       0: aload_1
       1: ldc           #31                 // String other
       3: invokestatic  #37                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: getfield      #20                 // Field prob:D
      10: aload_0
      11: getfield      #20                 // Field prob:D
      14: invokestatic  #43                 // Method java/lang/Double.compare:(DD)I
      17: ireturn

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

  public final double component2();
    Code:
       0: aload_0
       1: getfield      #20                 // Field prob:D
       4: dreturn

  public final leetcode.Problem1514$Node copy(int, double);
    Code:
       0: new           #2                  // class leetcode/Problem1514$Node
       3: dup
       4: iload_1
       5: dload_2
       6: invokespecial #49                 // Method "<init>":(ID)V
       9: areturn

  public static leetcode.Problem1514$Node copy$default(leetcode.Problem1514$Node, int, double, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #16                 // Field n:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #20                 // Field prob:D
      23: dstore_2
      24: aload_0
      25: iload_1
      26: dload_2
      27: invokevirtual #53                 // Method copy:(ID)Lleetcode/Problem1514$Node;
      30: areturn

  public java.lang.String toString();
    Code:
       0: new           #57                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #58                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #60                 // String Node(n=
       9: invokevirtual #64                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #16                 // Field n:I
      16: invokevirtual #67                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #69                 // String , prob=
      21: invokevirtual #64                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #20                 // Field prob:D
      28: invokevirtual #72                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #75                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #16                 // Field n:I
       4: invokestatic  #83                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #20                 // Field prob:D
      16: invokestatic  #86                 // Method java/lang/Double.hashCode:(D)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/Problem1514$Node
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class leetcode/Problem1514$Node
      20: astore_2
      21: aload_0
      22: getfield      #16                 // Field n:I
      25: aload_2
      26: getfield      #16                 // Field n:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #20                 // Field prob:D
      38: aload_2
      39: getfield      #20                 // Field prob:D
      42: invokestatic  #43                 // Method java/lang/Double.compare:(DD)I
      45: ifeq          50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn

  public int compareTo(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #2                  // class leetcode/Problem1514$Node
       5: invokevirtual #94                 // Method compareTo:(Lleetcode/Problem1514$Node;)I
       8: ireturn
}

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

  public final double maxProbability(int, int[][], double[], int, int);
    Code:
       0: aload_2
       1: ldc           #15                 // String edges
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #23                 // String succProb
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: iload_1
      14: aload_2
      15: aload_3
      16: invokespecial #27                 // Method buildAdjList:(I[[I[D)[Ljava/util/List;
      19: astore        6
      21: iconst_0
      22: istore        8
      24: iload_1
      25: newarray       double
      27: astore        9
      29: iload         8
      31: iload_1
      32: if_icmpge     53
      35: iload         8
      37: istore        10
      39: aload         9
      41: iload         10
      43: ldc2_w        #28                 // double -Infinityd
      46: dastore
      47: iinc          8, 1
      50: goto          29
      53: aload         9
      55: astore        7
      57: new           #31                 // class java/util/PriorityQueue
      60: dup
      61: invokespecial #32                 // Method java/util/PriorityQueue."<init>":()V
      64: astore        8
      66: aload         8
      68: checkcast     #34                 // class java/util/Collection
      71: new           #36                 // class leetcode/Problem1514$Node
      74: dup
      75: iload         4
      77: aload         7
      79: iload         4
      81: daload
      82: invokespecial #39                 // Method leetcode/Problem1514$Node."<init>":(ID)V
      85: invokeinterface #43,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: aload         8
      93: checkcast     #34                 // class java/util/Collection
      96: invokeinterface #47,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     101: ifne          108
     104: iconst_1
     105: goto          109
     108: iconst_0
     109: ifeq          258
     112: aload         8
     114: invokevirtual #51                 // Method java/util/PriorityQueue.remove:()Ljava/lang/Object;
     117: checkcast     #36                 // class leetcode/Problem1514$Node
     120: astore        9
     122: aload         6
     124: aload         9
     126: invokevirtual #55                 // Method leetcode/Problem1514$Node.getN:()I
     129: aaload
     130: invokeinterface #61,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     135: astore        10
     137: aload         10
     139: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     144: ifeq          91
     147: aload         10
     149: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     154: checkcast     #71                 // class leetcode/Problem1514$Edge
     157: astore        11
     159: aload         7
     161: aload         11
     163: invokevirtual #74                 // Method leetcode/Problem1514$Edge.getFrom:()I
     166: daload
     167: ldc2_w        #28                 // double -Infinityd
     170: dcmpg
     171: ifne          178
     174: iconst_1
     175: goto          179
     178: iconst_0
     179: ifeq          190
     182: aload         11
     184: invokevirtual #78                 // Method leetcode/Problem1514$Edge.getProb:()D
     187: goto          204
     190: aload         7
     192: aload         11
     194: invokevirtual #74                 // Method leetcode/Problem1514$Edge.getFrom:()I
     197: daload
     198: aload         11
     200: invokevirtual #78                 // Method leetcode/Problem1514$Edge.getProb:()D
     203: dmul
     204: dstore        12
     206: dload         12
     208: aload         7
     210: aload         11
     212: invokevirtual #81                 // Method leetcode/Problem1514$Edge.getTo:()I
     215: daload
     216: dcmpl
     217: ifle          137
     220: aload         7
     222: aload         11
     224: invokevirtual #81                 // Method leetcode/Problem1514$Edge.getTo:()I
     227: dload         12
     229: dastore
     230: aload         8
     232: checkcast     #34                 // class java/util/Collection
     235: new           #36                 // class leetcode/Problem1514$Node
     238: dup
     239: aload         11
     241: invokevirtual #81                 // Method leetcode/Problem1514$Edge.getTo:()I
     244: dload         12
     246: invokespecial #39                 // Method leetcode/Problem1514$Node."<init>":(ID)V
     249: invokeinterface #43,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     254: pop
     255: goto          137
     258: aload         7
     260: iload         5
     262: daload
     263: ldc2_w        #28                 // double -Infinityd
     266: dcmpg
     267: ifne          274
     270: iconst_1
     271: goto          275
     274: iconst_0
     275: ifeq          282
     278: dconst_0
     279: goto          287
     282: aload         7
     284: iload         5
     286: daload
     287: dreturn

  private final java.util.List<leetcode.Problem1514$Edge>[] buildAdjList(int, int[][], double[]);
    Code:
       0: iconst_0
       1: istore        5
       3: iload_1
       4: anewarray     #57                 // class java/util/List
       7: astore        6
       9: iload         5
      11: iload_1
      12: if_icmpge     40
      15: iload         5
      17: istore        7
      19: aload         6
      21: iload         7
      23: new           #104                // class java/util/ArrayList
      26: dup
      27: invokespecial #105                // Method java/util/ArrayList."<init>":()V
      30: checkcast     #57                 // class java/util/List
      33: aastore
      34: iinc          5, 1
      37: goto          9
      40: aload         6
      42: astore        4
      44: iconst_0
      45: istore        5
      47: aload_2
      48: checkcast     #107                // class "[Ljava/lang/Object;"
      51: arraylength
      52: istore        6
      54: iload         5
      56: iload         6
      58: if_icmpge     141
      61: iload         5
      63: istore        7
      65: aload_2
      66: iload         5
      68: aaload
      69: astore        8
      71: aload         8
      73: iconst_0
      74: iaload
      75: istore        9
      77: aload         8
      79: iconst_1
      80: iaload
      81: istore        10
      83: aload         4
      85: iload         9
      87: aaload
      88: new           #71                 // class leetcode/Problem1514$Edge
      91: dup
      92: iload         9
      94: iload         10
      96: aload_3
      97: iload         7
      99: daload
     100: invokespecial #110                // Method leetcode/Problem1514$Edge."<init>":(IID)V
     103: invokeinterface #111,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     108: pop
     109: aload         4
     111: iload         10
     113: aaload
     114: new           #71                 // class leetcode/Problem1514$Edge
     117: dup
     118: iload         10
     120: iload         9
     122: aload_3
     123: iload         7
     125: daload
     126: invokespecial #110                // Method leetcode/Problem1514$Edge."<init>":(IID)V
     129: invokeinterface #111,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     134: pop
     135: iinc          5, 1
     138: goto          54
     141: aload         4
     143: areturn
}

Compiled from "Problem1514.kt"
final class leetcode.Problem1514$Edge {
  private final int from;

  private final int to;

  private final double prob;

  public leetcode.Problem1514$Edge(int, int, double);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field from:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field to:I
      14: aload_0
      15: dload_3
      16: putfield      #20                 // Field prob:D
      19: return

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

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

  public final double getProb();
    Code:
       0: aload_0
       1: getfield      #20                 // Field prob:D
       4: dreturn

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

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

  public final double component3();
    Code:
       0: aload_0
       1: getfield      #20                 // Field prob:D
       4: dreturn

  public final leetcode.Problem1514$Edge copy(int, int, double);
    Code:
       0: new           #2                  // class leetcode/Problem1514$Edge
       3: dup
       4: iload_1
       5: iload_2
       6: dload_3
       7: invokespecial #35                 // Method "<init>":(IID)V
      10: areturn

  public static leetcode.Problem1514$Edge copy$default(leetcode.Problem1514$Edge, int, int, double, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field from:I
      11: istore_1
      12: iload         5
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field to:I
      23: istore_2
      24: iload         5
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #20                 // Field prob:D
      35: dstore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: dload_3
      40: invokevirtual #39                 // Method copy:(IID)Lleetcode/Problem1514$Edge;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #43                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #44                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #46                 // String Edge(from=
       9: invokevirtual #50                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field from:I
      16: invokevirtual #53                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #55                 // String , to=
      21: invokevirtual #50                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field to:I
      28: invokevirtual #53                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #57                 // String , prob=
      33: invokevirtual #50                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #20                 // Field prob:D
      40: invokevirtual #60                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #63                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #65                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field from:I
       4: invokestatic  #71                 // 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 to:I
      16: invokestatic  #71                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #20                 // Field prob:D
      29: invokestatic  #76                 // Method java/lang/Double.hashCode:(D)I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class leetcode/Problem1514$Edge
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class leetcode/Problem1514$Edge
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field from:I
      25: aload_2
      26: getfield      #13                 // Field from:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field to:I
      38: aload_2
      39: getfield      #16                 // Field to:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #20                 // Field prob:D
      51: aload_2
      52: getfield      #20                 // Field prob:D
      55: invokestatic  #84                 // Method java/lang/Double.compare:(DD)I
      58: ifeq          63
      61: iconst_0
      62: ireturn
      63: iconst_1
      64: ireturn
}