package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/530
class P42861 {

    fun solution(n: Int, costs: Array<IntArray>): Int {
        // 건설 비용이 낮은 순으로 정렬
        costs.sortBy { (_, _, cost) -> cost }
        // Union-Find
        val root = IntArray(n) { it }
        var ans = 0
        var count = 0
        for ((from, to, cost) in costs) {
            // 두 정점의 부모 정점이 같다면 패스 (루프)
            if (root.find(from) == root.find(to)) continue
            // 비용 누적
            ans += cost
            // 부모를 합쳐준다.
            root.union(from, to)
            // 간선은 (N-1)개가 만들어진다.
            if (count++ >= n) break
        }
        return ans
    }

    private fun IntArray.find(x: Int): Int = if (this[x] == x) x else find(this[x])

    private fun IntArray.union(x: Int, y: Int) {
        this[find(y)] = find(x)
    }

}

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

  public final int solution(int, int[][]);
    Code:
       0: aload_2
       1: ldc           #15                 // String costs
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: checkcast     #23                 // class "[Ljava/lang/Object;"
      10: astore_3
      11: iconst_0
      12: istore        4
      14: aload_3
      15: arraylength
      16: iconst_1
      17: if_icmple     34
      20: aload_3
      21: new           #25                 // class kr/co/programmers/P42861$solution$$inlined$sortBy$1
      24: dup
      25: invokespecial #26                 // Method kr/co/programmers/P42861$solution$$inlined$sortBy$1."<init>":()V
      28: checkcast     #28                 // class java/util/Comparator
      31: invokestatic  #34                 // Method kotlin/collections/ArraysKt.sortWith:([Ljava/lang/Object;Ljava/util/Comparator;)V
      34: nop
      35: iconst_0
      36: istore        4
      38: iload_1
      39: newarray       int
      41: astore        5
      43: iload         4
      45: iload_1
      46: if_icmpge     66
      49: iload         4
      51: istore        6
      53: aload         5
      55: iload         6
      57: iload         6
      59: iastore
      60: iinc          4, 1
      63: goto          43
      66: aload         5
      68: astore_3
      69: iconst_0
      70: istore        4
      72: iconst_0
      73: istore        5
      75: iconst_0
      76: istore        6
      78: aload_2
      79: checkcast     #23                 // class "[Ljava/lang/Object;"
      82: arraylength
      83: istore        7
      85: iload         6
      87: iload         7
      89: if_icmpge     164
      92: aload_2
      93: iload         6
      95: aaload
      96: astore        8
      98: aload         8
     100: iconst_0
     101: iaload
     102: istore        9
     104: aload         8
     106: iconst_1
     107: iaload
     108: istore        10
     110: aload         8
     112: iconst_2
     113: iaload
     114: istore        11
     116: aload_0
     117: aload_3
     118: iload         9
     120: invokespecial #38                 // Method find:([II)I
     123: aload_0
     124: aload_3
     125: iload         10
     127: invokespecial #38                 // Method find:([II)I
     130: if_icmpeq     158
     133: iload         4
     135: iload         11
     137: iadd
     138: istore        4
     140: aload_0
     141: aload_3
     142: iload         9
     144: iload         10
     146: invokespecial #42                 // Method union:([III)V
     149: iload         5
     151: iinc          5, 1
     154: iload_1
     155: if_icmpge     164
     158: iinc          6, 1
     161: goto          85
     164: iload         4
     166: ireturn

  private final int find(int[], int);
    Code:
       0: aload_1
       1: iload_2
       2: iaload
       3: iload_2
       4: if_icmpne     11
       7: iload_2
       8: goto          19
      11: aload_0
      12: aload_1
      13: aload_1
      14: iload_2
      15: iaload
      16: invokespecial #38                 // Method find:([II)I
      19: ireturn

  private final void union(int[], int, int);
    Code:
       0: aload_1
       1: aload_0
       2: aload_1
       3: iload_3
       4: invokespecial #38                 // Method find:([II)I
       7: aload_0
       8: aload_1
       9: iload_2
      10: invokespecial #38                 // Method find:([II)I
      13: iastore
      14: return
}

Compiled from "Comparisons.kt"
public final class kr.co.programmers.P42861$solution$$inlined$sortBy$1<T> implements java.util.Comparator {
  public kr.co.programmers.P42861$solution$$inlined$sortBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class "[I"
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: iconst_2
      10: iaload
      11: istore        5
      13: iload         5
      15: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: checkcast     #31                 // class java/lang/Comparable
      21: aload_2
      22: checkcast     #23                 // class "[I"
      25: astore_3
      26: astore        6
      28: iconst_0
      29: istore        4
      31: aload_3
      32: iconst_2
      33: iaload
      34: istore        5
      36: iload         5
      38: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aload         6
      43: swap
      44: checkcast     #31                 // class java/lang/Comparable
      47: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      50: ireturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/481
class P172927 {

    fun solution(picks: IntArray, minerals: Array<String>): Int {
        // 곡괭이의 수만큼 5칸마다 구간의 합(가중치)을 구한다.
        val mines = mutableListOf<IntArray>()
        var numOfPick = picks[0] + picks[1] + picks[2]
        for (i in minerals.indices step 5) {
            // 곡괭이의 수만큼 계산
            if (numOfPick <= 0) break
            // [0] : 다이아몬드 광석 수
            // [1] : 철 광석 수
            // [2] : 돌 광석 수
            // [3] : 가중치
            val mine = IntArray(4)
            for (j in i until minOf(i + 5, minerals.size)) {
                when (minerals[j]) {
                    "diamond" -> {
                        mine[0]++
                        mine[3] += 25
                    }

                    "iron" -> {
                        mine[1]++
                        mine[3] += 5
                    }

                    "stone" -> {
                        mine[2]++
                        mine[3] += 1
                    }
                }
            }
            mines += mine
            numOfPick--
        }
        // 기중치로 내림차순 정렬
        mines.sortByDescending { it[3] }
        // 최소 피로도 계산
        var answer = 0
        for (mine in mines) {
            val (diamond, iron, stone) = mine
            answer += when {
                picks[0] > 0 -> {
                    picks[0]--
                    diamond + iron + stone
                }

                picks[1] > 0 -> {
                    picks[1]--
                    (diamond * 5) + iron + stone
                }

                picks[2] > 0 -> {
                    picks[0]--
                    (diamond * 25) + (iron * 5) + stone
                }

                else -> 0
            }
        }

        return answer
    }

}

Compiled from "Comparisons.kt"
public final class kr.co.programmers.P172927$solution$$inlined$sortByDescending$1<T> implements java.util.Comparator {
  public kr.co.programmers.P172927$solution$$inlined$sortByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class "[I"
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: iconst_3
      10: iaload
      11: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: checkcast     #31                 // class java/lang/Comparable
      17: aload_1
      18: checkcast     #23                 // class "[I"
      21: astore_3
      22: astore        5
      24: iconst_0
      25: istore        4
      27: aload_3
      28: iconst_3
      29: iaload
      30: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aload         5
      35: swap
      36: checkcast     #31                 // class java/lang/Comparable
      39: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      42: ireturn
}

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

