import kotlin.math.max

fun main() {

    fun part1(input: List<String>): Int {
        val visible = mutableSetOf<Coord2D>()
        val grid = input.map { line -> line.map { it.digitToInt() } }
        val lastX = grid.lastIndex
        val lastY = grid.first().lastIndex
        visible.addAll(grid.indices.map { Coord2D(it, 0) })
        visible.addAll(grid.indices.map { Coord2D(it, lastX) })
        visible.addAll(grid.first().indices.map { Coord2D(0, it) })
        visible.addAll(grid.last().indices.map { Coord2D(lastY, it) })

        var max: Int
        for (x in 1 until lastX) {
            max = -1

            for (y in grid[x].indices) {
                if (grid[x][y] > max) {
                    max = grid[x][y]
                    visible.add(Coord2D(x, y))
                }
                if (max == 9) break
            }
            max = -1
            for (y in grid[x].indices.reversed()) {
                if (grid[x][y] > max) {
                    max = grid[x][y]
                    visible.add(Coord2D(x, y))
                }
                if (max == 9) break
            }
        }
        for (y in 1 until lastY) {
            max = -1
            for (x in grid.indices) {
                if (grid[x][y] > max) {
                    max = grid[x][y]
                    visible.add(Coord2D(x, y))
                }
                if (max == 9) break
            }
            max = -1
            for (x in grid.indices.reversed()) {
                if (grid[x][y] > max) {
                    max = grid[x][y]
                    visible.add(Coord2D(x, y))
                }
                if (max == 9) break
            }
        }
        return visible.size
    }

    fun lowerIdxScore(grid: List<List<Int>>, a: Int, b: Int): Int {
        val height = grid[a][b]
        for (i in a - 1 downTo 0) {
            if (grid[i][b] >= height) return a - i
        }
        return a
    }

    fun scenicScore(grid: List<List<Int>>, x: Int, y: Int): Int {
        val height = grid[x][y]
        val scores = mutableListOf<Int>()
        var score = 0
        for (a in x - 1 downTo 0) {
            if (grid[a][y] >= height) {
                score = x - a
                break
            }
        }
        if (score > 0) scores.add(score)
        else scores.add(x)
        score = 0
        for (a in x + 1..grid.lastIndex) {
            if (grid[a][y] >= height) {
                score = a - x
                break
            }
        }
        if (score > 0) scores.add(score)
        else scores.add(grid.lastIndex - x)
        score = 0
        for (b in y - 1 downTo 0) {
            if (grid[x][b] >= height) {
                score = y - b
                break
            }
        }
        if (score > 0) scores.add(score)
        else scores.add(y)
        score = 0
        for (b in y + 1..grid[x].lastIndex) {
            if (grid[x][b] >= height) {
                score = b - y
                break
            }
        }
        if (score > 0) scores.add(score)
        else scores.add(grid[x].lastIndex - y)
        return scores.product()
    }

    fun part2(input: List<String>): Int {
        val grid = input.map { line -> line.map { it.digitToInt() } }
        var maxScore = 0
        grid.forEachIndexed { x, line ->
            line.indices.forEach { y ->
                val score = scenicScore(grid, x, y)
                maxScore = max(maxScore, score)
            }
        }
        return maxScore
    }

    val input = readInput("Day08")

    println(part1(input))
    println(part2(input))
}

