fun main(args: Array<String>) {
    val list: List<List<Int>> = listOf(listOf(26, 40, 83), listOf(49, 60, 57), listOf(13, 89, 99))
    val list2: List<List<Int>> = listOf(listOf(1, 20, 30), listOf(50, 5, 6), listOf(9, 3, 7))

    println(solve(list))
    println(solve(list2))

}

fun solve(list: List<List<Int>>, index: Int = 0, min: Int = 0): Int = when {
    list.isEmpty() || index == 3 -> min
    else -> solve(list, index + 1, findMin(list, index, 0, min))
}

fun findMin(list: List<List<Int>>, index: Int, result: Int = 0, min: Int): Int = when {
    list.isEmpty() -> {
        if (min == 0)
            result
        else {
            if (min > result) {
                result
            } else {
                min
            }
        }
    }
    else -> {
        when (index) {
            0 -> Math.min(//RED
                    findMin(list.drop(1), 1, result + list.first()[index], min),
                    findMin(list.drop(1), 2, result + list.first()[index], min))
            1 -> Math.min(//Green
                    findMin(list.drop(1), 0, result + list.first()[index], min),
                    findMin(list.drop(1), 2, result + list.first()[index], min))
            2 -> Math.min(//Blue
                    findMin(list.drop(1), 0, result + list.first()[index], min),
                    findMin(list.drop(1), 1, result + list.first()[index], min))
            else -> {
                result
            }
        }
    }
}

/*
예제 입력
3
26 40 83
49 60 57
13 89 99

3
1 20 30
50 5 6
9 3 7

예제 출력
96

10
*/