  public final int solution(int[], java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String picks
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String minerals
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #25                 // class java/util/ArrayList
      15: dup
      16: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
      19: checkcast     #28                 // class java/util/List
      22: astore_3
      23: aload_1
      24: iconst_0
      25: iaload
      26: aload_1
      27: iconst_1
      28: iaload
      29: iadd
      30: aload_1
      31: iconst_2
      32: iaload
      33: iadd
      34: istore        4
      36: aload_2
      37: arraylength
      38: iconst_m1
      39: iadd
      40: istore        5
      42: iconst_0
      43: istore        6
      45: iconst_0
      46: iload         5
      48: iconst_5
      49: invokestatic  #34                 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I
      52: istore        7
      54: iload         6
      56: iload         7
      58: if_icmpgt     292
      61: iload         4
      63: ifle          292
      66: iconst_4
      67: newarray       int
      69: astore        8
      71: iload         6
      73: istore        9
      75: iload         6
      77: iconst_5
      78: iadd
      79: aload_2
      80: arraylength
      81: invokestatic  #40                 // Method java/lang/Math.min:(II)I
      84: istore        10
      86: iload         9
      88: iload         10
      90: if_icmpge     264
      93: aload_2
      94: iload         9
      96: aaload
      97: astore        11
      99: aload         11
     101: invokevirtual #46                 // Method java/lang/String.hashCode:()I
     104: lookupswitch  { // 3
               3241160: 153
             109770853: 166
            1655054676: 140
               default: 258
          }
     140: aload         11
     142: ldc           #48                 // String diamond
     144: invokevirtual #52                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     147: ifne          179
     150: goto          258
     153: aload         11
     155: ldc           #54                 // String iron
     157: invokevirtual #52                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     160: ifne          207
     163: goto          258
     166: aload         11
     168: ldc           #56                 // String stone
     170: invokevirtual #52                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     173: ifne          234
     176: goto          258
     179: aload         8
     181: iconst_0
     182: iaload
     183: istore        12
     185: aload         8
     187: iconst_0
     188: iload         12
     190: iconst_1
     191: iadd
     192: iastore
     193: aload         8
     195: iconst_3
     196: aload         8
     198: iconst_3
     199: iaload
     200: bipush        25
     202: iadd
     203: iastore
     204: goto          258
     207: aload         8
     209: iconst_1
     210: iaload
     211: istore        12
     213: aload         8
     215: iconst_1
     216: iload         12
     218: iconst_1
     219: iadd
     220: iastore
     221: aload         8
     223: iconst_3
     224: aload         8
     226: iconst_3
     227: iaload
     228: iconst_5
     229: iadd
     230: iastore
     231: goto          258
     234: aload         8
     236: iconst_2
     237: iaload
     238: istore        12
     240: aload         8
     242: iconst_2
     243: iload         12
     245: iconst_1
     246: iadd
     247: iastore
     248: aload         8
     250: iconst_3
     251: aload         8
     253: iconst_3
     254: iaload
     255: iconst_1
     256: iadd
     257: iastore
     258: iinc          9, 1
     261: goto          86
     264: aload_3
     265: checkcast     #58                 // class java/util/Collection
     268: aload         8
     270: invokeinterface #61,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     275: pop
     276: iinc          4, -1
     279: iload         6
     281: iload         7
     283: if_icmpeq     292
     286: iinc          6, 5
     289: goto          61
     292: aload_3
     293: astore        5
     295: iconst_0
     296: istore        6
     298: aload         5
     300: invokeinterface #64,  1           // InterfaceMethod java/util/List.size:()I
     305: iconst_1
     306: if_icmple     324
     309: aload         5
     311: new           #66                 // class kr/co/programmers/P172927$solution$$inlined$sortByDescending$1
     314: dup
     315: invokespecial #67                 // Method kr/co/programmers/P172927$solution$$inlined$sortByDescending$1."<init>":()V
     318: checkcast     #69                 // class java/util/Comparator
     321: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
     324: nop
     325: iconst_0
     326: istore        5
     328: aload_3
     329: invokeinterface #79,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     334: astore        6
     336: aload         6
     338: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     343: ifeq          479
     346: aload         6
     348: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     353: checkcast     #91                 // class "[I"
     356: astore        7
     358: aload         7
     360: iconst_0
     361: iaload
     362: istore        8
     364: aload         7
     366: iconst_1
     367: iaload
     368: istore        9
     370: aload         7
     372: iconst_2
     373: iaload
     374: istore        10
     376: iload         5
     378: aload_1
     379: iconst_0
     380: iaload
     381: ifle          407
     384: aload_1
     385: iconst_0
     386: iaload
     387: istore        11
     389: aload_1
     390: iconst_0
     391: iload         11
     393: iconst_m1
     394: iadd
     395: iastore
     396: iload         8
     398: iload         9
     400: iadd
     401: iload         10
     403: iadd
     404: goto          473
     407: aload_1
     408: iconst_1
     409: iaload
     410: ifle          438
     413: aload_1
     414: iconst_1
     415: iaload
     416: istore        11
     418: aload_1
     419: iconst_1
     420: iload         11
     422: iconst_m1
     423: iadd
     424: iastore
     425: iload         8
     427: iconst_5
     428: imul
     429: iload         9
     431: iadd
     432: iload         10
     434: iadd
     435: goto          473
     438: aload_1
     439: iconst_2
     440: iaload
     441: ifle          472
     444: aload_1
     445: iconst_0
     446: iaload
     447: istore        11
     449: aload_1
     450: iconst_0
     451: iload         11
     453: iconst_m1
     454: iadd
     455: iastore
     456: iload         8
     458: bipush        25
     460: imul
     461: iload         9
     463: iconst_5
     464: imul
     465: iadd
     466: iload         10
     468: iadd
     469: goto          473
     472: iconst_0
     473: iadd
     474: istore        5
     476: goto          336
     479: iload         5
     481: ireturn
}


package kr.co.programmers

import java.util.*

// https://github.com/antop-dev/algorithm/issues/489
class P155651 {
    fun solution(bookTime: Array<Array<String>>): Int {
        // 입(퇴)실 시간으로 정렬
        // 시간이 같다면 퇴실 시간이 먼저다.
        // first : 시간
        // second : 1(입실), 0(퇴실)
        val pq = PriorityQueue<Pair<Int, Int>> { a, b ->
            if (a.first == b.first) a.second - b.second else a.first - b.first
        }

        for (book in bookTime) {
            val (entrance, leave) = book
            pq += convert(entrance) to 1 // 입실
            pq += convert(leave, 10) to 0 // 퇴실 + 10분
        }

        var answer = 0
        var now = 0
        while (pq.isNotEmpty()) {
            val time = pq.poll()
            now += if (time.second == 1) 1 else -1
            answer = maxOf(answer, now)
        }
        return answer
    }

    // 시간 문자열을 숫자로 변경
    private fun convert(s: String, plus: Int = 0): Int {
        val split = s.split(":")
        var hour = split[0].toInt()
        var minute = split[1].toInt() + plus
        // 분이 넘쳤을 때 시간으로 넘긴다.
        if (minute >= 60) {
            hour++
            minute -= 60
        }
        return (hour * 60) + minute
    }

}

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