Compiled from "Day08.kt"
public final class Day08Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day08
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: new           #43                 // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #46                 // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #48                 // class java/util/Set
      10: astore_1
      11: aload_0
      12: checkcast     #50                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: astore        5
      22: new           #52                 // class java/util/ArrayList
      25: dup
      26: aload_3
      27: bipush        10
      29: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #62                 // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          200
      62: aload         8
      64: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         6
      73: aload         9
      75: checkcast     #78                 // class java/lang/String
      78: astore        10
      80: astore        22
      82: iconst_0
      83: istore        11
      85: aload         10
      87: checkcast     #80                 // class java/lang/CharSequence
      90: astore        12
      92: iconst_0
      93: istore        13
      95: aload         12
      97: astore        14
      99: new           #52                 // class java/util/ArrayList
     102: dup
     103: aload         12
     105: invokeinterface #84,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     110: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     113: checkcast     #62                 // class java/util/Collection
     116: astore        15
     118: iconst_0
     119: istore        16
     121: iconst_0
     122: istore        17
     124: iload         17
     126: aload         14
     128: invokeinterface #84,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     133: if_icmpge     181
     136: aload         14
     138: iload         17
     140: invokeinterface #88,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     145: istore        18
     147: aload         15
     149: iload         18
     151: istore        19
     153: astore        20
     155: iconst_0
     156: istore        21
     158: iload         19
     160: invokestatic  #94                 // Method kotlin/text/CharsKt.digitToInt:(C)I
     163: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     166: aload         20
     168: swap
     169: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     174: pop
     175: iinc          17, 1
     178: goto          124
     181: aload         15
     183: checkcast     #106                // class java/util/List
     186: nop
     187: nop
     188: aload         22
     190: swap
     191: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: goto          52
     200: aload         6
     202: checkcast     #106                // class java/util/List
     205: nop
     206: astore_2
     207: aload_2
     208: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     211: istore_3
     212: aload_2
     213: invokestatic  #113                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     216: checkcast     #106                // class java/util/List
     219: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     222: istore        4
     224: aload_1
     225: aload_2
     226: checkcast     #62                 // class java/util/Collection
     229: invokestatic  #117                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     232: checkcast     #50                 // class java/lang/Iterable
     235: astore        5
     237: astore        22
     239: iconst_0
     240: istore        6
     242: aload         5
     244: astore        7
     246: new           #52                 // class java/util/ArrayList
     249: dup
     250: aload         5
     252: bipush        10
     254: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     257: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     260: checkcast     #62                 // class java/util/Collection
     263: astore        8
     265: iconst_0
     266: istore        9
     268: aload         7
     270: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     275: astore        10
     277: aload         10
     279: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     284: ifeq          330
     287: aload         10
     289: checkcast     #119                // class kotlin/collections/IntIterator
     292: invokevirtual #122                // Method kotlin/collections/IntIterator.nextInt:()I
     295: istore        11
     297: aload         8
     299: iload         11
     301: istore        12
     303: astore        23
     305: iconst_0
     306: istore        13
     308: new           #124                // class Coord2D
     311: dup
     312: iload         12
     314: iconst_0
     315: invokespecial #127                // Method Coord2D."<init>":(II)V
     318: aload         23
     320: swap
     321: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     326: pop
     327: goto          277
     330: aload         8
     332: checkcast     #106                // class java/util/List
     335: nop
     336: aload         22
     338: swap
     339: checkcast     #62                 // class java/util/Collection
     342: invokeinterface #131,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     347: pop
     348: aload_1
     349: aload_2
     350: checkcast     #62                 // class java/util/Collection
     353: invokestatic  #117                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     356: checkcast     #50                 // class java/lang/Iterable
     359: astore        5
     361: astore        22
     363: iconst_0
     364: istore        6
     366: aload         5
     368: astore        7
     370: new           #52                 // class java/util/ArrayList
     373: dup
     374: aload         5
     376: bipush        10
     378: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     381: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     384: checkcast     #62                 // class java/util/Collection
     387: astore        8
     389: iconst_0
     390: istore        9
     392: aload         7
     394: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     399: astore        10
     401: aload         10
     403: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     408: ifeq          454
     411: aload         10
     413: checkcast     #119                // class kotlin/collections/IntIterator
     416: invokevirtual #122                // Method kotlin/collections/IntIterator.nextInt:()I
     419: istore        11
     421: aload         8
     423: iload         11
     425: istore        12
     427: astore        23
     429: iconst_0
     430: istore        13
     432: new           #124                // class Coord2D
     435: dup
     436: iload         12
     438: iload_3
     439: invokespecial #127                // Method Coord2D."<init>":(II)V
     442: aload         23
     444: swap
     445: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     450: pop
     451: goto          401
     454: aload         8
     456: checkcast     #106                // class java/util/List
     459: nop
     460: aload         22
     462: swap
     463: checkcast     #62                 // class java/util/Collection
     466: invokeinterface #131,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     471: pop
     472: aload_1
     473: aload_2
     474: invokestatic  #113                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     477: checkcast     #62                 // class java/util/Collection
     480: invokestatic  #117                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     483: checkcast     #50                 // class java/lang/Iterable
     486: astore        5
     488: astore        22
     490: iconst_0
     491: istore        6
     493: aload         5
     495: astore        7
     497: new           #52                 // class java/util/ArrayList
     500: dup
     501: aload         5
     503: bipush        10
     505: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     508: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     511: checkcast     #62                 // class java/util/Collection
     514: astore        8
     516: iconst_0
     517: istore        9
     519: aload         7
     521: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     526: astore        10
     528: aload         10
     530: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     535: ifeq          581
     538: aload         10
     540: checkcast     #119                // class kotlin/collections/IntIterator
     543: invokevirtual #122                // Method kotlin/collections/IntIterator.nextInt:()I
     546: istore        11
     548: aload         8
     550: iload         11
     552: istore        12
     554: astore        23
     556: iconst_0
     557: istore        13
     559: new           #124                // class Coord2D
     562: dup
     563: iconst_0
     564: iload         12
     566: invokespecial #127                // Method Coord2D."<init>":(II)V
     569: aload         23
     571: swap
     572: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     577: pop
     578: goto          528
     581: aload         8
     583: checkcast     #106                // class java/util/List
     586: nop
     587: aload         22
     589: swap
     590: checkcast     #62                 // class java/util/Collection
     593: invokeinterface #131,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     598: pop
     599: aload_1
     600: aload_2
     601: invokestatic  #134                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     604: checkcast     #62                 // class java/util/Collection
     607: invokestatic  #117                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     610: checkcast     #50                 // class java/lang/Iterable
     613: astore        5
     615: astore        22
     617: iconst_0
     618: istore        6
     620: aload         5
     622: astore        7
     624: new           #52                 // class java/util/ArrayList
     627: dup
     628: aload         5
     630: bipush        10
     632: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     635: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     638: checkcast     #62                 // class java/util/Collection
     641: astore        8
     643: iconst_0
     644: istore        9
     646: aload         7
     648: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     653: astore        10
     655: aload         10
     657: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     662: ifeq          709
     665: aload         10
     667: checkcast     #119                // class kotlin/collections/IntIterator
     670: invokevirtual #122                // Method kotlin/collections/IntIterator.nextInt:()I
     673: istore        11
     675: aload         8
     677: iload         11
     679: istore        12
     681: astore        23
     683: iconst_0
     684: istore        13
     686: new           #124                // class Coord2D
     689: dup
     690: iload         4
     692: iload         12
     694: invokespecial #127                // Method Coord2D."<init>":(II)V
     697: aload         23
     699: swap
     700: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     705: pop
     706: goto          655
     709: aload         8
     711: checkcast     #106                // class java/util/List
     714: nop
     715: aload         22
     717: swap
     718: checkcast     #62                 // class java/util/Collection
     721: invokeinterface #131,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     726: pop
     727: iconst_0
     728: istore        5
     730: iconst_1
     731: istore        6
     733: iload         6
     735: iload_3
     736: if_icmpge     984
     739: iconst_m1
     740: istore        5
     742: iconst_0
     743: istore        7
     745: aload_2
     746: iload         6
     748: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     753: checkcast     #62                 // class java/util/Collection
     756: invokeinterface #141,  1          // InterfaceMethod java/util/Collection.size:()I
     761: istore        8
     763: iload         7
     765: iload         8
     767: if_icmpge     856
     770: aload_2
     771: iload         6
     773: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     778: checkcast     #106                // class java/util/List
     781: iload         7
     783: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     788: checkcast     #143                // class java/lang/Number
     791: invokevirtual #146                // Method java/lang/Number.intValue:()I
     794: iload         5
     796: if_icmple     843
     799: aload_2
     800: iload         6
     802: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     807: checkcast     #106                // class java/util/List
     810: iload         7
     812: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     817: checkcast     #143                // class java/lang/Number
     820: invokevirtual #146                // Method java/lang/Number.intValue:()I
     823: istore        5
     825: aload_1
     826: new           #124                // class Coord2D
     829: dup
     830: iload         6
     832: iload         7
     834: invokespecial #127                // Method Coord2D."<init>":(II)V
     837: invokeinterface #147,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     842: pop
     843: iload         5
     845: bipush        9
     847: if_icmpeq     856
     850: iinc          7, 1
     853: goto          763
     856: iconst_m1
     857: istore        5
     859: aload_2
     860: iload         6
     862: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     867: checkcast     #62                 // class java/util/Collection
     870: invokeinterface #141,  1          // InterfaceMethod java/util/Collection.size:()I
     875: iconst_m1
     876: iadd
     877: istore        7
     879: iconst_0
     880: iload         7
     882: if_icmpgt     978
     885: iload         7
     887: istore        8
     889: iinc          7, -1
     892: aload_2
     893: iload         6
     895: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     900: checkcast     #106                // class java/util/List
     903: iload         8
     905: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     910: checkcast     #143                // class java/lang/Number
     913: invokevirtual #146                // Method java/lang/Number.intValue:()I
     916: iload         5
     918: if_icmple     965
     921: aload_2
     922: iload         6
     924: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     929: checkcast     #106                // class java/util/List
     932: iload         8
     934: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     939: checkcast     #143                // class java/lang/Number
     942: invokevirtual #146                // Method java/lang/Number.intValue:()I
     945: istore        5
     947: aload_1
     948: new           #124                // class Coord2D
     951: dup
     952: iload         6
     954: iload         8
     956: invokespecial #127                // Method Coord2D."<init>":(II)V
     959: invokeinterface #147,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     964: pop
     965: iload         5
     967: bipush        9
     969: if_icmpeq     978
     972: iconst_0
     973: iload         7
     975: if_icmple     885
     978: iinc          6, 1
     981: goto          733
     984: iconst_1
     985: istore        6
     987: iload         6
     989: iload         4
     991: if_icmpge     1225
     994: iconst_m1
     995: istore        5
     997: iconst_0
     998: istore        7
    1000: aload_2
    1001: checkcast     #62                 // class java/util/Collection
    1004: invokeinterface #141,  1          // InterfaceMethod java/util/Collection.size:()I
    1009: istore        8
    1011: iload         7
    1013: iload         8
    1015: if_icmpge     1104
    1018: aload_2
    1019: iload         7
    1021: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1026: checkcast     #106                // class java/util/List
    1029: iload         6
    1031: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1036: checkcast     #143                // class java/lang/Number
    1039: invokevirtual #146                // Method java/lang/Number.intValue:()I
    1042: iload         5
    1044: if_icmple     1091
    1047: aload_2
    1048: iload         7
    1050: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1055: checkcast     #106                // class java/util/List
    1058: iload         6
    1060: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1065: checkcast     #143                // class java/lang/Number
    1068: invokevirtual #146                // Method java/lang/Number.intValue:()I
    1071: istore        5
    1073: aload_1
    1074: new           #124                // class Coord2D
    1077: dup
    1078: iload         7
    1080: iload         6
    1082: invokespecial #127                // Method Coord2D."<init>":(II)V
    1085: invokeinterface #147,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
    1090: pop
    1091: iload         5
    1093: bipush        9
    1095: if_icmpeq     1104
    1098: iinc          7, 1
    1101: goto          1011
    1104: iconst_m1
    1105: istore        5
    1107: aload_2
    1108: checkcast     #62                 // class java/util/Collection
    1111: invokeinterface #141,  1          // InterfaceMethod java/util/Collection.size:()I
    1116: iconst_m1
    1117: iadd
    1118: istore        7
    1120: iconst_0
    1121: iload         7
    1123: if_icmpgt     1219
    1126: iload         7
    1128: istore        8
    1130: iinc          7, -1
    1133: aload_2
    1134: iload         8
    1136: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1141: checkcast     #106                // class java/util/List
    1144: iload         6
    1146: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1151: checkcast     #143                // class java/lang/Number
    1154: invokevirtual #146                // Method java/lang/Number.intValue:()I
    1157: iload         5
    1159: if_icmple     1206
    1162: aload_2
    1163: iload         8
    1165: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1170: checkcast     #106                // class java/util/List
    1173: iload         6
    1175: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1180: checkcast     #143                // class java/lang/Number
    1183: invokevirtual #146                // Method java/lang/Number.intValue:()I
    1186: istore        5
    1188: aload_1
    1189: new           #124                // class Coord2D
    1192: dup
    1193: iload         8
    1195: iload         6
    1197: invokespecial #127                // Method Coord2D."<init>":(II)V
    1200: invokeinterface #147,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
    1205: pop
    1206: iload         5
    1208: bipush        9
    1210: if_icmpeq     1219
    1213: iconst_0
    1214: iload         7
    1216: if_icmple     1126
    1219: iinc          6, 1
    1222: goto          987
    1225: aload_1
    1226: invokeinterface #148,  1          // InterfaceMethod java/util/Set.size:()I
    1231: ireturn

  private static final int main$lowerIdxScore(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #106                // class java/util/List
      10: iload_2
      11: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #143                // class java/lang/Number
      19: invokevirtual #146                // Method java/lang/Number.intValue:()I
      22: istore_3
      23: iload_1
      24: iconst_1
      25: isub
      26: istore        4
      28: iconst_m1
      29: iload         4
      31: if_icmpge     72
      34: aload_0
      35: iload         4
      37: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #106                // class java/util/List
      45: iload_2
      46: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      51: checkcast     #143                // class java/lang/Number
      54: invokevirtual #146                // Method java/lang/Number.intValue:()I
      57: iload_3
      58: if_icmplt     66
      61: iload_1
      62: iload         4
      64: isub
      65: ireturn
      66: iinc          4, -1
      69: goto          28
      72: iload_1
      73: ireturn

  private static final int main$scenicScore(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #106                // class java/util/List
      10: iload_2
      11: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #143                // class java/lang/Number
      19: invokevirtual #146                // Method java/lang/Number.intValue:()I
      22: istore_3
      23: new           #52                 // class java/util/ArrayList
      26: dup
      27: invokespecial #186                // Method java/util/ArrayList."<init>":()V
      30: checkcast     #106                // class java/util/List
      33: astore        4
      35: iconst_0
      36: istore        5
      38: iload_1
      39: iconst_1
      40: isub
      41: istore        6
      43: iconst_m1
      44: iload         6
      46: if_icmpge     91
      49: aload_0
      50: iload         6
      52: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      57: checkcast     #106                // class java/util/List
      60: iload_2
      61: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      66: checkcast     #143                // class java/lang/Number
      69: invokevirtual #146                // Method java/lang/Number.intValue:()I
      72: iload_3
      73: if_icmplt     85
      76: iload_1
      77: iload         6
      79: isub
      80: istore        5
      82: goto          91
      85: iinc          6, -1
      88: goto          43
      91: iload         5
      93: ifle          111
      96: aload         4
      98: iload         5
     100: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     108: goto          122
     111: aload         4
     113: iload_1
     114: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     117: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     122: pop
     123: iconst_0
     124: istore        5
     126: iload_1
     127: iconst_1
     128: iadd
     129: istore        6
     131: aload_0
     132: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     135: istore        7
     137: iload         6
     139: iload         7
     141: if_icmpgt     193
     144: aload_0
     145: iload         6
     147: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     152: checkcast     #106                // class java/util/List
     155: iload_2
     156: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     161: checkcast     #143                // class java/lang/Number
     164: invokevirtual #146                // Method java/lang/Number.intValue:()I
     167: iload_3
     168: if_icmplt     180
     171: iload         6
     173: iload_1
     174: isub
     175: istore        5
     177: goto          193
     180: iload         6
     182: iload         7
     184: if_icmpeq     193
     187: iinc          6, 1
     190: goto          144
     193: iload         5
     195: ifle          213
     198: aload         4
     200: iload         5
     202: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     205: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     210: goto          229
     213: aload         4
     215: aload_0
     216: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     219: iload_1
     220: isub
     221: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     224: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     229: pop
     230: iconst_0
     231: istore        5
     233: iload_2
     234: iconst_1
     235: isub
     236: istore        6
     238: iconst_m1
     239: iload         6
     241: if_icmpge     286
     244: aload_0
     245: iload_1
     246: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     251: checkcast     #106                // class java/util/List
     254: iload         6
     256: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     261: checkcast     #143                // class java/lang/Number
     264: invokevirtual #146                // Method java/lang/Number.intValue:()I
     267: iload_3
     268: if_icmplt     280
     271: iload_2
     272: iload         6
     274: isub
     275: istore        5
     277: goto          286
     280: iinc          6, -1
     283: goto          238
     286: iload         5
     288: ifle          306
     291: aload         4
     293: iload         5
     295: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     298: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     303: goto          317
     306: aload         4
     308: iload_2
     309: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     312: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     317: pop
     318: iconst_0
     319: istore        5
     321: iload_2
     322: iconst_1
     323: iadd
     324: istore        6
     326: aload_0
     327: iload_1
     328: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     333: checkcast     #106                // class java/util/List
     336: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     339: istore        7
     341: iload         6
     343: iload         7
     345: if_icmpgt     397
     348: aload_0
     349: iload_1
     350: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     355: checkcast     #106                // class java/util/List
     358: iload         6
     360: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     365: checkcast     #143                // class java/lang/Number
     368: invokevirtual #146                // Method java/lang/Number.intValue:()I
     371: iload_3
     372: if_icmplt     384
     375: iload         6
     377: iload_2
     378: isub
     379: istore        5
     381: goto          397
     384: iload         6
     386: iload         7
     388: if_icmpeq     397
     391: iinc          6, 1
     394: goto          348
     397: iload         5
     399: ifle          417
     402: aload         4
     404: iload         5
     406: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     409: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     414: goto          442
     417: aload         4
     419: aload_0
     420: iload_1
     421: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     426: checkcast     #106                // class java/util/List
     429: invokestatic  #109                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     432: iload_2
     433: isub
     434: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     437: invokeinterface #187,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     442: pop
     443: aload         4
     445: invokestatic  #190                // Method UtilsKt.product:(Ljava/util/List;)I
     448: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #50                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #52                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #62                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          188
      50: aload         7
      52: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #78                 // class java/lang/String
      66: astore        9
      68: astore        21
      70: iconst_0
      71: istore        10
      73: aload         9
      75: checkcast     #80                 // class java/lang/CharSequence
      78: astore        11
      80: iconst_0
      81: istore        12
      83: aload         11
      85: astore        13
      87: new           #52                 // class java/util/ArrayList
      90: dup
      91: aload         11
      93: invokeinterface #84,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      98: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     101: checkcast     #62                 // class java/util/Collection
     104: astore        14
     106: iconst_0
     107: istore        15
     109: iconst_0
     110: istore        16
     112: iload         16
     114: aload         13
     116: invokeinterface #84,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     121: if_icmpge     169
     124: aload         13
     126: iload         16
     128: invokeinterface #88,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     133: istore        17
     135: aload         14
     137: iload         17
     139: istore        18
     141: astore        19
     143: iconst_0
     144: istore        20
     146: iload         18
     148: invokestatic  #94                 // Method kotlin/text/CharsKt.digitToInt:(C)I
     151: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     154: aload         19
     156: swap
     157: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     162: pop
     163: iinc          16, 1
     166: goto          112
     169: aload         14
     171: checkcast     #106                // class java/util/List
     174: nop
     175: nop
     176: aload         21
     178: swap
     179: invokeinterface #104,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     184: pop
     185: goto          40
     188: aload         5
     190: checkcast     #106                // class java/util/List
     193: nop
     194: astore_1
     195: iconst_0
     196: istore_2
     197: aload_1
     198: checkcast     #50                 // class java/lang/Iterable
     201: astore_3
     202: iconst_0
     203: istore        4
     205: iconst_0
     206: istore        5
     208: aload_3
     209: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     214: astore        6
     216: aload         6
     218: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     223: ifeq          344
     226: aload         6
     228: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     233: astore        7
     235: iload         5
     237: iinc          5, 1
     240: istore        8
     242: iload         8
     244: ifge          250
     247: invokestatic  #195                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     250: iload         8
     252: aload         7
     254: checkcast     #106                // class java/util/List
     257: astore        9
     259: istore        10
     261: iconst_0
     262: istore        11
     264: aload         9
     266: checkcast     #62                 // class java/util/Collection
     269: invokestatic  #117                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     272: checkcast     #50                 // class java/lang/Iterable
     275: astore        12
     277: iconst_0
     278: istore        13
     280: aload         12
     282: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     287: astore        14
     289: aload         14
     291: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     296: ifeq          338
     299: aload         14
     301: checkcast     #119                // class kotlin/collections/IntIterator
     304: invokevirtual #122                // Method kotlin/collections/IntIterator.nextInt:()I
     307: istore        15
     309: iload         15
     311: istore        16
     313: iconst_0
     314: istore        17
     316: aload_1
     317: iload         10
     319: iload         16
     321: invokestatic  #197                // Method main$scenicScore:(Ljava/util/List;II)I
     324: istore        18
     326: iload_2
     327: iload         18
     329: invokestatic  #202                // Method java/lang/Math.max:(II)I
     332: istore_2
     333: nop
     334: nop
     335: goto          289
     338: nop
     339: nop
     340: nop
     341: goto          216
     344: nop
     345: iload_2
     346: ireturn
}


class NumberFraction(var numerator: Int, denominatorValue: Int){
    var denominator = denominatorValue
        set(value){
            require(value != 0){
                "The denominator must be different from 0"
            }
            field = value
        }
        init{
            require(denominatorValue != 0){
                "The denominator must be different from 0"
            }
        }
    fun product(number: NumberFraction): NumberFraction{
        val numberSecond = reduce(number)
        reduceCurrentFraction()
        return reduce(NumberFraction(numerator * numberSecond.numerator, denominator * numberSecond.denominator))
    }
    fun sum(number: NumberFraction): NumberFraction{
        val numberSecond = reduce(number)
        reduceCurrentFraction()
        return reduce(NumberFraction(numerator*numberSecond.denominator + numberSecond.numerator * denominator, denominator*numberSecond.denominator))
    }
    fun isEqual(number: NumberFraction): Boolean {
        val numberSecond = reduce(number)
        reduceCurrentFraction()
        return numerator == numberSecond.numerator && denominator == numberSecond.denominator
    }
    fun isPositive() = (denominator * numerator >= 0)
    fun calculateGCD(numberFirst: Int, numberSecond: Int): Int {
        require(numberSecond != 0){
            "The number must be positive"
        }
        var numberFirst1 = numberFirst
        var numberSecond1 = numberSecond
        var numberMaximum = if(numberFirst > numberSecond) numberFirst else numberSecond
        var gcd = 1
        for(i in 2..numberMaximum){
            if(numberFirst1 == 1 && numberSecond1 == 1){
                break
            }
            while(numberFirst1%i == 0 && numberSecond1%i == 0){
                gcd *= i
                numberFirst1 /= i
                numberSecond1 /= i
            }
        }
        return gcd
    }
    fun reduce(numberFraction: NumberFraction): NumberFraction{
        val gcd = calculateGCD(numberFraction.numerator, numberFraction.denominator)
        numberFraction.numerator /= gcd
        numberFraction.denominator /= gcd
        return numberFraction
    }
    fun reduceCurrentFraction(){
        val gcd = calculateGCD(numerator, denominator)
        numerator /= gcd
        denominator /= gcd
    }
}

Compiled from "numberFraction.kt"
public final class NumberFraction {
  private int numerator;

  private int denominator;

  public NumberFraction(int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field numerator:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field denominator:I
      14: nop
      15: iload_2
      16: ifeq          23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: ifne          44
      27: iconst_0
      28: istore_3
      29: ldc           #18                 // String The denominator must be different from 0
      31: astore_3
      32: new           #20                 // class java/lang/IllegalArgumentException
      35: dup
      36: aload_3
      37: invokevirtual #24                 // Method java/lang/Object.toString:()Ljava/lang/String;
      40: invokespecial #27                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      43: athrow
      44: nop
      45: return

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

  public final void setNumerator(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #13                 // Field numerator:I
       5: return

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

  public final void setDenominator(int);
    Code:
       0: iload_1
       1: ifeq          8
       4: iconst_1
       5: goto          9
       8: iconst_0
       9: ifne          29
      12: iconst_0
      13: istore_2
      14: ldc           #18                 // String The denominator must be different from 0
      16: astore_2
      17: new           #20                 // class java/lang/IllegalArgumentException
      20: dup
      21: aload_2
      22: invokevirtual #24                 // Method java/lang/Object.toString:()Ljava/lang/String;
      25: invokespecial #27                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      28: athrow
      29: aload_0
      30: iload_1
      31: putfield      #16                 // Field denominator:I
      34: return

  public final NumberFraction product(NumberFraction);
    Code:
       0: aload_1
       1: ldc           #45                 // String number
       3: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokevirtual #54                 // Method reduce:(LNumberFraction;)LNumberFraction;
      11: astore_2
      12: aload_0
      13: invokevirtual #57                 // Method reduceCurrentFraction:()V
      16: aload_0
      17: new           #2                  // class NumberFraction
      20: dup
      21: aload_0
      22: getfield      #13                 // Field numerator:I
      25: aload_2
      26: getfield      #13                 // Field numerator:I
      29: imul
      30: aload_0
      31: getfield      #16                 // Field denominator:I
      34: aload_2
      35: getfield      #16                 // Field denominator:I
      38: imul
      39: invokespecial #59                 // Method "<init>":(II)V
      42: invokevirtual #54                 // Method reduce:(LNumberFraction;)LNumberFraction;
      45: areturn

  public final NumberFraction sum(NumberFraction);
    Code:
       0: aload_1
       1: ldc           #45                 // String number
       3: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokevirtual #54                 // Method reduce:(LNumberFraction;)LNumberFraction;
      11: astore_2
      12: aload_0
      13: invokevirtual #57                 // Method reduceCurrentFraction:()V
      16: aload_0
      17: new           #2                  // class NumberFraction
      20: dup
      21: aload_0
      22: getfield      #13                 // Field numerator:I
      25: aload_2
      26: getfield      #16                 // Field denominator:I
      29: imul
      30: aload_2
      31: getfield      #13                 // Field numerator:I
      34: aload_0
      35: getfield      #16                 // Field denominator:I
      38: imul
      39: iadd
      40: aload_0
      41: getfield      #16                 // Field denominator:I
      44: aload_2
      45: getfield      #16                 // Field denominator:I
      48: imul
      49: invokespecial #59                 // Method "<init>":(II)V
      52: invokevirtual #54                 // Method reduce:(LNumberFraction;)LNumberFraction;
      55: areturn

  public final boolean isEqual(NumberFraction);
    Code:
       0: aload_1
       1: ldc           #45                 // String number
       3: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokevirtual #54                 // Method reduce:(LNumberFraction;)LNumberFraction;
      11: astore_2
      12: aload_0
      13: invokevirtual #57                 // Method reduceCurrentFraction:()V
      16: aload_0
      17: getfield      #13                 // Field numerator:I
      20: aload_2
      21: getfield      #13                 // Field numerator:I
      24: if_icmpne     42
      27: aload_0
      28: getfield      #16                 // Field denominator:I
      31: aload_2
      32: getfield      #16                 // Field denominator:I
      35: if_icmpne     42
      38: iconst_1
      39: goto          43
      42: iconst_0
      43: ireturn

  public final boolean isPositive();
    Code:
       0: aload_0
       1: getfield      #16                 // Field denominator:I
       4: aload_0
       5: getfield      #13                 // Field numerator:I
       8: imul
       9: iflt          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ireturn

  public final int calculateGCD(int, int);
    Code:
       0: iload_2
       1: ifeq          8
       4: iconst_1
       5: goto          9
       8: iconst_0
       9: ifne          32
      12: iconst_0
      13: istore        4
      15: ldc           #69                 // String The number must be positive
      17: astore        4
      19: new           #20                 // class java/lang/IllegalArgumentException
      22: dup
      23: aload         4
      25: invokevirtual #24                 // Method java/lang/Object.toString:()Ljava/lang/String;
      28: invokespecial #27                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      31: athrow
      32: iload_1
      33: istore_3
      34: iload_2
      35: istore        4
      37: iload_1
      38: iload_2
      39: if_icmple     46
      42: iload_1
      43: goto          47
      46: iload_2
      47: istore        5
      49: iconst_1
      50: istore        6
      52: iconst_2
      53: istore        7
      55: iload         5
      57: istore        8
      59: iload         7
      61: iload         8
      63: if_icmpgt     130
      66: iload_3
      67: iconst_1
      68: if_icmpne     80
      71: iload         4
      73: iconst_1
      74: if_icmpne     80
      77: goto          130
      80: iload_3
      81: iload         7
      83: irem
      84: ifne          117
      87: iload         4
      89: iload         7
      91: irem
      92: ifne          117
      95: iload         6
      97: iload         7
      99: imul
     100: istore        6
     102: iload_3
     103: iload         7
     105: idiv
     106: istore_3
     107: iload         4
     109: iload         7
     111: idiv
     112: istore        4
     114: goto          80
     117: iload         7
     119: iload         8
     121: if_icmpeq     130
     124: iinc          7, 1
     127: goto          66
     130: iload         6
     132: ireturn

  public final NumberFraction reduce(NumberFraction);
    Code:
       0: aload_1
       1: ldc           #78                 // String numberFraction
       3: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: getfield      #13                 // Field numerator:I
      11: aload_1
      12: getfield      #16                 // Field denominator:I
      15: invokevirtual #80                 // Method calculateGCD:(II)I
      18: istore_2
      19: aload_1
      20: aload_1
      21: getfield      #13                 // Field numerator:I
      24: iload_2
      25: idiv
      26: putfield      #13                 // Field numerator:I
      29: aload_1
      30: aload_1
      31: getfield      #16                 // Field denominator:I
      34: iload_2
      35: idiv
      36: invokevirtual #82                 // Method setDenominator:(I)V
      39: aload_1
      40: areturn

  public final void reduceCurrentFraction();
    Code:
       0: aload_0
       1: aload_0
       2: getfield      #13                 // Field numerator:I
       5: aload_0
       6: getfield      #16                 // Field denominator:I
       9: invokevirtual #80                 // Method calculateGCD:(II)I
      12: istore_1
      13: aload_0
      14: aload_0
      15: getfield      #13                 // Field numerator:I
      18: iload_1
      19: idiv
      20: putfield      #13                 // Field numerator:I
      23: aload_0
      24: aload_0
      25: getfield      #16                 // Field denominator:I
      28: iload_1
      29: idiv
      30: invokevirtual #82                 // Method setDenominator:(I)V
      33: return
}


import kotlin.math.*

class SegmentTree(array: Array<Int>){
    private var segment = Array<Int>(0){ 0 }
    private var size = 0
    private var sizeOfInitialArray = 0

    init{
        size = 1 shl ceil(log2(array.size.toFloat())).toInt()
        sizeOfInitialArray = array.size
        segment = Array(size * 2){ 0 }
        for(i in array.indices){
            segment[i + size] = array[i]
        }
        for(i in size-1 downTo 1){
            segment[i] = segment[i * 2]+segment[i * 2 + 1]
        }
    }

    private fun privateGetSum(node: Int, nodeRangeLeft: Int, nodeRangeRight: Int, queryRangeLeft: Int, queryRangeRight: Int): Int{ // the query range is [queryRangeLeft, queryRangeRight)
        if(queryRangeLeft >= nodeRangeRight || queryRangeRight <= nodeRangeLeft){
            return 0
        }
        if(nodeRangeLeft >= queryRangeLeft && nodeRangeRight <= queryRangeRight){
            return segment[node]
        }
        val left = privateGetSum(node * 2, nodeRangeLeft, (nodeRangeLeft + nodeRangeRight) / 2, queryRangeLeft, queryRangeRight)
        val right = privateGetSum(node * 2 + 1, (nodeRangeLeft + nodeRangeRight) / 2, nodeRangeRight, queryRangeLeft ,queryRangeRight)
        return left + right
    }
    private fun privateUpdate(nodePosition: Int, value: Int){
        var node = nodePosition + size
        segment[node] = value
        node /= 2
        while(node > 0){
            segment[node] = segment[node * 2] + segment[node * 2 + 1]
            node /= 2
        }
    }
    private fun check(){
        for(i in segment.indices){
            print(segment[i].toString() + " ")
        }
        println("")
    }
    fun getSum(queryLeft: Int, queryRight: Int): Int{
        require(queryLeft >= 0 && queryLeft < segment.size){
            "Left end is not correct, it must be greater than -1 and less than the size of the segment size"
        }
        require(queryRight >= 0 && queryRight <= segment.size){
            "Right end is not correct, it must be greater than -1 and less than the size of the segment size"
        }
        require(queryLeft <= queryRight){
            "The right end must be greater or equal to the left end"
        }
        return privateGetSum(1, 1, size, queryLeft, queryRight)
    }
    fun update(nodePosition: Int, value: Int){
        require(nodePosition in 0 until sizeOfInitialArray){
            "The node isn't in the segment tree"
        }
        privateUpdate(nodePosition, value)
        check()
    }
}

fun main(){
    val arr = arrayOf(2, 4, 2, 1, 3, 4, 5)
    val seg = SegmentTree(arr)
    print(seg.getSum(0, 4))
    //seg.update(3, 4)
}

Compiled from "segtree.kt"
public final class SegtreeKt {
  public static final void main();
    Code:
       0: bipush        7
       2: anewarray     #8                  // class java/lang/Integer
       5: astore_1
       6: aload_1
       7: iconst_0
       8: iconst_2
       9: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: aastore
      13: aload_1
      14: iconst_1
      15: iconst_4
      16: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: aastore
      20: aload_1
      21: iconst_2
      22: iconst_2
      23: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: aastore
      27: aload_1
      28: iconst_3
      29: iconst_1
      30: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload_1
      35: iconst_4
      36: iconst_3
      37: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      40: aastore
      41: aload_1
      42: iconst_5
      43: iconst_4
      44: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      47: aastore
      48: aload_1
      49: bipush        6
      51: iconst_5
      52: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      55: aastore
      56: aload_1
      57: astore_0
      58: new           #14                 // class SegmentTree
      61: dup
      62: aload_0
      63: invokespecial #18                 // Method SegmentTree."<init>":([Ljava/lang/Integer;)V
      66: astore_1
      67: aload_1
      68: iconst_0
      69: iconst_4
      70: invokevirtual #22                 // Method SegmentTree.getSum:(II)I
      73: istore_2
      74: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: iload_2
      78: invokevirtual #34                 // Method java/io/PrintStream.print:(I)V
      81: return

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


fun main() {
    println(
        repeatedIntersection(intArrayOf(3, 6, 7, 8, 7, 9), mutableListOf(12, 6, 7, 6, 7, 565))
    )
    println(countLetters("AAGGDDDFBBBAAABB"))
    println(groupWords(arrayOf("ate", "tdb", "eat", "ref", "fer", "test")))
}

fun repeatedIntersection(array1: IntArray, array2: MutableList<Int>): List<Int> {
    return array1
        .filter { e ->
            array2.remove(e)
        }
}

fun countLetters(input: String): String {
    var i = 0
    var count = 0
    var result = ""
    for (letter in input) {
        count++
        i++
        if (i < input.length && letter == input[i]) {
            continue
        }
        result += "${input[i - 1]}$count"
        count = 0
    }
    return result
}

fun groupWords(words: Array<String>): List<List<String>> {
    val map: MutableMap<String, MutableList<String>> = HashMap()
    for (word in words) {
        val sum: String = word.toCharArray().sorted().joinToString()
        map.getOrPut(sum) { mutableListOf() }
            .add(word)
    }
    return map.values.toList()
}

Compiled from "Tasks.kt"
public final class TasksKt {
  public static final void main();
    Code:
       0: bipush        6
       2: newarray       int
       4: astore_0
       5: aload_0
       6: iconst_0
       7: iconst_3
       8: iastore
       9: aload_0
      10: iconst_1
      11: bipush        6
      13: iastore
      14: aload_0
      15: iconst_2
      16: bipush        7
      18: iastore
      19: aload_0
      20: iconst_3
      21: bipush        8
      23: iastore
      24: aload_0
      25: iconst_4
      26: bipush        7
      28: iastore
      29: aload_0
      30: iconst_5
      31: bipush        9
      33: iastore
      34: aload_0
      35: bipush        6
      37: anewarray     #8                  // class java/lang/Integer
      40: astore_0
      41: aload_0
      42: iconst_0
      43: bipush        12
      45: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: aastore
      49: aload_0
      50: iconst_1
      51: bipush        6
      53: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      56: aastore
      57: aload_0
      58: iconst_2
      59: bipush        7
      61: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      64: aastore
      65: aload_0
      66: iconst_3
      67: bipush        6
      69: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: aastore
      73: aload_0
      74: iconst_4
      75: bipush        7
      77: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aastore
      81: aload_0
      82: iconst_5
      83: sipush        565
      86: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: aastore
      90: aload_0
      91: invokestatic  #18                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      94: invokestatic  #22                 // Method repeatedIntersection:([ILjava/util/List;)Ljava/util/List;
      97: astore_0
      98: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     101: aload_0
     102: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     105: ldc           #36                 // String AAGGDDDFBBBAAABB
     107: invokestatic  #40                 // Method countLetters:(Ljava/lang/String;)Ljava/lang/String;
     110: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     113: swap
     114: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     117: bipush        6
     119: anewarray     #42                 // class java/lang/String
     122: astore_0
     123: aload_0
     124: iconst_0
     125: ldc           #44                 // String ate
     127: aastore
     128: aload_0
     129: iconst_1
     130: ldc           #46                 // String tdb
     132: aastore
     133: aload_0
     134: iconst_2
     135: ldc           #48                 // String eat
     137: aastore
     138: aload_0
     139: iconst_3
     140: ldc           #50                 // String ref
     142: aastore
     143: aload_0
     144: iconst_4
     145: ldc           #52                 // String fer
     147: aastore
     148: aload_0
     149: iconst_5
     150: ldc           #54                 // String test
     152: aastore
     153: aload_0
     154: invokestatic  #58                 // Method groupWords:([Ljava/lang/String;)Ljava/util/List;
     157: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     160: swap
     161: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     164: return

  public static final java.util.List<java.lang.Integer> repeatedIntersection(int[], java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #62                 // String array1
       3: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #70                 // String array2
       9: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: nop
      15: iconst_0
      16: istore_3
      17: aload_2
      18: astore        4
      20: new           #72                 // class java/util/ArrayList
      23: dup
      24: invokespecial #75                 // Method java/util/ArrayList."<init>":()V
      27: checkcast     #77                 // class java/util/Collection
      30: astore        5
      32: iconst_0
      33: istore        6
      35: iconst_0
      36: istore        7
      38: aload         4
      40: arraylength
      41: istore        8
      43: iload         7
      45: iload         8
      47: if_icmpge     97
      50: aload         4
      52: iload         7
      54: iaload
      55: istore        9
      57: iload         9
      59: istore        10
      61: iconst_0
      62: istore        11
      64: aload_1
      65: iload         10
      67: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      70: invokeinterface #83,  2           // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z
      75: ifeq          91
      78: aload         5
      80: iload         9
      82: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      85: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: iinc          7, 1
      94: goto          43
      97: aload         5
      99: checkcast     #79                 // class java/util/List
     102: nop
     103: areturn

  public static final java.lang.String countLetters(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #101                // String input
       3: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iconst_0
       9: istore_2
      10: ldc           #103                // String
      12: astore_3
      13: iconst_0
      14: istore        4
      16: aload_0
      17: invokevirtual #107                // Method java/lang/String.length:()I
      20: istore        5
      22: iload         4
      24: iload         5
      26: if_icmpge     101
      29: aload_0
      30: iload         4
      32: invokevirtual #111                // Method java/lang/String.charAt:(I)C
      35: istore        6
      37: iinc          2, 1
      40: iinc          1, 1
      43: iload_1
      44: aload_0
      45: invokevirtual #107                // Method java/lang/String.length:()I
      48: if_icmpge     64
      51: iload         6
      53: aload_0
      54: iload_1
      55: invokevirtual #111                // Method java/lang/String.charAt:(I)C
      58: if_icmpne     64
      61: goto          95
      64: new           #113                // class java/lang/StringBuilder
      67: dup
      68: invokespecial #114                // Method java/lang/StringBuilder."<init>":()V
      71: aload_3
      72: invokevirtual #118                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      75: aload_0
      76: iload_1
      77: iconst_1
      78: isub
      79: invokevirtual #111                // Method java/lang/String.charAt:(I)C
      82: invokevirtual #121                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      85: iload_2
      86: invokevirtual #124                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      89: invokevirtual #128                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      92: astore_3
      93: iconst_0
      94: istore_2
      95: iinc          4, 1
      98: goto          22
     101: aload_3
     102: areturn

  public static final java.util.List<java.util.List<java.lang.String>> groupWords(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #137                // String words
       3: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #139                // class java/util/HashMap
       9: dup
      10: invokespecial #140                // Method java/util/HashMap."<init>":()V
      13: checkcast     #142                // class java/util/Map
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_0
      20: arraylength
      21: istore_3
      22: iload_2
      23: iload_3
      24: if_icmpge     138
      27: aload_0
      28: iload_2
      29: aaload
      30: astore        4
      32: aload         4
      34: invokevirtual #146                // Method java/lang/String.toCharArray:()[C
      37: dup
      38: ldc           #148                // String toCharArray(...)
      40: invokestatic  #151                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      43: invokestatic  #157                // Method kotlin/collections/ArraysKt.sorted:([C)Ljava/util/List;
      46: checkcast     #159                // class java/lang/Iterable
      49: aconst_null
      50: aconst_null
      51: aconst_null
      52: iconst_0
      53: aconst_null
      54: aconst_null
      55: bipush        63
      57: aconst_null
      58: invokestatic  #163                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      61: astore        5
      63: aload_1
      64: astore        6
      66: iconst_0
      67: istore        7
      69: aload         6
      71: aload         5
      73: invokeinterface #167,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      78: astore        8
      80: aload         8
      82: ifnonnull     118
      85: iconst_0
      86: istore        9
      88: new           #72                 // class java/util/ArrayList
      91: dup
      92: invokespecial #75                 // Method java/util/ArrayList."<init>":()V
      95: checkcast     #79                 // class java/util/List
      98: nop
      99: astore        9
     101: aload         6
     103: aload         5
     105: aload         9
     107: invokeinterface #171,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     112: pop
     113: aload         9
     115: goto          120
     118: aload         8
     120: nop
     121: checkcast     #79                 // class java/util/List
     124: aload         4
     126: invokeinterface #172,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     131: pop
     132: iinc          2, 1
     135: goto          22
     138: aload_1
     139: invokeinterface #176,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     144: checkcast     #159                // class java/lang/Iterable
     147: invokestatic  #180                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     150: areturn

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


/**
 *  Programmieraufgabe:
 *
 *  Kamele beladen
 *  https://www.programmieraufgaben.ch/aufgabe/kamele-beladen/6gddr4zm
 *
 *  Ein Kamel soll optimal beladen werden. Das Kamel kann maximal 270 kg tragen.
 *  Aktuell sind Waren mit den folgenden Gewichten zu transportieren: 5, 18, 32,
 *  34, 45, 57, 63, 69, 94, 98 und 121 kg. Nicht alle Gewichte müssen verwendet
 *  werden; die 270 kg sollen aber möglichst gut, wenn nicht sogar ganz ohne
 *  Rest beladen werden. Die Funktion
 *  beladeOptimal(kapazitaet: integer, vorrat: integer[]): integer[]
 *  erhält die maximal tragbare Last (kapazitaet) und eine Menge von
 *  aufzuteilenden Gewichten (vorrat). Das Resultat (hier integer[]) ist die
 *  Auswahl aus dem Vorrat, die der Belastbarkeit möglichst nahe kommt. Gehen
 *  Sie wie folgt rekursiv vor: Für jedes vorhandene Gewicht g aus dem Vorrat
 *  soll das Problem vereinfacht werden. Dazu wird dieses Gewicht probehalber
 *  aufgeladen:
 *      tmpLadung: integer[]
 *      tmpLadung := beladeOptimal(kapazitaet - g, "vorrat ohne g")
 *  Danach wird das beste Resultat tmpLadung + g gesucht und als Array
 *  zurückgegeben. Behandeln Sie in der Methode beladeOptimal() zunächst die
 *  Abbruchbedingungen:
 *      Vorrat leer
 *      alle vorhandenen Gewichte sind zu schwer
 *      nur noch ein Gewicht im Vorrat
 *
 *  Autor:
 *      <NAME> 2018-06-24
 *
 *  Sprache:
 *      Kotlin 1.2.51
 */

/**
 * Bestimmt die optimale Beladung.
 * @param capacity Die maximale Beladung.
 * @param pool Die zur Beladung möglichen Elemente.
 * @return Die optimale Beladung, ein Teilmenge von pool.
 */
fun optimalLoad(capacity: Int, pool: IntArray): IntArray {
    var tmpOptimalLoad = 0
    var tmpOptimalBag = IntArray(0)
    for (index in pool.indices)
        if (pool[index] <= capacity) {
            val bag = optimalLoad(capacity - pool[index], pool.sliceArray(pool.indices - index))
            val total = bag.sum() + pool[index]
            if (total > tmpOptimalLoad) {
                tmpOptimalLoad = total
                tmpOptimalBag = bag + pool[index]
            }
        }
    return tmpOptimalBag
}

/**
 * Hauptprogramm.
 * @param argv Aufrufparamter werden ignotiert.
 */
fun main(argv: Array<String>) {
    val capacity = 270
    val pool = intArrayOf(18, 32, 34, 45, 57, 63, 69, 94, 98, 121)
    // Mit mehr Elementen dauert es wesentlioh länger:
    //val capacity =  1000
    //val pool = arrayOf(181, 130, 128, 125, 124, 121, 104, 101, 98, 94, 69, 61, 13)
    val bag = optimalLoad(capacity, pool)
    val load = bag.sum()
    println("""
    |Beladung: ${bag.contentToString()}
    |Summe Beladung: $load
    |Freie Kapazität: ${capacity - load}
    """.trimMargin())
}

Compiled from "KameleBeladen.kt"
public final class KameleBeladenKt {
  public static final int[] optimalLoad(int, int[]);
    Code:
       0: aload_1
       1: ldc           #9                  // String pool
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: iconst_0
       9: newarray       int
      11: astore_3
      12: iconst_0
      13: istore        4
      15: aload_1
      16: arraylength
      17: istore        5
      19: iload         4
      21: iload         5
      23: if_icmpge     104
      26: aload_1
      27: iload         4
      29: iaload
      30: iload_0
      31: if_icmpgt     98
      34: iload_0
      35: aload_1
      36: iload         4
      38: iaload
      39: isub
      40: aload_1
      41: aload_1
      42: invokestatic  #21                 // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
      45: checkcast     #23                 // class java/lang/Iterable
      48: iload         4
      50: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;
      56: checkcast     #37                 // class java/util/Collection
      59: invokestatic  #41                 // Method kotlin/collections/ArraysKt.sliceArray:([ILjava/util/Collection;)[I
      62: invokestatic  #43                 // Method optimalLoad:(I[I)[I
      65: astore        6
      67: aload         6
      69: invokestatic  #47                 // Method kotlin/collections/ArraysKt.sum:([I)I
      72: aload_1
      73: iload         4
      75: iaload
      76: iadd
      77: istore        7
      79: iload         7
      81: iload_2
      82: if_icmple     98
      85: iload         7
      87: istore_2
      88: aload         6
      90: aload_1
      91: iload         4
      93: iaload
      94: invokestatic  #51                 // Method kotlin/collections/ArraysKt.plus:([II)[I
      97: astore_3
      98: iinc          4, 1
     101: goto          19
     104: aload_3
     105: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #64                 // String argv
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: sipush        270
       9: istore_1
      10: bipush        10
      12: newarray       int
      14: astore_3
      15: aload_3
      16: iconst_0
      17: bipush        18
      19: iastore
      20: aload_3
      21: iconst_1
      22: bipush        32
      24: iastore
      25: aload_3
      26: iconst_2
      27: bipush        34
      29: iastore
      30: aload_3
      31: iconst_3
      32: bipush        45
      34: iastore
      35: aload_3
      36: iconst_4
      37: bipush        57
      39: iastore
      40: aload_3
      41: iconst_5
      42: bipush        63
      44: iastore
      45: aload_3
      46: bipush        6
      48: bipush        69
      50: iastore
      51: aload_3
      52: bipush        7
      54: bipush        94
      56: iastore
      57: aload_3
      58: bipush        8
      60: bipush        98
      62: iastore
      63: aload_3
      64: bipush        9
      66: bipush        121
      68: iastore
      69: aload_3
      70: astore_2
      71: iload_1
      72: aload_2
      73: invokestatic  #43                 // Method optimalLoad:(I[I)[I
      76: astore_3
      77: aload_3
      78: invokestatic  #47                 // Method kotlin/collections/ArraysKt.sum:([I)I
      81: istore        4
      83: new           #66                 // class java/lang/StringBuilder
      86: dup
      87: invokespecial #70                 // Method java/lang/StringBuilder."<init>":()V
      90: ldc           #72                 // String \n    |Beladung:
      92: invokevirtual #76                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      95: aload_3
      96: invokestatic  #82                 // Method java/util/Arrays.toString:([I)Ljava/lang/String;
      99: dup
     100: ldc           #84                 // String toString(...)
     102: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     105: invokevirtual #76                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     108: ldc           #89                 // String \n    |Summe Beladung:
     110: invokevirtual #76                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     113: iload         4
     115: invokevirtual #92                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     118: ldc           #94                 // String \n    |Freie Kapazität:
     120: invokevirtual #76                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     123: iload_1
     124: iload         4
     126: isub
     127: invokevirtual #92                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     130: ldc           #96                 // String \n
     132: invokevirtual #76                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     135: invokevirtual #99                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     138: aconst_null
     139: iconst_1
     140: aconst_null
     141: invokestatic  #105                // Method kotlin/text/StringsKt.trimMargin$default:(Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     144: astore        5
     146: getstatic     #111                // Field java/lang/System.out:Ljava/io/PrintStream;
     149: aload         5
     151: invokevirtual #117                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     154: return
}


import java.util.*

//Valid Parentheses
//Easy
//16.9K
//871
//Companies
//Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
//
//An input string is valid if:
//
//Open brackets must be closed by the same type of brackets.
//Open brackets must be closed in the correct order.
//Every close bracket has a corresponding open bracket of the same type.
//
//
//Example 1:
//
//Input: s = "()"
//Output: true
//Example 2:
//
//Input: s = "()[]{}"
//Output: true
//Example 3:
//
//Input: s = "(]"
//Output: false
//
//
//Constraints:
//
//1 <= s.length <= 104
//s consists of parentheses only '()[]{}'.

fun isValidParentheses(s: String): Boolean {
    if (s.length % 2 == 1) return false

    val openingBrackets: MutableList<Char> = mutableListOf()
    val closingBrackets: MutableList<Char> = mutableListOf()

    s.forEach { char ->
        if (isOpeningBracket(char)) {
            openingBrackets.add(char)
        } else {
            closingBrackets.add(char)
        }
    }

    if (openingBrackets.size == closingBrackets.size) {
        openingBrackets.forEachIndexed { index, char ->
            if (isSameTypeBracket(openingChar = char, closingChar = closingBrackets[index]).not()) {
                return false
            }
            return true
        }
    } else {
        return false
    }
    return false
}

fun isOpeningBracket(char: Char): Boolean = when (char) {
    '(', '[', '{' -> true
    else -> false
}

fun isSameTypeBracket(openingChar: Char, closingChar: Char): Boolean {
    if (openingChar == '(' && closingChar == ')') return true
    if (openingChar == '[' && closingChar == ']') return true
    if (openingChar == '{' && closingChar == '}') return true

    return false
}

//----------------------------------------------------------------------------- Stack Solution
fun isValidParenthesesStack(s: String): Boolean {
    if (s.length % 2 != 0) return false
    val map = mapOf('}' to '{', ')' to '(', ']' to '[')
    val stack = Stack<Char>()
    s.forEach {
        if (it == '}' || it == ')' || it == ']') {
            if (stack.isEmpty() || stack.peek() != map[it]) return false
            stack.pop()
        } else stack.push(it)
    }
    return stack.isEmpty()
}

Compiled from "ValidParenthese.kt"
public final class ValidParentheseKt {
  public static final boolean isValidParentheses(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String s
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #21                 // Method java/lang/String.length:()I
      10: iconst_2
      11: irem
      12: iconst_1
      13: if_icmpne     18
      16: iconst_0
      17: ireturn
      18: new           #23                 // class java/util/ArrayList
      21: dup
      22: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      25: checkcast     #29                 // class java/util/List
      28: astore_1
      29: new           #23                 // class java/util/ArrayList
      32: dup
      33: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      36: checkcast     #29                 // class java/util/List
      39: astore_2
      40: aload_0
      41: checkcast     #31                 // class java/lang/CharSequence
      44: astore_3
      45: iconst_0
      46: istore        4
      48: iconst_0
      49: istore        5
      51: iload         5
      53: aload_3
      54: invokeinterface #32,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      59: if_icmpge     121
      62: aload_3
      63: iload         5
      65: invokeinterface #36,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      70: istore        6
      72: iload         6
      74: istore        7
      76: iconst_0
      77: istore        8
      79: iload         7
      81: invokestatic  #40                 // Method isOpeningBracket:(C)Z
      84: ifeq          101
      87: aload_1
      88: iload         7
      90: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      93: invokeinterface #50,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      98: goto          112
     101: aload_2
     102: iload         7
     104: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     107: invokeinterface #50,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     112: pop
     113: nop
     114: nop
     115: iinc          5, 1
     118: goto          51
     121: nop
     122: aload_1
     123: invokeinterface #53,  1           // InterfaceMethod java/util/List.size:()I
     128: aload_2
     129: invokeinterface #53,  1           // InterfaceMethod java/util/List.size:()I
     134: if_icmpne     229
     137: aload_1
     138: checkcast     #55                 // class java/lang/Iterable
     141: astore_3
     142: iconst_0
     143: istore        4
     145: iconst_0
     146: istore        5
     148: aload_3
     149: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        6
     156: aload         6
     158: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          225
     166: aload         6
     168: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: astore        7
     175: iload         5
     177: iinc          5, 1
     180: istore        8
     182: iload         8
     184: aload         7
     186: checkcast     #42                 // class java/lang/Character
     189: invokevirtual #73                 // Method java/lang/Character.charValue:()C
     192: istore        9
     194: istore        10
     196: iconst_0
     197: istore        11
     199: iload         9
     201: aload_2
     202: iload         10
     204: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: checkcast     #42                 // class java/lang/Character
     212: invokevirtual #73                 // Method java/lang/Character.charValue:()C
     215: invokestatic  #81                 // Method isSameTypeBracket:(CC)Z
     218: ifne          223
     221: iconst_0
     222: ireturn
     223: iconst_1
     224: ireturn
     225: nop
     226: goto          231
     229: iconst_0
     230: ireturn
     231: iconst_0
     232: ireturn

  public static final boolean isOpeningBracket(char);
    Code:
       0: iload_0
       1: lookupswitch  { // 3
                    40: 36
                    91: 36
                   123: 36
               default: 40
          }
      36: iconst_1
      37: goto          41
      40: iconst_0
      41: ireturn

  public static final boolean isSameTypeBracket(char, char);
    Code:
       0: iload_0
       1: bipush        40
       3: if_icmpne     14
       6: iload_1
       7: bipush        41
       9: if_icmpne     14
      12: iconst_1
      13: ireturn
      14: iload_0
      15: bipush        91
      17: if_icmpne     28
      20: iload_1
      21: bipush        93
      23: if_icmpne     28
      26: iconst_1
      27: ireturn
      28: iload_0
      29: bipush        123
      31: if_icmpne     42
      34: iload_1
      35: bipush        125
      37: if_icmpne     42
      40: iconst_1
      41: ireturn
      42: iconst_0
      43: ireturn

  public static final boolean isValidParenthesesStack(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String s
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #21                 // Method java/lang/String.length:()I
      10: iconst_2
      11: irem
      12: ifeq          17
      15: iconst_0
      16: ireturn
      17: iconst_3
      18: anewarray     #106                // class kotlin/Pair
      21: astore_2
      22: aload_2
      23: iconst_0
      24: bipush        125
      26: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      29: bipush        123
      31: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      34: invokestatic  #112                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      37: aastore
      38: aload_2
      39: iconst_1
      40: bipush        41
      42: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      45: bipush        40
      47: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      50: invokestatic  #112                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      53: aastore
      54: aload_2
      55: iconst_2
      56: bipush        93
      58: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      61: bipush        91
      63: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      66: invokestatic  #112                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      69: aastore
      70: aload_2
      71: invokestatic  #118                // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;
      74: astore_1
      75: new           #120                // class java/util/Stack
      78: dup
      79: invokespecial #121                // Method java/util/Stack."<init>":()V
      82: astore_2
      83: aload_0
      84: checkcast     #31                 // class java/lang/CharSequence
      87: astore_3
      88: iconst_0
      89: istore        4
      91: iconst_0
      92: istore        5
      94: iload         5
      96: aload_3
      97: invokeinterface #32,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     102: if_icmpge     221
     105: aload_3
     106: iload         5
     108: invokeinterface #36,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     113: istore        6
     115: iload         6
     117: istore        7
     119: iconst_0
     120: istore        8
     122: iload         7
     124: lookupswitch  { // 3
                    41: 160
                    93: 160
                   125: 160
               default: 200
          }
     160: aload_2
     161: invokevirtual #124                // Method java/util/Stack.isEmpty:()Z
     164: ifne          188
     167: aload_2
     168: invokevirtual #127                // Method java/util/Stack.peek:()Ljava/lang/Object;
     171: aload_1
     172: iload         7
     174: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     177: invokeinterface #132,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     182: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     185: ifne          190
     188: iconst_0
     189: ireturn
     190: aload_2
     191: invokevirtual #139                // Method java/util/Stack.pop:()Ljava/lang/Object;
     194: checkcast     #42                 // class java/lang/Character
     197: goto          212
     200: aload_2
     201: iload         7
     203: invokestatic  #46                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     206: invokevirtual #142                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     209: checkcast     #42                 // class java/lang/Character
     212: pop
     213: nop
     214: nop
     215: iinc          5, 1
     218: goto          94
     221: nop
     222: aload_2
     223: invokevirtual #124                // Method java/util/Stack.isEmpty:()Z
     226: ireturn
}