Compiled from "StreetRgb.kt"
public final class StreetRgbKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_3
       7: anewarray     #17                 // class java/util/List
      10: astore_2
      11: aload_2
      12: iconst_0
      13: iconst_3
      14: anewarray     #19                 // class java/lang/Integer
      17: astore_3
      18: aload_3
      19: iconst_0
      20: bipush        26
      22: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload_3
      27: iconst_1
      28: bipush        40
      30: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload_3
      35: iconst_2
      36: bipush        83
      38: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aastore
      42: aload_3
      43: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      46: aastore
      47: aload_2
      48: iconst_1
      49: iconst_3
      50: anewarray     #19                 // class java/lang/Integer
      53: astore_3
      54: aload_3
      55: iconst_0
      56: bipush        49
      58: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: aastore
      62: aload_3
      63: iconst_1
      64: bipush        60
      66: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: aastore
      70: aload_3
      71: iconst_2
      72: bipush        57
      74: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: aastore
      78: aload_3
      79: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      82: aastore
      83: aload_2
      84: iconst_2
      85: iconst_3
      86: anewarray     #19                 // class java/lang/Integer
      89: astore_3
      90: aload_3
      91: iconst_0
      92: bipush        13
      94: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      97: aastore
      98: aload_3
      99: iconst_1
     100: bipush        89
     102: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     105: aastore
     106: aload_3
     107: iconst_2
     108: bipush        99
     110: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     113: aastore
     114: aload_3
     115: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     118: aastore
     119: aload_2
     120: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     123: astore_1
     124: iconst_3
     125: anewarray     #17                 // class java/util/List
     128: astore_3
     129: aload_3
     130: iconst_0
     131: iconst_3
     132: anewarray     #19                 // class java/lang/Integer
     135: astore        4
     137: aload         4
     139: iconst_0
     140: iconst_1
     141: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     144: aastore
     145: aload         4
     147: iconst_1
     148: bipush        20
     150: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     153: aastore
     154: aload         4
     156: iconst_2
     157: bipush        30
     159: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     162: aastore
     163: aload         4
     165: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     168: aastore
     169: aload_3
     170: iconst_1
     171: iconst_3
     172: anewarray     #19                 // class java/lang/Integer
     175: astore        4
     177: aload         4
     179: iconst_0
     180: bipush        50
     182: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     185: aastore
     186: aload         4
     188: iconst_1
     189: iconst_5
     190: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     193: aastore
     194: aload         4
     196: iconst_2
     197: bipush        6
     199: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: aastore
     203: aload         4
     205: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     208: aastore
     209: aload_3
     210: iconst_2
     211: iconst_3
     212: anewarray     #19                 // class java/lang/Integer
     215: astore        4
     217: aload         4
     219: iconst_0
     220: bipush        9
     222: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     225: aastore
     226: aload         4
     228: iconst_1
     229: iconst_3
     230: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     233: aastore
     234: aload         4
     236: iconst_2
     237: bipush        7
     239: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     242: aastore
     243: aload         4
     245: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     248: aastore
     249: aload_3
     250: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     253: astore_2
     254: aload_1
     255: iconst_0
     256: iconst_0
     257: bipush        6
     259: aconst_null
     260: invokestatic  #33                 // Method solve$default:(Ljava/util/List;IIILjava/lang/Object;)I
     263: istore_3
     264: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
     267: iload_3
     268: invokevirtual #45                 // Method java/io/PrintStream.println:(I)V
     271: aload_2
     272: iconst_0
     273: iconst_0
     274: bipush        6
     276: aconst_null
     277: invokestatic  #33                 // Method solve$default:(Ljava/util/List;IIILjava/lang/Object;)I
     280: istore_3
     281: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
     284: iload_3
     285: invokevirtual #45                 // Method java/io/PrintStream.println:(I)V
     288: return

  public static final int solve(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: ldc           #53                 // String list
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: aload_0
       8: invokeinterface #57,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifne          21
      16: iload_1
      17: iconst_3
      18: if_icmpne     25
      21: iload_2
      22: goto          39
      25: aload_0
      26: iload_1
      27: iconst_1
      28: iadd
      29: aload_0
      30: iload_1
      31: iconst_0
      32: iload_2
      33: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
      36: invokestatic  #63                 // Method solve:(Ljava/util/List;II)I
      39: ireturn

  public static int solve$default(java.util.List, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_3
       9: iconst_4
      10: iand
      11: ifeq          16
      14: iconst_0
      15: istore_2
      16: aload_0
      17: iload_1
      18: iload_2
      19: invokestatic  #63                 // Method solve:(Ljava/util/List;II)I
      22: ireturn

  public static final int findMin(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int, int);
    Code:
       0: aload_0
       1: ldc           #53                 // String list
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: aload_0
       8: invokeinterface #57,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifeq          37
      16: iload_3
      17: ifne          24
      20: iload_2
      21: goto          287
      24: iload_3
      25: iload_2
      26: if_icmple     33
      29: iload_2
      30: goto          287
      33: iload_3
      34: goto          287
      37: iload_1
      38: tableswitch   { // 0 to 2
                     0: 64
                     1: 138
                     2: 212
               default: 286
          }
      64: aload_0
      65: checkcast     #69                 // class java/lang/Iterable
      68: iconst_1
      69: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      72: iconst_1
      73: iload_2
      74: aload_0
      75: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      78: checkcast     #17                 // class java/util/List
      81: iload_1
      82: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #83                 // class java/lang/Number
      90: invokevirtual #87                 // Method java/lang/Number.intValue:()I
      93: iadd
      94: iload_3
      95: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
      98: aload_0
      99: checkcast     #69                 // class java/lang/Iterable
     102: iconst_1
     103: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     106: iconst_2
     107: iload_2
     108: aload_0
     109: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     112: checkcast     #17                 // class java/util/List
     115: iload_1
     116: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #83                 // class java/lang/Number
     124: invokevirtual #87                 // Method java/lang/Number.intValue:()I
     127: iadd
     128: iload_3
     129: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
     132: invokestatic  #92                 // Method java/lang/Math.min:(II)I
     135: goto          287
     138: aload_0
     139: checkcast     #69                 // class java/lang/Iterable
     142: iconst_1
     143: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     146: iconst_0
     147: iload_2
     148: aload_0
     149: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     152: checkcast     #17                 // class java/util/List
     155: iload_1
     156: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     161: checkcast     #83                 // class java/lang/Number
     164: invokevirtual #87                 // Method java/lang/Number.intValue:()I
     167: iadd
     168: iload_3
     169: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
     172: aload_0
     173: checkcast     #69                 // class java/lang/Iterable
     176: iconst_1
     177: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     180: iconst_2
     181: iload_2
     182: aload_0
     183: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     186: checkcast     #17                 // class java/util/List
     189: iload_1
     190: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     195: checkcast     #83                 // class java/lang/Number
     198: invokevirtual #87                 // Method java/lang/Number.intValue:()I
     201: iadd
     202: iload_3
     203: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
     206: invokestatic  #92                 // Method java/lang/Math.min:(II)I
     209: goto          287
     212: aload_0
     213: checkcast     #69                 // class java/lang/Iterable
     216: iconst_1
     217: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     220: iconst_0
     221: iload_2
     222: aload_0
     223: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     226: checkcast     #17                 // class java/util/List
     229: iload_1
     230: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     235: checkcast     #83                 // class java/lang/Number
     238: invokevirtual #87                 // Method java/lang/Number.intValue:()I
     241: iadd
     242: iload_3
     243: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
     246: aload_0
     247: checkcast     #69                 // class java/lang/Iterable
     250: iconst_1
     251: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     254: iconst_1
     255: iload_2
     256: aload_0
     257: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     260: checkcast     #17                 // class java/util/List
     263: iload_1
     264: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     269: checkcast     #83                 // class java/lang/Number
     272: invokevirtual #87                 // Method java/lang/Number.intValue:()I
     275: iadd
     276: iload_3
     277: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
     280: invokestatic  #92                 // Method java/lang/Math.min:(II)I
     283: goto          287
     286: iload_2
     287: ireturn

  public static int findMin$default(java.util.List, int, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_2
       9: aload_0
      10: iload_1
      11: iload_2
      12: iload_3
      13: invokestatic  #61                 // Method findMin:(Ljava/util/List;III)I
      16: ireturn
}


fun main(args: Array<String>) {
    val test1 = listOf(
            listOf(9, 8, 7),
            listOf(5, 3, 2),
            listOf(6, 6, 7))

    val test2 = listOf(
            listOf(1, 2, 3),
            listOf(3, 1, 2),
            listOf(2, 3, 1))
    val test3 = listOf(
            listOf(4, 5, 4),
            listOf(3, 5, 5),
            listOf(1, 5, 4))

    val test4 = listOf(
            listOf(8, 7, 9),
            listOf(6, 7, 6),
            listOf(3, 2, 5)
    )

    println(solve(test1).filterNotNull())
    println(solve(test2).filterNotNull())
    println(solve(test3).filterNotNull())
    println(solve(test4).filterNotNull())
}

private fun solve(list: List<List<Int>>): List<Pair<Int, Int>?> {
    val xResult = list.map { it.max()!! }.min()
    val yResult = transfer(list, listOf()).map { it.min()!! }.max()

    return if (xResult == yResult) {
        list.foldIndexed(listOf()) { index, acc, lista ->
            acc.plus(lista.mapIndexed { indexa, i -> if(i == xResult) index to indexa else null })
        }
    } else {
        listOf()
    }
}

tailrec fun transfer(list: List<List<Int>>, acc: List<List<Int>>): List<List<Int>> {
    return when {
        list.isEmpty() || list.first().isEmpty() -> acc
        else -> {
            transfer(list.map { it.drop(1) }, acc.plusElement(list.map { it.first() }))
        }
    }
}

Compiled from "Saddlepoint.kt"
public final class SaddlepointKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_3
       7: anewarray     #17                 // class java/util/List
      10: astore_2
      11: aload_2
      12: iconst_0
      13: iconst_3
      14: anewarray     #19                 // class java/lang/Integer
      17: astore_3
      18: aload_3
      19: iconst_0
      20: bipush        9
      22: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload_3
      27: iconst_1
      28: bipush        8
      30: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload_3
      35: iconst_2
      36: bipush        7
      38: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aastore
      42: aload_3
      43: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      46: aastore
      47: aload_2
      48: iconst_1
      49: iconst_3
      50: anewarray     #19                 // class java/lang/Integer
      53: astore_3
      54: aload_3
      55: iconst_0
      56: iconst_5
      57: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      60: aastore
      61: aload_3
      62: iconst_1
      63: iconst_3
      64: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      67: aastore
      68: aload_3
      69: iconst_2
      70: iconst_2
      71: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      74: aastore
      75: aload_3
      76: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      79: aastore
      80: aload_2
      81: iconst_2
      82: iconst_3
      83: anewarray     #19                 // class java/lang/Integer
      86: astore_3
      87: aload_3
      88: iconst_0
      89: bipush        6
      91: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: aastore
      95: aload_3
      96: iconst_1
      97: bipush        6
      99: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     102: aastore
     103: aload_3
     104: iconst_2
     105: bipush        7
     107: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     110: aastore
     111: aload_3
     112: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     115: aastore
     116: aload_2
     117: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     120: astore_1
     121: iconst_3
     122: anewarray     #17                 // class java/util/List
     125: astore_3
     126: aload_3
     127: iconst_0
     128: iconst_3
     129: anewarray     #19                 // class java/lang/Integer
     132: astore        4
     134: aload         4
     136: iconst_0
     137: iconst_1
     138: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: aastore
     142: aload         4
     144: iconst_1
     145: iconst_2
     146: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     149: aastore
     150: aload         4
     152: iconst_2
     153: iconst_3
     154: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     157: aastore
     158: aload         4
     160: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     163: aastore
     164: aload_3
     165: iconst_1
     166: iconst_3
     167: anewarray     #19                 // class java/lang/Integer
     170: astore        4
     172: aload         4
     174: iconst_0
     175: iconst_3
     176: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     179: aastore
     180: aload         4
     182: iconst_1
     183: iconst_1
     184: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     187: aastore
     188: aload         4
     190: iconst_2
     191: iconst_2
     192: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     195: aastore
     196: aload         4
     198: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     201: aastore
     202: aload_3
     203: iconst_2
     204: iconst_3
     205: anewarray     #19                 // class java/lang/Integer
     208: astore        4
     210: aload         4
     212: iconst_0
     213: iconst_2
     214: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     217: aastore
     218: aload         4
     220: iconst_1
     221: iconst_3
     222: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     225: aastore
     226: aload         4
     228: iconst_2
     229: iconst_1
     230: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     233: aastore
     234: aload         4
     236: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     239: aastore
     240: aload_3
     241: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     244: astore_2
     245: iconst_3
     246: anewarray     #17                 // class java/util/List
     249: astore        4
     251: aload         4
     253: iconst_0
     254: iconst_3
     255: anewarray     #19                 // class java/lang/Integer
     258: astore        5
     260: aload         5
     262: iconst_0
     263: iconst_4
     264: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     267: aastore
     268: aload         5
     270: iconst_1
     271: iconst_5
     272: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     275: aastore
     276: aload         5
     278: iconst_2
     279: iconst_4
     280: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: aastore
     284: aload         5
     286: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     289: aastore
     290: aload         4
     292: iconst_1
     293: iconst_3
     294: anewarray     #19                 // class java/lang/Integer
     297: astore        5
     299: aload         5
     301: iconst_0
     302: iconst_3
     303: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     306: aastore
     307: aload         5
     309: iconst_1
     310: iconst_5
     311: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     314: aastore
     315: aload         5
     317: iconst_2
     318: iconst_5
     319: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     322: aastore
     323: aload         5
     325: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     328: aastore
     329: aload         4
     331: iconst_2
     332: iconst_3
     333: anewarray     #19                 // class java/lang/Integer
     336: astore        5
     338: aload         5
     340: iconst_0
     341: iconst_1
     342: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     345: aastore
     346: aload         5
     348: iconst_1
     349: iconst_5
     350: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     353: aastore
     354: aload         5
     356: iconst_2
     357: iconst_4
     358: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     361: aastore
     362: aload         5
     364: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     367: aastore
     368: aload         4
     370: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     373: astore_3
     374: iconst_3
     375: anewarray     #17                 // class java/util/List
     378: astore        5
     380: aload         5
     382: iconst_0
     383: iconst_3
     384: anewarray     #19                 // class java/lang/Integer
     387: astore        6
     389: aload         6
     391: iconst_0
     392: bipush        8
     394: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     397: aastore
     398: aload         6
     400: iconst_1
     401: bipush        7
     403: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     406: aastore
     407: aload         6
     409: iconst_2
     410: bipush        9
     412: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     415: aastore
     416: aload         6
     418: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     421: aastore
     422: aload         5
     424: iconst_1
     425: iconst_3
     426: anewarray     #19                 // class java/lang/Integer
     429: astore        6
     431: aload         6
     433: iconst_0
     434: bipush        6
     436: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     439: aastore
     440: aload         6
     442: iconst_1
     443: bipush        7
     445: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     448: aastore
     449: aload         6
     451: iconst_2
     452: bipush        6
     454: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     457: aastore
     458: aload         6
     460: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     463: aastore
     464: aload         5
     466: iconst_2
     467: iconst_3
     468: anewarray     #19                 // class java/lang/Integer
     471: astore        6
     473: aload         6
     475: iconst_0
     476: iconst_3
     477: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     480: aastore
     481: aload         6
     483: iconst_1
     484: iconst_2
     485: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     488: aastore
     489: aload         6
     491: iconst_2
     492: iconst_5
     493: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     496: aastore
     497: aload         6
     499: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     502: aastore
     503: aload         5
     505: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     508: astore        4
     510: aload_1
     511: invokestatic  #33                 // Method solve:(Ljava/util/List;)Ljava/util/List;
     514: checkcast     #35                 // class java/lang/Iterable
     517: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     520: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     523: swap
     524: invokevirtual #51                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     527: aload_2
     528: invokestatic  #33                 // Method solve:(Ljava/util/List;)Ljava/util/List;
     531: checkcast     #35                 // class java/lang/Iterable
     534: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     537: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     540: swap
     541: invokevirtual #51                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     544: aload_3
     545: invokestatic  #33                 // Method solve:(Ljava/util/List;)Ljava/util/List;
     548: checkcast     #35                 // class java/lang/Iterable
     551: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     554: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     557: swap
     558: invokevirtual #51                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     561: aload         4
     563: invokestatic  #33                 // Method solve:(Ljava/util/List;)Ljava/util/List;
     566: checkcast     #35                 // class java/lang/Iterable
     569: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     572: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     575: swap
     576: invokevirtual #51                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     579: return

  private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> solve(java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: checkcast     #35                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #60                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #70                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          106
      50: aload         7
      52: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #17                 // class java/util/List
      66: astore        9
      68: astore        29
      70: iconst_0
      71: istore        10
      73: aload         9
      75: checkcast     #35                 // class java/lang/Iterable
      78: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      81: dup
      82: invokestatic  #91                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      85: checkcast     #93                 // class java/lang/Number
      88: invokevirtual #97                 // Method java/lang/Number.intValue:()I
      91: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: aload         29
      96: swap
      97: invokeinterface #101,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     102: pop
     103: goto          40
     106: aload         5
     108: checkcast     #17                 // class java/util/List
     111: nop
     112: checkcast     #35                 // class java/lang/Iterable
     115: invokestatic  #104                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     118: checkcast     #93                 // class java/lang/Number
     121: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     124: istore_1
     125: aload_0
     126: invokestatic  #108                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     129: invokestatic  #112                // Method transfer:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     132: checkcast     #35                 // class java/lang/Iterable
     135: astore_3
     136: iconst_0
     137: istore        4
     139: aload_3
     140: astore        5
     142: new           #60                 // class java/util/ArrayList
     145: dup
     146: aload_3
     147: bipush        10
     149: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     152: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     155: checkcast     #70                 // class java/util/Collection
     158: astore        6
     160: iconst_0
     161: istore        7
     163: aload         5
     165: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     170: astore        8
     172: aload         8
     174: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     179: ifeq          238
     182: aload         8
     184: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     189: astore        9
     191: aload         6
     193: aload         9
     195: checkcast     #17                 // class java/util/List
     198: astore        10
     200: astore        29
     202: iconst_0
     203: istore        11
     205: aload         10
     207: checkcast     #35                 // class java/lang/Iterable
     210: invokestatic  #104                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     213: dup
     214: invokestatic  #91                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     217: checkcast     #93                 // class java/lang/Number
     220: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     223: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     226: aload         29
     228: swap
     229: invokeinterface #101,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: goto          172
     238: aload         6
     240: checkcast     #17                 // class java/util/List
     243: nop
     244: checkcast     #35                 // class java/lang/Iterable
     247: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     250: checkcast     #93                 // class java/lang/Number
     253: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     256: istore_2
     257: iload_1
     258: iload_2
     259: if_icmpne     513
     262: aload_0
     263: checkcast     #35                 // class java/lang/Iterable
     266: astore_3
     267: invokestatic  #108                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     270: astore        4
     272: nop
     273: iconst_0
     274: istore        5
     276: iconst_0
     277: istore        6
     279: aload         4
     281: astore        7
     283: aload_3
     284: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     289: astore        8
     291: aload         8
     293: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     298: ifeq          508
     301: aload         8
     303: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     308: astore        9
     310: iload         6
     312: iinc          6, 1
     315: istore        10
     317: iload         10
     319: ifge          325
     322: invokestatic  #116                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     325: iload         10
     327: aload         7
     329: aload         9
     331: checkcast     #17                 // class java/util/List
     334: astore        11
     336: astore        12
     338: istore        13
     340: iconst_0
     341: istore        14
     343: aload         12
     345: checkcast     #70                 // class java/util/Collection
     348: aload         11
     350: checkcast     #35                 // class java/lang/Iterable
     353: astore        15
     355: astore        16
     357: iconst_0
     358: istore        17
     360: aload         15
     362: astore        18
     364: new           #60                 // class java/util/ArrayList
     367: dup
     368: aload         15
     370: bipush        10
     372: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     375: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     378: checkcast     #70                 // class java/util/Collection
     381: astore        19
     383: iconst_0
     384: istore        20
     386: iconst_0
     387: istore        21
     389: aload         18
     391: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     396: astore        22
     398: aload         22
     400: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     405: ifeq          488
     408: aload         22
     410: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     415: astore        23
     417: aload         19
     419: iload         21
     421: iinc          21, 1
     424: istore        24
     426: iload         24
     428: ifge          434
     431: invokestatic  #116                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     434: iload         24
     436: aload         23
     438: checkcast     #93                 // class java/lang/Number
     441: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     444: istore        25
     446: istore        26
     448: astore        27
     450: iconst_0
     451: istore        28
     453: iload         25
     455: iload_1
     456: if_icmpne     475
     459: iload         13
     461: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     464: iload         26
     466: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     469: invokestatic  #122                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     472: goto          476
     475: aconst_null
     476: aload         27
     478: swap
     479: invokeinterface #101,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     484: pop
     485: goto          398
     488: aload         19
     490: checkcast     #17                 // class java/util/List
     493: nop
     494: aload         16
     496: swap
     497: checkcast     #35                 // class java/lang/Iterable
     500: invokestatic  #126                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     503: astore        7
     505: goto          291
     508: aload         7
     510: goto          516
     513: invokestatic  #108                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     516: areturn

  public static final java.util.List<java.util.List<java.lang.Integer>> transfer(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #164                // String list
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #165                // String acc
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: nop
      13: aload_0
      14: invokeinterface #168,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      19: ifne          37
      22: aload_0
      23: invokestatic  #172                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      26: checkcast     #17                 // class java/util/List
      29: invokeinterface #168,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      34: ifeq          41
      37: aload_1
      38: goto          275
      41: aload_0
      42: checkcast     #35                 // class java/lang/Iterable
      45: astore_3
      46: iconst_0
      47: istore        4
      49: aload_3
      50: astore        5
      52: new           #60                 // class java/util/ArrayList
      55: dup
      56: aload_3
      57: bipush        10
      59: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      62: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
      65: checkcast     #70                 // class java/util/Collection
      68: astore        6
      70: iconst_0
      71: istore        7
      73: aload         5
      75: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      80: astore        8
      82: aload         8
      84: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      89: ifeq          136
      92: aload         8
      94: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      99: astore        9
     101: aload         6
     103: aload         9
     105: checkcast     #17                 // class java/util/List
     108: astore        10
     110: astore        14
     112: iconst_0
     113: istore        11
     115: aload         10
     117: checkcast     #35                 // class java/lang/Iterable
     120: iconst_1
     121: invokestatic  #176                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     124: aload         14
     126: swap
     127: invokeinterface #101,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     132: pop
     133: goto          82
     136: aload         6
     138: checkcast     #17                 // class java/util/List
     141: nop
     142: astore_2
     143: aload_1
     144: checkcast     #70                 // class java/util/Collection
     147: astore        4
     149: aload_0
     150: checkcast     #35                 // class java/lang/Iterable
     153: astore        5
     155: iconst_0
     156: istore        6
     158: aload         5
     160: astore        7
     162: new           #60                 // class java/util/ArrayList
     165: dup
     166: aload         5
     168: bipush        10
     170: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     173: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     176: checkcast     #70                 // class java/util/Collection
     179: astore        8
     181: iconst_0
     182: istore        9
     184: aload         7
     186: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     191: astore        10
     193: aload         10
     195: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     200: ifeq          252
     203: aload         10
     205: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     210: astore        11
     212: aload         8
     214: aload         11
     216: checkcast     #17                 // class java/util/List
     219: astore        12
     221: astore        14
     223: iconst_0
     224: istore        13
     226: aload         12
     228: invokestatic  #172                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     231: checkcast     #93                 // class java/lang/Number
     234: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     237: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     240: aload         14
     242: swap
     243: invokeinterface #101,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     248: pop
     249: goto          193
     252: aload         8
     254: checkcast     #17                 // class java/util/List
     257: nop
     258: astore        5
     260: aload         4
     262: aload         5
     264: invokestatic  #179                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     267: astore_3
     268: aload_2
     269: astore_0
     270: aload_3
     271: astore_1
     272: goto          12
     275: areturn
}


fun main(args: Array<String>) {
    solve(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1), 9)
    solve2(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1))
    solve3(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1))
    solve3(listOf(3, 4, 21, 36, 10, 28, 35, 5, 24, 42))
}