  public final int solution(java.lang.String[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String bookTime
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #23                 // class java/util/PriorityQueue
       9: dup
      10: invokedynamic #43,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
      15: invokedynamic #54,  0             // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
      20: invokespecial #57                 // Method java/util/PriorityQueue."<init>":(Ljava/util/Comparator;)V
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_1
      27: checkcast     #59                 // class "[Ljava/lang/Object;"
      30: arraylength
      31: istore        4
      33: iload_3
      34: iload         4
      36: if_icmpge     119
      39: aload_1
      40: iload_3
      41: aaload
      42: astore        5
      44: aload         5
      46: iconst_0
      47: aaload
      48: astore        6
      50: aload         5
      52: iconst_1
      53: aaload
      54: astore        7
      56: aload_2
      57: checkcast     #61                 // class java/util/Collection
      60: aload_0
      61: aload         6
      63: iconst_0
      64: iconst_2
      65: aconst_null
      66: invokestatic  #65                 // Method convert$default:(Lkr/co/programmers/P155651;Ljava/lang/String;IILjava/lang/Object;)I
      69: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: iconst_1
      73: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: invokestatic  #77                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      79: invokeinterface #81,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      84: pop
      85: aload_2
      86: checkcast     #61                 // class java/util/Collection
      89: aload_0
      90: aload         7
      92: bipush        10
      94: invokespecial #85                 // Method convert:(Ljava/lang/String;I)I
      97: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     100: iconst_0
     101: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     104: invokestatic  #77                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     107: invokeinterface #81,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     112: pop
     113: iinc          3, 1
     116: goto          33
     119: iconst_0
     120: istore_3
     121: iconst_0
     122: istore        4
     124: aload_2
     125: checkcast     #61                 // class java/util/Collection
     128: invokeinterface #89,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     133: ifne          140
     136: iconst_1
     137: goto          141
     140: iconst_0
     141: ifeq          188
     144: aload_2
     145: invokevirtual #93                 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
     148: checkcast     #95                 // class kotlin/Pair
     151: astore        5
     153: iload         4
     155: aload         5
     157: invokevirtual #98                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     160: checkcast     #100                // class java/lang/Number
     163: invokevirtual #104                // Method java/lang/Number.intValue:()I
     166: iconst_1
     167: if_icmpne     174
     170: iconst_1
     171: goto          175
     174: iconst_m1
     175: iadd
     176: istore        4
     178: iload_3
     179: iload         4
     181: invokestatic  #110                // Method java/lang/Math.max:(II)I
     184: istore_3
     185: goto          124
     188: iload_3
     189: ireturn

  private final int convert(java.lang.String, int);
    Code:
       0: aload_1
       1: checkcast     #126                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #128                // class java/lang/String
       8: astore        4
      10: aload         4
      12: iconst_0
      13: ldc           #130                // String :
      15: aastore
      16: aload         4
      18: iconst_0
      19: iconst_0
      20: bipush        6
      22: aconst_null
      23: invokestatic  #136                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      26: astore_3
      27: aload_3
      28: iconst_0
      29: invokeinterface #142,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      34: checkcast     #128                // class java/lang/String
      37: invokestatic  #146                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      40: istore        4
      42: aload_3
      43: iconst_1
      44: invokeinterface #142,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      49: checkcast     #128                // class java/lang/String
      52: invokestatic  #146                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      55: iload_2
      56: iadd
      57: istore        5
      59: iload         5
      61: bipush        60
      63: if_icmplt     72
      66: iinc          4, 1
      69: iinc          5, -60
      72: iload         4
      74: bipush        60
      76: imul
      77: iload         5
      79: iadd
      80: ireturn

  static int convert$default(kr.co.programmers.P155651, java.lang.String, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokespecial #85                 // Method convert:(Ljava/lang/String;I)I
      14: ireturn

  private static final int solution$lambda$0(kotlin.Pair, kotlin.Pair);
    Code:
       0: aload_0
       1: invokevirtual #155                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #100                // class java/lang/Number
       7: invokevirtual #104                // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokevirtual #155                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      14: checkcast     #100                // class java/lang/Number
      17: invokevirtual #104                // Method java/lang/Number.intValue:()I
      20: if_icmpne     47
      23: aload_0
      24: invokevirtual #98                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      27: checkcast     #100                // class java/lang/Number
      30: invokevirtual #104                // Method java/lang/Number.intValue:()I
      33: aload_1
      34: invokevirtual #98                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      37: checkcast     #100                // class java/lang/Number
      40: invokevirtual #104                // Method java/lang/Number.intValue:()I
      43: isub
      44: goto          68
      47: aload_0
      48: invokevirtual #155                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      51: checkcast     #100                // class java/lang/Number
      54: invokevirtual #104                // Method java/lang/Number.intValue:()I
      57: aload_1
      58: invokevirtual #155                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      61: checkcast     #100                // class java/lang/Number
      64: invokevirtual #104                // Method java/lang/Number.intValue:()I
      67: isub
      68: ireturn

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


package kr.co.programmers

import kotlin.math.pow
import kotlin.math.sqrt

// https://github.com/antop-dev/algorithm/issues/502
class P181187 {
    fun solution(r1: Int, r2: Int): Long {
        // y가 0인 점의 개수
        var count = 0L + (r2 - r1 + 1) * 4
        // x 좌표만 루프
        for (x in 1 until r2) {
            val minY = if (x < r1) y(x, r1).toCeilInt() else 1
            val maxY = y(x, r2).toFloorInt()
            count += (maxY - minY + 1) * 4
        }
        return count
    }

    // 피타고라스 정리를 이용하여 y값을 구한다.
    private fun y(x: Int, r: Int) = sqrt(r.pow(2) - x.pow(2))
}

// Int.제곱근
private fun Int.pow(n: Int) = this.toDouble().pow(n)

// Double -> 올림 Int
private fun Double.toCeilInt(): Int {
    var v = this.toInt()
    if (this - v > 0) v++
    return v
}

// Double -> 내림 Int
private fun Double.toFloorInt() = this.toInt()

Compiled from "P181187.kt"
public final class kr.co.programmers.P181187Kt {
  private static final double pow(int, int);
    Code:
       0: iload_0
       1: i2d
       2: iload_1
       3: i2d
       4: invokestatic  #11                 // Method java/lang/Math.pow:(DD)D
       7: dreturn

  private static final int toCeilInt(double);
    Code:
       0: dload_0
       1: d2i
       2: istore_2
       3: dload_0
       4: iload_2
       5: i2d
       6: dsub
       7: dconst_0
       8: dcmpl
       9: ifle          15
      12: iinc          2, 1
      15: iload_2
      16: ireturn

  private static final int toFloorInt(double);
    Code:
       0: dload_0
       1: d2i
       2: ireturn

  public static final int access$toCeilInt(double);
    Code:
       0: dload_0
       1: invokestatic  #24                 // Method toCeilInt:(D)I
       4: ireturn

  public static final int access$toFloorInt(double);
    Code:
       0: dload_0
       1: invokestatic  #28                 // Method toFloorInt:(D)I
       4: ireturn

  public static final double access$pow(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: invokestatic  #31                 // Method pow:(II)D
       5: dreturn
}

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

  public final long solution(int, int);
    Code:
       0: lconst_0
       1: iload_2
       2: iload_1
       3: isub
       4: iconst_1
       5: iadd
       6: iconst_4
       7: imul
       8: i2l
       9: ladd
      10: lstore_3
      11: iconst_1
      12: istore        5
      14: iload         5
      16: iload_2
      17: if_icmpge     73
      20: iload         5
      22: iload_1
      23: if_icmpge     39
      26: aload_0
      27: iload         5
      29: iload_1
      30: invokespecial #16                 // Method y:(II)D
      33: invokestatic  #22                 // Method kr/co/programmers/P181187Kt.access$toCeilInt:(D)I
      36: goto          40
      39: iconst_1
      40: istore        6
      42: aload_0
      43: iload         5
      45: iload_2
      46: invokespecial #16                 // Method y:(II)D
      49: invokestatic  #25                 // Method kr/co/programmers/P181187Kt.access$toFloorInt:(D)I
      52: istore        7
      54: lload_3
      55: iload         7
      57: iload         6
      59: isub
      60: iconst_1
      61: iadd
      62: iconst_4
      63: imul
      64: i2l
      65: ladd
      66: lstore_3
      67: iinc          5, 1
      70: goto          14
      73: lload_3
      74: lreturn

  private final double y(int, int);
    Code:
       0: iload_2
       1: iconst_2
       2: invokestatic  #36                 // Method kr/co/programmers/P181187Kt.access$pow:(II)D
       5: iload_1
       6: iconst_2
       7: invokestatic  #36                 // Method kr/co/programmers/P181187Kt.access$pow:(II)D
      10: dsub
      11: invokestatic  #42                 // Method java/lang/Math.sqrt:(D)D
      14: dreturn
}


package kr.co.programmers

// https://school.programmers.co.kr/learn/courses/30/lessons/60059
class P60059 {
    fun solution(k: Array<IntArray>, lock: Array<IntArray>): Boolean {
        var key = k
        repeat(4) { // 키를 4번 회전면서 체크한다.
            if (check(key, lock)) {
                return true
            }
            // 키를 오른쪽으로 90도 회전
            key = turn(key)
        }
        return false
    }

    private fun check(key: Array<IntArray>, lock: Array<IntArray>): Boolean {
        val n = lock.size
        val m = key.size
        val len = (n + m - 1)
        val loop = len * len
        var i = 0
        while (i < loop) {
            val x = (i % len) + n - m + 1
            val y = (i / len) + n - m + 1
            if (verify(key, lock, y, x)) {
                return true
            }
            i++
        }
        return false
    }

    /**
     * 자물쇠([lock])와 열쇠([key])에서 겹쳐지는 부분 계산
     */
    private fun verify(key: Array<IntArray>, lock: Array<IntArray>, y: Int, x: Int): Boolean {
        val m = key.size
        val n = lock.size
        val copiedLock = lock.map { it.copyOf() }
        for (i in y until y + m) {
            for (j in x until x + m) {
                // 자물쇠에 해당하는 부분만 계산
                if (i in n until n + n && j in n until n + n) {
                    copiedLock[i - n][j - n] += key[i - y][j - x]
                }
            }
        }
        // 자물쇠의 모든 칸이 1이면 OK
        return copiedLock.all { it.all { v -> v == 1 } }
    }

    /** 키를 오른쪽으로 90도 회전 */
    private fun turn(key: Array<IntArray>): Array<IntArray> {
        val n = key.size
        val turned = Array(n) { IntArray(n) }
        for (r in 0 until n) {
            for (c in 0 until n) {
                turned[c][n - r - 1] = key[r][c]
            }
        }
        return turned
    }

}

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

  public final boolean solution(int[][], int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String k
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String lock
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aconst_null
      13: astore_3
      14: aload_1
      15: astore_3
      16: iconst_4
      17: istore        4
      19: iconst_0
      20: istore        5
      22: iload         5
      24: iload         4
      26: if_icmpge     66
      29: iload         5
      31: istore        6
      33: iconst_0
      34: istore        7
      36: aload_0
      37: aload_3
      38: checkcast     #25                 // class "[[I"
      41: aload_2
      42: invokespecial #28                 // Method check:([[I[[I)Z
      45: ifeq          50
      48: iconst_1
      49: ireturn
      50: aload_0
      51: aload_3
      52: checkcast     #25                 // class "[[I"
      55: invokespecial #32                 // Method turn:([[I)[[I
      58: astore_3
      59: nop
      60: iinc          5, 1
      63: goto          22
      66: iconst_0
      67: ireturn

  private final boolean check(int[][], int[][]);
    Code:
       0: aload_2
       1: checkcast     #39                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore_3
       6: aload_1
       7: checkcast     #39                 // class "[Ljava/lang/Object;"
      10: arraylength
      11: istore        4
      13: iload_3
      14: iload         4
      16: iadd
      17: iconst_1
      18: isub
      19: istore        5
      21: iload         5
      23: iload         5
      25: imul
      26: istore        6
      28: iconst_0
      29: istore        7
      31: iload         7
      33: iload         6
      35: if_icmpge     87
      38: iload         7
      40: iload         5
      42: irem
      43: iload_3
      44: iadd
      45: iload         4
      47: isub
      48: iconst_1
      49: iadd
      50: istore        8
      52: iload         7
      54: iload         5
      56: idiv
      57: iload_3
      58: iadd
      59: iload         4
      61: isub
      62: iconst_1
      63: iadd
      64: istore        9
      66: aload_0
      67: aload_1
      68: aload_2
      69: iload         9
      71: iload         8
      73: invokespecial #43                 // Method verify:([[I[[III)Z
      76: ifeq          81
      79: iconst_1
      80: ireturn
      81: iinc          7, 1
      84: goto          31
      87: iconst_0
      88: ireturn

  private final boolean verify(int[][], int[][], int, int);
    Code:
       0: aload_1
       1: checkcast     #39                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore        5
       7: aload_2
       8: checkcast     #39                 // class "[Ljava/lang/Object;"
      11: arraylength
      12: istore        6
      14: aload_2
      15: checkcast     #39                 // class "[Ljava/lang/Object;"
      18: astore        8
      20: iconst_0
      21: istore        9
      23: aload         8
      25: astore        10
      27: new           #52                 // class java/util/ArrayList
      30: dup
      31: aload         8
      33: arraylength
      34: invokespecial #55                 // Method java/util/ArrayList."<init>":(I)V
      37: checkcast     #57                 // class java/util/Collection
      40: astore        11
      42: iconst_0
      43: istore        12
      45: iconst_0
      46: istore        13
      48: aload         10
      50: arraylength
      51: istore        14
      53: iload         13
      55: iload         14
      57: if_icmpge     110
      60: aload         10
      62: iload         13
      64: aaload
      65: astore        15
      67: aload         11
      69: aload         15
      71: checkcast     #59                 // class "[I"
      74: astore        16
      76: astore        21
      78: iconst_0
      79: istore        17
      81: aload         16
      83: dup
      84: arraylength
      85: invokestatic  #65                 // Method java/util/Arrays.copyOf:([II)[I
      88: dup
      89: ldc           #67                 // String copyOf(...)
      91: invokestatic  #70                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      94: nop
      95: aload         21
      97: swap
      98: invokeinterface #74,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: iinc          13, 1
     107: goto          53
     110: aload         11
     112: checkcast     #76                 // class java/util/List
     115: nop
     116: astore        7
     118: iload_3
     119: istore        8
     121: iload_3
     122: iload         5
     124: iadd
     125: istore        9
     127: iload         8
     129: iload         9
     131: if_icmpge     269
     134: iload         4
     136: istore        10
     138: iload         4
     140: iload         5
     142: iadd
     143: istore        11
     145: iload         10
     147: iload         11
     149: if_icmpge     263
     152: iload         6
     154: iload         8
     156: if_icmpgt     177
     159: iload         8
     161: iload         6
     163: iload         6
     165: iadd
     166: if_icmpge     173
     169: iconst_1
     170: goto          178
     173: iconst_0
     174: goto          178
     177: iconst_0
     178: ifeq          257
     181: iload         6
     183: iload         10
     185: if_icmpgt     206
     188: iload         10
     190: iload         6
     192: iload         6
     194: iadd
     195: if_icmpge     202
     198: iconst_1
     199: goto          207
     202: iconst_0
     203: goto          207
     206: iconst_0
     207: ifeq          257
     210: aload         7
     212: iload         8
     214: iload         6
     216: isub
     217: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     222: checkcast     #59                 // class "[I"
     225: astore        12
     227: iload         10
     229: iload         6
     231: isub
     232: istore        13
     234: aload         12
     236: iload         13
     238: aload         12
     240: iload         13
     242: iaload
     243: aload_1
     244: iload         8
     246: iload_3
     247: isub
     248: aaload
     249: iload         10
     251: iload         4
     253: isub
     254: iaload
     255: iadd
     256: iastore
     257: iinc          10, 1
     260: goto          145
     263: iinc          8, 1
     266: goto          127
     269: aload         7
     271: checkcast     #82                 // class java/lang/Iterable
     274: astore        8
     276: iconst_0
     277: istore        9
     279: aload         8
     281: instanceof    #57                 // class java/util/Collection
     284: ifeq          304
     287: aload         8
     289: checkcast     #57                 // class java/util/Collection
     292: invokeinterface #86,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     297: ifeq          304
     300: iconst_1
     301: goto          412
     304: aload         8
     306: invokeinterface #90,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     311: astore        10
     313: aload         10
     315: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     320: ifeq          411
     323: aload         10
     325: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     330: astore        11
     332: aload         11
     334: checkcast     #59                 // class "[I"
     337: astore        12
     339: iconst_0
     340: istore        13
     342: aload         12
     344: astore        14
     346: iconst_0
     347: istore        15
     349: iconst_0
     350: istore        16
     352: aload         14
     354: arraylength
     355: istore        17
     357: iload         16
     359: iload         17
     361: if_icmpge     402
     364: aload         14
     366: iload         16
     368: iaload
     369: istore        18
     371: iload         18
     373: istore        19
     375: iconst_0
     376: istore        20
     378: iload         19
     380: iconst_1
     381: if_icmpne     388
     384: iconst_1
     385: goto          389
     388: iconst_0
     389: ifne          396
     392: iconst_0
     393: goto          403
     396: iinc          16, 1
     399: goto          357
     402: iconst_1
     403: nop
     404: ifne          313
     407: iconst_0
     408: goto          412
     411: iconst_1
     412: ireturn

  private final int[][] turn(int[][]);
    Code:
       0: aload_1
       1: checkcast     #39                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore_2
       6: iconst_0
       7: istore        4
       9: iload_2
      10: anewarray     #59                 // class "[I"
      13: astore        5
      15: iload         4
      17: iload_2
      18: if_icmpge     39
      21: iload         4
      23: istore        6
      25: aload         5
      27: iload         6
      29: iload_2
      30: newarray       int
      32: aastore
      33: iinc          4, 1
      36: goto          15
      39: aload         5
      41: astore_3
      42: iconst_0
      43: istore        4
      45: iload         4
      47: iload_2
      48: if_icmpge     90
      51: iconst_0
      52: istore        5
      54: iload         5
      56: iload_2
      57: if_icmpge     84
      60: aload_3
      61: iload         5
      63: aaload
      64: iload_2
      65: iload         4
      67: isub
      68: iconst_1
      69: isub
      70: aload_1
      71: iload         4
      73: aaload
      74: iload         5
      76: iaload
      77: iastore
      78: iinc          5, 1
      81: goto          54
      84: iinc          4, 1
      87: goto          45
      90: aload_3
      91: areturn
}


package kr.co.programmers

import java.math.BigInteger

// https://github.com/antop-dev/algorithm/issues/403
class P92335 {
    companion object {
        val TEEN: BigInteger = BigInteger("10")
    }

    fun solution(n: Int, k: Int): Int {

        var answer = 0
        val kNumber = decimalToK(n, k) + "0" // n.toString(k) + "0"
        var num = BigInteger.ZERO
        for (ch in kNumber) { // 한 문자씩 탐색
            val n = ch - '0'
            num = if (n == 0 && num != BigInteger.ZERO) { // 조건에 맞는 경우
                if (isPrime(num)) { // 소수인지 판단
                    answer++
                }
                BigInteger.ZERO // 수 초기화
            } else { // 숫자를 완성해 나간다.
                // num = (num * 10) + n
                (num * TEEN) + BigInteger("$n")
            }
        }
        return answer
    }

    // 10진수를 k진수로 변환
    private fun decimalToK(n: Int, k: Int): String {
        val sb = StringBuilder()
        var num = n
        while (num >= k) {
            sb.insert(0, num % k)
            num /= k
        }
        sb.insert(0, num)
        return sb.toString()
    }

    // 소수인지 판단
    private fun isPrime(num: BigInteger): Boolean {
        if (num <= BigInteger.ONE) {
            return false
        }
        for (n in 2 until num.sqrt().toLong() + 1) {
            // 나눠지면 소수가 아니다
            if (num.mod(BigInteger("$n")) == BigInteger.ZERO) {
                return false
            }
        }
        return true
    }

}

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

  public final java.math.BigInteger getTEEN();
    Code:
       0: invokestatic  #18                 // Method kr/co/programmers/P92335.access$getTEEN$cp:()Ljava/math/BigInteger;
       3: areturn

  public kr.co.programmers.P92335$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #20                 // Method "<init>":()V
       4: return
}

Compiled from "P92335.kt"
public final class kr.co.programmers.P92335 {
  public static final kr.co.programmers.P92335$Companion Companion;

  private static final java.math.BigInteger TEEN;

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

  public final int solution(int, int);
    Code:
       0: iconst_0
       1: istore_3
       2: new           #14                 // class java/lang/StringBuilder
       5: dup
       6: invokespecial #15                 // Method java/lang/StringBuilder."<init>":()V
       9: aload_0
      10: iload_1
      11: iload_2
      12: invokespecial #19                 // Method decimalToK:(II)Ljava/lang/String;
      15: invokevirtual #23                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: bipush        48
      20: invokevirtual #26                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      23: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      26: astore        4
      28: getstatic     #36                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      31: astore        5
      33: iconst_0
      34: istore        6
      36: aload         4
      38: invokevirtual #42                 // Method java/lang/String.length:()I
      41: istore        7
      43: iload         6
      45: iload         7
      47: if_icmpge     171
      50: aload         4
      52: iload         6
      54: invokevirtual #46                 // Method java/lang/String.charAt:(I)C
      57: istore        8
      59: iload         8
      61: bipush        48
      63: isub
      64: istore        9
      66: iload         9
      68: ifne          109
      71: aload         5
      73: getstatic     #36                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      76: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      79: ifne          109
      82: aload_0
      83: aload         5
      85: astore        10
      87: aload         10
      89: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      92: aload         10
      94: invokespecial #60                 // Method isPrime:(Ljava/math/BigInteger;)Z
      97: ifeq          103
     100: iinc          3, 1
     103: getstatic     #36                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     106: goto          163
     109: aload         5
     111: astore        10
     113: aload         10
     115: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     118: aload         10
     120: astore        10
     122: getstatic     #63                 // Field TEEN:Ljava/math/BigInteger;
     125: aload         10
     127: swap
     128: invokevirtual #67                 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     131: dup
     132: ldc           #69                 // String multiply(...)
     134: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     137: astore        10
     139: new           #32                 // class java/math/BigInteger
     142: dup
     143: iload         9
     145: invokestatic  #77                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     148: invokespecial #80                 // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
     151: aload         10
     153: swap
     154: invokevirtual #83                 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     157: dup
     158: ldc           #85                 // String add(...)
     160: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     163: astore        5
     165: iinc          6, 1
     168: goto          43
     171: iload_3
     172: ireturn

  private final java.lang.String decimalToK(int, int);
    Code:
       0: new           #14                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #15                 // Method java/lang/StringBuilder."<init>":()V
       7: astore_3
       8: iload_1
       9: istore        4
      11: iload         4
      13: iload_2
      14: if_icmplt     36
      17: aload_3
      18: iconst_0
      19: iload         4
      21: iload_2
      22: irem
      23: invokevirtual #98                 // Method java/lang/StringBuilder.insert:(II)Ljava/lang/StringBuilder;
      26: pop
      27: iload         4
      29: iload_2
      30: idiv
      31: istore        4
      33: goto          11
      36: aload_3
      37: iconst_0
      38: iload         4
      40: invokevirtual #98                 // Method java/lang/StringBuilder.insert:(II)Ljava/lang/StringBuilder;
      43: pop
      44: aload_3
      45: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      48: dup
      49: ldc           #100                // String toString(...)
      51: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      54: areturn

  private final boolean isPrime(java.math.BigInteger);
    Code:
       0: aload_1
       1: getstatic     #105                // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
       4: invokevirtual #109                // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
       7: ifgt          12
      10: iconst_0
      11: ireturn
      12: ldc2_w        #110                // long 2l
      15: lstore_2
      16: aload_1
      17: invokevirtual #115                // Method java/math/BigInteger.sqrt:()Ljava/math/BigInteger;
      20: invokevirtual #119                // Method java/math/BigInteger.longValue:()J
      23: lconst_1
      24: ladd
      25: lstore        4
      27: lload_2
      28: lload         4
      30: lcmp
      31: ifge          67
      34: aload_1
      35: new           #32                 // class java/math/BigInteger
      38: dup
      39: lload_2
      40: invokestatic  #122                // Method java/lang/String.valueOf:(J)Ljava/lang/String;
      43: invokespecial #80                 // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      46: invokevirtual #125                // Method java/math/BigInteger.mod:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      49: getstatic     #36                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      52: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      55: ifeq          60
      58: iconst_0
      59: ireturn
      60: lload_2
      61: lconst_1
      62: ladd
      63: lstore_2
      64: goto          27
      67: iconst_1
      68: ireturn

  public static final java.math.BigInteger access$getTEEN$cp();
    Code:
       0: getstatic     #63                 // Field TEEN:Ljava/math/BigInteger;
       3: areturn

  static {};
    Code:
       0: new           #130                // class kr/co/programmers/P92335$Companion
       3: dup
       4: aconst_null
       5: invokespecial #133                // Method kr/co/programmers/P92335$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #137                // Field Companion:Lkr/co/programmers/P92335$Companion;
      11: new           #32                 // class java/math/BigInteger
      14: dup
      15: ldc           #139                // String 10
      17: invokespecial #80                 // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      20: putstatic     #63                 // Field TEEN:Ljava/math/BigInteger;
      23: return
}


package kr.co.programmers

import kotlin.math.ceil

// https://github.com/antop-dev/algorithm/issues/396
class P92341 {
    fun solution(fees: IntArray, records: Array<String>): IntArray {
        // 차량의 마지막 입차 시간을 가지고 있는 맵
        val inMap = mutableMapOf<String, Int>()
        // 차량의 누적 주차 시간을 가지고 있는 맵
        val timeMap = mutableMapOf<String, Int>()
        // 차량의 주차 요금
        val moneyMap = mutableMapOf<String, Int>()
        // 누적 주차시간 계산
        for (record in records) {
            val split = record.split(" ")
            val t = split[0].split(":")

            val time = t[0].toInt() * 60 + t[1].toInt() // 숫자로 변환한 시각
            val carNumber = split[1] // 차량번호
            val inOut = split[2] // 내역
            // 누적 주차 시간 0으로 세팅
            if (!timeMap.containsKey(carNumber)) {
                timeMap[carNumber] = 0
            }
            // "OUT" 전에는 반드시 "IN"이 있다.
            if (inOut == "IN") {
                inMap[carNumber] = time
            } else { // "OUT"
                timeMap[carNumber] = timeMap[carNumber]!! + (time - inMap.remove(carNumber)!!)
            }
        }
        // 타임맵에 남아있다면 23:59분 출차로 계산한다.
        for ((carNumber, time) in inMap.entries) {
            timeMap[carNumber] = timeMap[carNumber]!! + (1439 - time)
        }
        // 주차 요금 계산
        for ((carNumber, time) in timeMap.entries) {
            var money = 0.0 + fees[1]
            if (time - fees[0] > 0) {
                money += ceil((time - fees[0]).toDouble() / fees[2]) * fees[3]
            }
            moneyMap[carNumber] = money.toInt()
        }
        // 차량번호로 정렬 후 금액만 리턴
        return moneyMap.toSortedMap().values.toIntArray()
    }

}

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

  public final int[] solution(int[], java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String fees
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String records
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #25                 // class java/util/LinkedHashMap
      15: dup
      16: invokespecial #26                 // Method java/util/LinkedHashMap."<init>":()V
      19: checkcast     #28                 // class java/util/Map
      22: astore_3
      23: new           #25                 // class java/util/LinkedHashMap
      26: dup
      27: invokespecial #26                 // Method java/util/LinkedHashMap."<init>":()V
      30: checkcast     #28                 // class java/util/Map
      33: astore        4
      35: new           #25                 // class java/util/LinkedHashMap
      38: dup
      39: invokespecial #26                 // Method java/util/LinkedHashMap."<init>":()V
      42: checkcast     #28                 // class java/util/Map
      45: astore        5
      47: iconst_0
      48: istore        6
      50: aload_2
      51: arraylength
      52: istore        7
      54: iload         6
      56: iload         7
      58: if_icmpge     308
      61: aload_2
      62: iload         6
      64: aaload
      65: astore        8
      67: aload         8
      69: checkcast     #30                 // class java/lang/CharSequence
      72: iconst_1
      73: anewarray     #32                 // class java/lang/String
      76: astore        10
      78: aload         10
      80: iconst_0
      81: ldc           #34                 // String
      83: aastore
      84: aload         10
      86: iconst_0
      87: iconst_0
      88: bipush        6
      90: aconst_null
      91: invokestatic  #40                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      94: astore        9
      96: aload         9
      98: iconst_0
      99: invokeinterface #46,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     104: checkcast     #30                 // class java/lang/CharSequence
     107: iconst_1
     108: anewarray     #32                 // class java/lang/String
     111: astore        11
     113: aload         11
     115: iconst_0
     116: ldc           #48                 // String :
     118: aastore
     119: aload         11
     121: iconst_0
     122: iconst_0
     123: bipush        6
     125: aconst_null
     126: invokestatic  #40                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     129: astore        10
     131: aload         10
     133: iconst_0
     134: invokeinterface #46,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     139: checkcast     #32                 // class java/lang/String
     142: invokestatic  #54                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     145: bipush        60
     147: imul
     148: aload         10
     150: iconst_1
     151: invokeinterface #46,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     156: checkcast     #32                 // class java/lang/String
     159: invokestatic  #54                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     162: iadd
     163: istore        11
     165: aload         9
     167: iconst_1
     168: invokeinterface #46,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     173: checkcast     #32                 // class java/lang/String
     176: astore        12
     178: aload         9
     180: iconst_2
     181: invokeinterface #46,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     186: checkcast     #32                 // class java/lang/String
     189: astore        13
     191: aload         4
     193: aload         12
     195: invokeinterface #58,  2           // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     200: ifne          217
     203: aload         4
     205: aload         12
     207: iconst_0
     208: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     211: invokeinterface #66,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     216: pop
     217: aload         13
     219: ldc           #68                 // String IN
     221: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     224: ifeq          248
     227: iload         11
     229: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: astore        14
     234: aload_3
     235: aload         12
     237: aload         14
     239: invokeinterface #66,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     244: pop
     245: goto          302
     248: aload         4
     250: aload         12
     252: aload         4
     254: aload         12
     256: invokeinterface #75,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     261: dup
     262: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     265: checkcast     #81                 // class java/lang/Number
     268: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     271: iload         11
     273: aload_3
     274: aload         12
     276: invokeinterface #88,  2           // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;
     281: dup
     282: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     285: checkcast     #81                 // class java/lang/Number
     288: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     291: isub
     292: iadd
     293: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     296: invokeinterface #66,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     301: pop
     302: iinc          6, 1
     305: goto          54
     308: aload_3
     309: invokeinterface #92,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     314: invokeinterface #98,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     319: astore        6
     321: aload         6
     323: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     328: ifeq          412
     331: aload         6
     333: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     338: checkcast     #110                // class java/util/Map$Entry
     341: astore        7
     343: aload         7
     345: invokeinterface #113,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     350: checkcast     #32                 // class java/lang/String
     353: astore        8
     355: aload         7
     357: invokeinterface #116,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     362: checkcast     #81                 // class java/lang/Number
     365: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     368: istore        9
     370: aload         4
     372: aload         8
     374: aload         4
     376: aload         8
     378: invokeinterface #75,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     383: dup
     384: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     387: checkcast     #81                 // class java/lang/Number
     390: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     393: sipush        1439
     396: iload         9
     398: isub
     399: iadd
     400: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     403: invokeinterface #66,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     408: pop
     409: goto          321
     412: aload         4
     414: invokeinterface #92,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     419: invokeinterface #98,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     424: astore        6
     426: aload         6
     428: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     433: ifeq          536
     436: aload         6
     438: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     443: checkcast     #110                // class java/util/Map$Entry
     446: astore        7
     448: aload         7
     450: invokeinterface #113,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     455: checkcast     #32                 // class java/lang/String
     458: astore        8
     460: aload         7
     462: invokeinterface #116,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     467: checkcast     #81                 // class java/lang/Number
     470: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     473: istore        9
     475: dconst_0
     476: aload_1
     477: iconst_1
     478: iaload
     479: i2d
     480: dadd
     481: dstore        10
     483: iload         9
     485: aload_1
     486: iconst_0
     487: iaload
     488: isub
     489: ifle          517
     492: dload         10
     494: iload         9
     496: aload_1
     497: iconst_0
     498: iaload
     499: isub
     500: i2d
     501: aload_1
     502: iconst_2
     503: iaload
     504: i2d
     505: ddiv
     506: invokestatic  #122                // Method java/lang/Math.ceil:(D)D
     509: aload_1
     510: iconst_3
     511: iaload
     512: i2d
     513: dmul
     514: dadd
     515: dstore        10
     517: aload         5
     519: aload         8
     521: dload         10
     523: d2i
     524: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     527: invokeinterface #66,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     532: pop
     533: goto          426
     536: aload         5
     538: invokestatic  #128                // Method kotlin/collections/MapsKt.toSortedMap:(Ljava/util/Map;)Ljava/util/SortedMap;
     541: invokeinterface #134,  1          // InterfaceMethod java/util/SortedMap.values:()Ljava/util/Collection;
     546: dup
     547: ldc           #136                // String <get-values>(...)
     549: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     552: invokestatic  #145                // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     555: areturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/411
class P12978 {
    companion object {
        const val INF = 500_001 // 최대 시간은 K + 1
    }

    fun solution(N: Int, road: Array<IntArray>, k: Int): Int {
        if (N == 1) return 1
        // 행노드 -> 열노드간의 거리를 2차원 배열에 담는다.
        val graph = makeGraph(N, road)
        // 노드 방문 여부
        val visited = BooleanArray(N + 1)
        // 이동 시간
        val times = IntArray(N + 1) {
            if (it >= 2) INF else 0
        }
        var node = 1 // 1번 마을에서 시작
        while (node != INF) {
            visited[node] = true
            // 갈 수 있는 노드 계산
            for (i in 1..N) {
                if (visited[i]) continue
                if (graph[node][i] == INF) continue
                // 시간 갱신
                if (times[node] + graph[node][i] < times[i]) {
                    times[i] = times[node] + graph[node][i]
                }
            }
            // 가장 최소 시간를 가지는 노드를 구한다.
            node = run {
                var min = INF
                var idx = INF
                for (i in 1 .. N) {
                    if (!visited[i] && times[i] < min) {
                        min = times[i]
                        idx = i
                    }
                }
                idx
            }
        }
        // K 시간 이하로 배달이 가능한 노드 개수 세기
        var answer = 0
        for (i in 1 until times.size) {
            if (times[i] <= k) answer++
        }
        return answer
    }

    private fun makeGraph(N: Int, road: Array<IntArray>): Array<IntArray> {
        val graph = Array(N + 1) {
            IntArray(N + 1)
        }
        // 디폴트를 0 또는 INF
        for (i in 1..N) {
            for (j in 1..N) {
                if (i == j) continue
                graph[i][j] = INF
            }
        }
        // 마을간에 여러개의 길이 있을 수 있으므로 최단 거리만 남긴다.
        for (r in road) {
            if (r[2] < graph[r[0]][r[1]]) {
                graph[r[0]][r[1]] = r[2]
            }
            if (r[2] < graph[r[1]][r[0]]) {
                graph[r[1]][r[0]] = r[2]
            }
        }
        return graph
    }

}

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

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

Compiled from "P12978.kt"
public final class kr.co.programmers.P12978 {
  public static final kr.co.programmers.P12978$Companion Companion;

  public static final int INF;

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

  public final int solution(int, int[][], int);
    Code:
       0: aload_2
       1: ldc           #15                 // String road
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: iconst_1
       8: if_icmpne     13
      11: iconst_1
      12: ireturn
      13: aload_0
      14: iload_1
      15: aload_2
      16: invokespecial #25                 // Method makeGraph:(I[[I)[[I
      19: astore        4
      21: iload_1
      22: iconst_1
      23: iadd
      24: newarray       boolean
      26: astore        5
      28: iconst_0
      29: istore        7
      31: iload_1
      32: iconst_1
      33: iadd
      34: istore        8
      36: iload         8
      38: newarray       int
      40: astore        9
      42: iload         7
      44: iload         8
      46: if_icmpge     76
      49: iload         7
      51: istore        10
      53: aload         9
      55: iload         10
      57: iload         10
      59: iconst_2
      60: if_icmplt     68
      63: ldc           #26                 // int 500001
      65: goto          69
      68: iconst_0
      69: iastore
      70: iinc          7, 1
      73: goto          42
      76: aload         9
      78: astore        6
      80: iconst_1
      81: istore        7
      83: iload         7
      85: ldc           #26                 // int 500001
      87: if_icmpeq     254
      90: aload         5
      92: iload         7
      94: iconst_1
      95: bastore
      96: iconst_1
      97: istore        8
      99: iload         8
     101: iload_1
     102: if_icmpgt     179
     105: aload         5
     107: iload         8
     109: baload
     110: ifne          167
     113: aload         4
     115: iload         7
     117: aaload
     118: iload         8
     120: iaload
     121: ldc           #26                 // int 500001
     123: if_icmpeq     167
     126: aload         6
     128: iload         7
     130: iaload
     131: aload         4
     133: iload         7
     135: aaload
     136: iload         8
     138: iaload
     139: iadd
     140: aload         6
     142: iload         8
     144: iaload
     145: if_icmpge     167
     148: aload         6
     150: iload         8
     152: aload         6
     154: iload         7
     156: iaload
     157: aload         4
     159: iload         7
     161: aaload
     162: iload         8
     164: iaload
     165: iadd
     166: iastore
     167: iload         8
     169: iload_1
     170: if_icmpeq     179
     173: iinc          8, 1
     176: goto          105
     179: aload_0
     180: checkcast     #2                  // class kr/co/programmers/P12978
     183: astore        9
     185: iconst_0
     186: istore        10
     188: ldc           #26                 // int 500001
     190: istore        11
     192: ldc           #26                 // int 500001
     194: istore        12
     196: iconst_1
     197: istore        13
     199: iload         13
     201: iload_1
     202: if_icmpgt     246
     205: aload         5
     207: iload         13
     209: baload
     210: ifne          234
     213: aload         6
     215: iload         13
     217: iaload
     218: iload         11
     220: if_icmpge     234
     223: aload         6
     225: iload         13
     227: iaload
     228: istore        11
     230: iload         13
     232: istore        12
     234: iload         13
     236: iload_1
     237: if_icmpeq     246
     240: iinc          13, 1
     243: goto          205
     246: iload         12
     248: nop
     249: istore        7
     251: goto          83
     254: iconst_0
     255: istore        8
     257: iconst_1
     258: istore        9
     260: aload         6
     262: arraylength
     263: istore        10
     265: iload         9
     267: iload         10
     269: if_icmpge     290
     272: aload         6
     274: iload         9
     276: iaload
     277: iload_3
     278: if_icmpgt     284
     281: iinc          8, 1
     284: iinc          9, 1
     287: goto          265
     290: iload         8
     292: ireturn

  private final int[][] makeGraph(int, int[][]);
    Code:
       0: iconst_0
       1: istore        4
       3: iload_1
       4: iconst_1
       5: iadd
       6: istore        5
       8: iload         5
      10: anewarray     #45                 // class "[I"
      13: astore        6
      15: iload         4
      17: iload         5
      19: if_icmpge     42
      22: iload         4
      24: istore        7
      26: aload         6
      28: iload         7
      30: iload_1
      31: iconst_1
      32: iadd
      33: newarray       int
      35: aastore
      36: iinc          4, 1
      39: goto          15
      42: aload         6
      44: astore_3
      45: iconst_1
      46: istore        4
      48: iload         4
      50: iload_1
      51: if_icmpgt     103
      54: iconst_1
      55: istore        5
      57: iload         5
      59: iload_1
      60: if_icmpgt     91
      63: iload         4
      65: iload         5
      67: if_icmpeq     79
      70: aload_3
      71: iload         4
      73: aaload
      74: iload         5
      76: ldc           #26                 // int 500001
      78: iastore
      79: iload         5
      81: iload_1
      82: if_icmpeq     91
      85: iinc          5, 1
      88: goto          63
      91: iload         4
      93: iload_1
      94: if_icmpeq     103
      97: iinc          4, 1
     100: goto          54
     103: iconst_0
     104: istore        4
     106: aload_2
     107: checkcast     #47                 // class "[Ljava/lang/Object;"
     110: arraylength
     111: istore        5
     113: iload         4
     115: iload         5
     117: if_icmpge     198
     120: aload_2
     121: iload         4
     123: aaload
     124: astore        6
     126: aload         6
     128: iconst_2
     129: iaload
     130: aload_3
     131: aload         6
     133: iconst_0
     134: iaload
     135: aaload
     136: aload         6
     138: iconst_1
     139: iaload
     140: iaload
     141: if_icmpge     159
     144: aload_3
     145: aload         6
     147: iconst_0
     148: iaload
     149: aaload
     150: aload         6
     152: iconst_1
     153: iaload
     154: aload         6
     156: iconst_2
     157: iaload
     158: iastore
     159: aload         6
     161: iconst_2
     162: iaload
     163: aload_3
     164: aload         6
     166: iconst_1
     167: iaload
     168: aaload
     169: aload         6
     171: iconst_0
     172: iaload
     173: iaload
     174: if_icmpge     192
     177: aload_3
     178: aload         6
     180: iconst_1
     181: iaload
     182: aaload
     183: aload         6
     185: iconst_0
     186: iaload
     187: aload         6
     189: iconst_2
     190: iaload
     191: iastore
     192: iinc          4, 1
     195: goto          113
     198: aload_3
     199: areturn

  static {};
    Code:
       0: new           #52                 // class kr/co/programmers/P12978$Companion
       3: dup
       4: aconst_null
       5: invokespecial #55                 // Method kr/co/programmers/P12978$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #59                 // Field Companion:Lkr/co/programmers/P12978$Companion;
      11: return
}


package kr.co.programmers

import java.util.*

// https://github.com/antop-dev/algorithm/issues/491
class P150369 {
    fun solution(cap: Int, n: Int, deliveries: IntArray, pickups: IntArray): Long {
        val d = Stack<Int>()
        val p = Stack<Int>()
        var move = 0L // 총 이동거리

        for (i in 0 until n) {
            if (deliveries[i] > 0) d.push(i)
            if (pickups[i] > 0) p.push(i)
        }

        while (d.isNotEmpty() || p.isNotEmpty()) {
            // 배달과 수거중 가장 먼 위치 찾기
            val i = maxOf(peek(d), peek(p))
            // 왕복 거리 계산
            move += (i + 1) * 2
            // 배달과 수거 계산하기
            calculate(d, deliveries, cap)
            calculate(p, pickups, cap)
        }

        return move
    }

    private fun calculate(stack: Stack<Int>, arr: IntArray, cap: Int) {
        var sum = 0
        while (stack.isNotEmpty() && sum < cap) {
            val i = stack.pop()
            val v = arr[i]
            // 배달(수거)할 양이 최대치(cap)보다 클 경우 최대한 차에 실는다.
            // 수거해야할 양이 6이고 차에 여유공간이 3일경우 3이라도 실어서 간다.
            // 다음에 같은 위치에 와서 남은 3을 수거해간다.
            if (sum + v > cap) {
                arr[i] = sum + v - cap
                stack.push(i)
            }
            sum += v
        }
    }

    // 스택이 비어 있으면 -1 처리
    private fun peek(stack: Stack<Int>) = if (stack.isNotEmpty()) stack.peek() else -1

}

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

  public final long solution(int, int, int[], int[]);
    Code:
       0: aload_3
       1: ldc           #15                 // String deliveries
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload         4
       8: ldc           #23                 // String pickups
      10: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: new           #25                 // class java/util/Stack
      16: dup
      17: invokespecial #26                 // Method java/util/Stack."<init>":()V
      20: astore        5
      22: new           #25                 // class java/util/Stack
      25: dup
      26: invokespecial #26                 // Method java/util/Stack."<init>":()V
      29: astore        6
      31: lconst_0
      32: lstore        7
      34: iconst_0
      35: istore        9
      37: iload         9
      39: iload_2
      40: if_icmpge     86
      43: aload_3
      44: iload         9
      46: iaload
      47: ifle          61
      50: aload         5
      52: iload         9
      54: invokestatic  #32                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokevirtual #36                 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
      60: pop
      61: aload         4
      63: iload         9
      65: iaload
      66: ifle          80
      69: aload         6
      71: iload         9
      73: invokestatic  #32                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: invokevirtual #36                 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
      79: pop
      80: iinc          9, 1
      83: goto          37
      86: aload         5
      88: checkcast     #38                 // class java/util/Collection
      91: invokeinterface #42,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      96: ifne          103
      99: iconst_1
     100: goto          104
     103: iconst_0
     104: ifne          128
     107: aload         6
     109: checkcast     #38                 // class java/util/Collection
     112: invokeinterface #42,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     117: ifne          124
     120: iconst_1
     121: goto          125
     124: iconst_0
     125: ifeq          209
     128: aload_0
     129: aload         5
     131: invokespecial #46                 // Method peek:(Ljava/util/Stack;)Ljava/lang/Integer;
     134: dup
     135: ldc           #48                 // String peek(...)
     137: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     140: checkcast     #53                 // class java/lang/Number
     143: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     146: istore        10
     148: aload_0
     149: aload         6
     151: invokespecial #46                 // Method peek:(Ljava/util/Stack;)Ljava/lang/Integer;
     154: dup
     155: ldc           #48                 // String peek(...)
     157: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     160: checkcast     #53                 // class java/lang/Number
     163: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     166: istore        11
     168: iload         10
     170: iload         11
     172: invokestatic  #63                 // Method java/lang/Math.max:(II)I
     175: istore        9
     177: lload         7
     179: iload         9
     181: iconst_1
     182: iadd
     183: iconst_2
     184: imul
     185: i2l
     186: ladd
     187: lstore        7
     189: aload_0
     190: aload         5
     192: aload_3
     193: iload_1
     194: invokespecial #67                 // Method calculate:(Ljava/util/Stack;[II)V
     197: aload_0
     198: aload         6
     200: aload         4
     202: iload_1
     203: invokespecial #67                 // Method calculate:(Ljava/util/Stack;[II)V
     206: goto          86
     209: lload         7
     211: lreturn

  private final void calculate(java.util.Stack<java.lang.Integer>, int[], int);
    Code:
       0: iconst_0
       1: istore        4
       3: aload_1
       4: checkcast     #38                 // class java/util/Collection
       7: invokeinterface #42,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      12: ifne          19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifeq          92
      23: iload         4
      25: iload_3
      26: if_icmpge     92
      29: aload_1
      30: invokevirtual #83                 // Method java/util/Stack.pop:()Ljava/lang/Object;
      33: checkcast     #28                 // class java/lang/Integer
      36: astore        5
      38: aload_2
      39: aload         5
      41: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      44: aload         5
      46: invokevirtual #88                 // Method java/lang/Integer.intValue:()I
      49: iaload
      50: istore        6
      52: iload         4
      54: iload         6
      56: iadd
      57: iload_3
      58: if_icmple     82
      61: aload_2
      62: aload         5
      64: invokevirtual #88                 // Method java/lang/Integer.intValue:()I
      67: iload         4
      69: iload         6
      71: iadd
      72: iload_3
      73: isub
      74: iastore
      75: aload_1
      76: aload         5
      78: invokevirtual #36                 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
      81: pop
      82: iload         4
      84: iload         6
      86: iadd
      87: istore        4
      89: goto          3
      92: return

  private final java.lang.Integer peek(java.util.Stack<java.lang.Integer>);
    Code:
       0: aload_1
       1: checkcast     #38                 // class java/util/Collection
       4: invokeinterface #42,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
       9: ifne          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifeq          30
      20: aload_1
      21: invokevirtual #96                 // Method java/util/Stack.peek:()Ljava/lang/Object;
      24: checkcast     #28                 // class java/lang/Integer
      27: goto          34
      30: iconst_m1
      31: invokestatic  #32                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: areturn
}