data class RecordedScore(val minScore: Int = 0, val maxScore: Int = 0, val min: Int = 0, val max: Int = 0)

tailrec fun solve(
        scoreList: List<Int>,
        size: Int,
        minScore: Int = 0,
        maxScore: Int = 0,
        min: Int = 0,
        max: Int = 0
) {
    when {
        scoreList.isEmpty() -> println("$max $min")
        scoreList.size == size -> {
            val score = scoreList.first()
            solve(scoreList.drop(1), 9, score, score)
        }
        scoreList.size != size -> {
            val score = scoreList.first()
            solve(
                    scoreList.drop(1),
                    size,
                    if (score < minScore) score else minScore,
                    if (score > maxScore) score else maxScore,
                    if (score < minScore) min + 1 else min,
                    if (score > maxScore) max + 1 else max
            )
        }
    }
}

private tailrec fun solve2(
        scoreList: List<Int>,
        minScore: Int,
        maxScore: Int,
        min: Int = 0,
        max: Int = 0
) {
    when (scoreList.isEmpty()) {
        true -> println("$max $min")
        false -> {
            val score = scoreList.first()
            val scoreLessThenMinScore = score < minScore
            val scoreGreaterThenMinScore = score > maxScore
            solve2(
                    scoreList.drop(1),
                    if (scoreLessThenMinScore) score else minScore,
                    if (scoreGreaterThenMinScore) score else maxScore,
                    if (scoreLessThenMinScore) min + 1 else min,
                    if (scoreGreaterThenMinScore) max + 1 else max
            )
        }
    }
}

fun solve2(scoreList: List<Int>) {
    val init = scoreList.first()
    solve2(scoreList.drop(1), init, init)
}

fun solve3(scoreList: List<Int>) = scoreList.foldIndexed(RecordedScore()) { i, record, score ->
    when (i) {
        0 -> RecordedScore(score, score)
        else -> RecordedScore(
                Math.min(score, record.minScore),
                Math.max(score, record.maxScore),
                if (score < record.minScore) record.min + 1 else record.min,
                if (score > record.maxScore) record.max + 1 else record.max
        )
    }
}.also { println("${it.max} ${it.min}") }

Compiled from "RefreshRecord.kt"
public final class RefreshRecordKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        9
       8: anewarray     #17                 // class java/lang/Integer
      11: astore_1
      12: aload_1
      13: iconst_0
      14: bipush        10
      16: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: aastore
      20: aload_1
      21: iconst_1
      22: iconst_5
      23: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: aastore
      27: aload_1
      28: iconst_2
      29: bipush        20
      31: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: aastore
      35: aload_1
      36: iconst_3
      37: bipush        20
      39: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      42: aastore
      43: aload_1
      44: iconst_4
      45: iconst_4
      46: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      49: aastore
      50: aload_1
      51: iconst_5
      52: iconst_5
      53: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      56: aastore
      57: aload_1
      58: bipush        6
      60: iconst_2
      61: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      64: aastore
      65: aload_1
      66: bipush        7
      68: bipush        25
      70: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      73: aastore
      74: aload_1
      75: bipush        8
      77: iconst_1
      78: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      81: aastore
      82: aload_1
      83: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      86: bipush        9
      88: iconst_0
      89: iconst_0
      90: iconst_0
      91: iconst_0
      92: bipush        60
      94: aconst_null
      95: invokestatic  #31                 // Method solve$default:(Ljava/util/List;IIIIIILjava/lang/Object;)V
      98: bipush        9
     100: anewarray     #17                 // class java/lang/Integer
     103: astore_1
     104: aload_1
     105: iconst_0
     106: bipush        10
     108: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     111: aastore
     112: aload_1
     113: iconst_1
     114: iconst_5
     115: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     118: aastore
     119: aload_1
     120: iconst_2
     121: bipush        20
     123: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     126: aastore
     127: aload_1
     128: iconst_3
     129: bipush        20
     131: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     134: aastore
     135: aload_1
     136: iconst_4
     137: iconst_4
     138: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: aastore
     142: aload_1
     143: iconst_5
     144: iconst_5
     145: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     148: aastore
     149: aload_1
     150: bipush        6
     152: iconst_2
     153: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     156: aastore
     157: aload_1
     158: bipush        7
     160: bipush        25
     162: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     165: aastore
     166: aload_1
     167: bipush        8
     169: iconst_1
     170: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     173: aastore
     174: aload_1
     175: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     178: invokestatic  #35                 // Method solve2:(Ljava/util/List;)V
     181: bipush        9
     183: anewarray     #17                 // class java/lang/Integer
     186: astore_1
     187: aload_1
     188: iconst_0
     189: bipush        10
     191: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     194: aastore
     195: aload_1
     196: iconst_1
     197: iconst_5
     198: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: aastore
     202: aload_1
     203: iconst_2
     204: bipush        20
     206: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     209: aastore
     210: aload_1
     211: iconst_3
     212: bipush        20
     214: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     217: aastore
     218: aload_1
     219: iconst_4
     220: iconst_4
     221: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     224: aastore
     225: aload_1
     226: iconst_5
     227: iconst_5
     228: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     231: aastore
     232: aload_1
     233: bipush        6
     235: iconst_2
     236: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     239: aastore
     240: aload_1
     241: bipush        7
     243: bipush        25
     245: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     248: aastore
     249: aload_1
     250: bipush        8
     252: iconst_1
     253: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     256: aastore
     257: aload_1
     258: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     261: invokestatic  #39                 // Method solve3:(Ljava/util/List;)LRecordedScore;
     264: pop
     265: bipush        10
     267: anewarray     #17                 // class java/lang/Integer
     270: astore_1
     271: aload_1
     272: iconst_0
     273: iconst_3
     274: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: aastore
     278: aload_1
     279: iconst_1
     280: iconst_4
     281: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     284: aastore
     285: aload_1
     286: iconst_2
     287: bipush        21
     289: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     292: aastore
     293: aload_1
     294: iconst_3
     295: bipush        36
     297: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     300: aastore
     301: aload_1
     302: iconst_4
     303: bipush        10
     305: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     308: aastore
     309: aload_1
     310: iconst_5
     311: bipush        28
     313: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     316: aastore
     317: aload_1
     318: bipush        6
     320: bipush        35
     322: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     325: aastore
     326: aload_1
     327: bipush        7
     329: iconst_5
     330: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     333: aastore
     334: aload_1
     335: bipush        8
     337: bipush        24
     339: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     342: aastore
     343: aload_1
     344: bipush        9
     346: bipush        42
     348: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     351: aastore
     352: aload_1
     353: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     356: invokestatic  #39                 // Method solve3:(Ljava/util/List;)LRecordedScore;
     359: pop
     360: return

  public static final void solve(java.util.List<java.lang.Integer>, int, int, int, int, int);
    Code:
       0: aload_0
       1: ldc           #45                 // String scoreList
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: aload_0
       8: invokeinterface #51,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifeq          51
      16: new           #53                 // class java/lang/StringBuilder
      19: dup
      20: invokespecial #57                 // Method java/lang/StringBuilder."<init>":()V
      23: iload         5
      25: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      28: bipush        32
      30: invokevirtual #64                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      33: iload         4
      35: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      38: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      41: getstatic     #74                 // Field java/lang/System.out:Ljava/io/PrintStream;
      44: swap
      45: invokevirtual #80                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      48: goto          220
      51: aload_0
      52: invokeinterface #84,  1           // InterfaceMethod java/util/List.size:()I
      57: iload_1
      58: if_icmpne     100
      61: aload_0
      62: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      65: checkcast     #90                 // class java/lang/Number
      68: invokevirtual #93                 // Method java/lang/Number.intValue:()I
      71: istore        6
      73: aload_0
      74: checkcast     #95                 // class java/lang/Iterable
      77: iconst_1
      78: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      81: astore_0
      82: bipush        9
      84: istore_1
      85: iload         6
      87: istore_2
      88: iload         6
      90: istore_3
      91: iconst_0
      92: istore        4
      94: iconst_0
      95: istore        5
      97: goto          6
     100: aload_0
     101: invokeinterface #84,  1           // InterfaceMethod java/util/List.size:()I
     106: iload_1
     107: if_icmpeq     220
     110: aload_0
     111: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     114: checkcast     #90                 // class java/lang/Number
     117: invokevirtual #93                 // Method java/lang/Number.intValue:()I
     120: istore        6
     122: aload_0
     123: checkcast     #95                 // class java/lang/Iterable
     126: iconst_1
     127: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     130: astore        7
     132: iload_1
     133: istore        8
     135: iload         6
     137: iload_2
     138: if_icmpge     146
     141: iload         6
     143: goto          147
     146: iload_2
     147: istore        9
     149: iload         6
     151: iload_3
     152: if_icmple     160
     155: iload         6
     157: goto          161
     160: iload_3
     161: istore        10
     163: iload         6
     165: iload_2
     166: if_icmpge     176
     169: iload         4
     171: iconst_1
     172: iadd
     173: goto          178
     176: iload         4
     178: istore        11
     180: iload         6
     182: iload_3
     183: if_icmple     193
     186: iload         5
     188: iconst_1
     189: iadd
     190: goto          195
     193: iload         5
     195: istore        12
     197: aload         7
     199: astore_0
     200: iload         8
     202: istore_1
     203: iload         9
     205: istore_2
     206: iload         10
     208: istore_3
     209: iload         11
     211: istore        4
     213: iload         12
     215: istore        5
     217: goto          6
     220: goto          223
     223: return

  public static void solve$default(java.util.List, int, int, int, int, int, int, java.lang.Object);
    Code:
       0: iload         6
       2: iconst_4
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_2
       9: iload         6
      11: bipush        8
      13: iand
      14: ifeq          19
      17: iconst_0
      18: istore_3
      19: iload         6
      21: bipush        16
      23: iand
      24: ifeq          30
      27: iconst_0
      28: istore        4
      30: iload         6
      32: bipush        32
      34: iand
      35: ifeq          41
      38: iconst_0
      39: istore        5
      41: aload_0
      42: iload_1
      43: iload_2
      44: iload_3
      45: iload         4
      47: iload         5
      49: invokestatic  #108                // Method solve:(Ljava/util/List;IIIII)V
      52: return

  private static final void solve2(java.util.List<java.lang.Integer>, int, int, int, int);
    Code:
       0: aload_0
       1: invokeinterface #51,  1           // InterfaceMethod java/util/List.isEmpty:()Z
       6: istore        5
       8: iload         5
      10: iconst_1
      11: if_icmpne     48
      14: new           #53                 // class java/lang/StringBuilder
      17: dup
      18: invokespecial #57                 // Method java/lang/StringBuilder."<init>":()V
      21: iload         4
      23: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      26: bipush        32
      28: invokevirtual #64                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      31: iload_3
      32: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      35: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      38: getstatic     #74                 // Field java/lang/System.out:Ljava/io/PrintStream;
      41: swap
      42: invokevirtual #80                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      45: goto          184
      48: iload         5
      50: ifne          176
      53: aload_0
      54: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      57: checkcast     #90                 // class java/lang/Number
      60: invokevirtual #93                 // Method java/lang/Number.intValue:()I
      63: istore        6
      65: iload         6
      67: iload_1
      68: if_icmpge     75
      71: iconst_1
      72: goto          76
      75: iconst_0
      76: istore        7
      78: iload         6
      80: iload_2
      81: if_icmple     88
      84: iconst_1
      85: goto          89
      88: iconst_0
      89: istore        8
      91: aload_0
      92: checkcast     #95                 // class java/lang/Iterable
      95: iconst_1
      96: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      99: astore        9
     101: iload         7
     103: ifeq          111
     106: iload         6
     108: goto          112
     111: iload_1
     112: istore        10
     114: iload         8
     116: ifeq          124
     119: iload         6
     121: goto          125
     124: iload_2
     125: istore        11
     127: iload         7
     129: ifeq          138
     132: iload_3
     133: iconst_1
     134: iadd
     135: goto          139
     138: iload_3
     139: istore        12
     141: iload         8
     143: ifeq          153
     146: iload         4
     148: iconst_1
     149: iadd
     150: goto          155
     153: iload         4
     155: istore        13
     157: aload         9
     159: astore_0
     160: iload         10
     162: istore_1
     163: iload         11
     165: istore_2
     166: iload         12
     168: istore_3
     169: iload         13
     171: istore        4
     173: goto          0
     176: new           #112                // class kotlin/NoWhenBranchMatchedException
     179: dup
     180: invokespecial #113                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     183: athrow
     184: goto          187
     187: return

  static void solve2$default(java.util.List, int, int, int, int, int, java.lang.Object);
    Code:
       0: iload         5
       2: bipush        8
       4: iand
       5: ifeq          10
       8: iconst_0
       9: istore_3
      10: iload         5
      12: bipush        16
      14: iand
      15: ifeq          21
      18: iconst_0
      19: istore        4
      21: aload_0
      22: iload_1
      23: iload_2
      24: iload_3
      25: iload         4
      27: invokestatic  #120                // Method solve2:(Ljava/util/List;IIII)V
      30: return

  public static final void solve2(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #45                 // String scoreList
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      10: checkcast     #90                 // class java/lang/Number
      13: invokevirtual #93                 // Method java/lang/Number.intValue:()I
      16: istore_1
      17: aload_0
      18: checkcast     #95                 // class java/lang/Iterable
      21: iconst_1
      22: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      25: iload_1
      26: iload_1
      27: iconst_0
      28: iconst_0
      29: bipush        24
      31: aconst_null
      32: invokestatic  #123                // Method solve2$default:(Ljava/util/List;IIIIILjava/lang/Object;)V
      35: return

  public static final RecordedScore solve3(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #45                 // String scoreList
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #95                 // class java/lang/Iterable
      10: astore_1
      11: new           #127                // class RecordedScore
      14: dup
      15: iconst_0
      16: iconst_0
      17: iconst_0
      18: iconst_0
      19: bipush        15
      21: aconst_null
      22: invokespecial #130                // Method RecordedScore."<init>":(IIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      25: astore_2
      26: iconst_0
      27: istore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: astore        5
      34: aload_1
      35: invokeinterface #134,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        6
      42: aload         6
      44: invokeinterface #139,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          204
      52: aload         6
      54: invokeinterface #143,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        7
      61: iload         4
      63: iinc          4, 1
      66: istore        8
      68: iload         8
      70: ifge          76
      73: invokestatic  #146                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      76: iload         8
      78: aload         5
      80: aload         7
      82: checkcast     #90                 // class java/lang/Number
      85: invokevirtual #93                 // Method java/lang/Number.intValue:()I
      88: istore        9
      90: astore        10
      92: istore        11
      94: iconst_0
      95: istore        12
      97: iload         11
      99: ifne          121
     102: new           #127                // class RecordedScore
     105: dup
     106: iload         9
     108: iload         9
     110: iconst_0
     111: iconst_0
     112: bipush        12
     114: aconst_null
     115: invokespecial #130                // Method RecordedScore."<init>":(IIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
     118: goto          198
     121: new           #127                // class RecordedScore
     124: dup
     125: iload         9
     127: aload         10
     129: invokevirtual #149                // Method RecordedScore.getMinScore:()I
     132: invokestatic  #154                // Method java/lang/Math.min:(II)I
     135: iload         9
     137: aload         10
     139: invokevirtual #157                // Method RecordedScore.getMaxScore:()I
     142: invokestatic  #159                // Method java/lang/Math.max:(II)I
     145: iload         9
     147: aload         10
     149: invokevirtual #149                // Method RecordedScore.getMinScore:()I
     152: if_icmpge     165
     155: aload         10
     157: invokevirtual #162                // Method RecordedScore.getMin:()I
     160: iconst_1
     161: iadd
     162: goto          170
     165: aload         10
     167: invokevirtual #162                // Method RecordedScore.getMin:()I
     170: iload         9
     172: aload         10
     174: invokevirtual #157                // Method RecordedScore.getMaxScore:()I
     177: if_icmple     190
     180: aload         10
     182: invokevirtual #165                // Method RecordedScore.getMax:()I
     185: iconst_1
     186: iadd
     187: goto          195
     190: aload         10
     192: invokevirtual #165                // Method RecordedScore.getMax:()I
     195: invokespecial #168                // Method RecordedScore."<init>":(IIII)V
     198: nop
     199: astore        5
     201: goto          42
     204: aload         5
     206: astore_1
     207: aload_1
     208: astore_2
     209: iconst_0
     210: istore_3
     211: new           #53                 // class java/lang/StringBuilder
     214: dup
     215: invokespecial #57                 // Method java/lang/StringBuilder."<init>":()V
     218: aload_2
     219: invokevirtual #165                // Method RecordedScore.getMax:()I
     222: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     225: bipush        32
     227: invokevirtual #64                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     230: aload_2
     231: invokevirtual #162                // Method RecordedScore.getMin:()I
     234: invokevirtual #61                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     237: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     240: getstatic     #74                 // Field java/lang/System.out:Ljava/io/PrintStream;
     243: swap
     244: invokevirtual #80                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     247: nop
     248: aload_1
     249: areturn
}