package misc;

import kotlin.math.max
import kotlin.system.measureTimeMillis
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime

data class State(
    val rank: Int,
    val star: Int,
    val continuousWin: Int,
    val preserveStars: Int
)

class Solution {

    fun calc(starPerRank: Int, winPerPreserve: Int, totalWin: Int, targetRank: Int, gameRecord: String): Boolean {

        //缓存，好像除了浪费内存没啥用（
        val winCache = HashMap<State, State>()
        val failCache = HashMap<State, State>()

        //如果胜利，下一场次的状态
        fun State.win(): State = winCache.computeIfAbsent(this) {

            if (star == starPerRank) {
                State(
                    rank + 1,
                    1,
                    (continuousWin + 1) % winPerPreserve,
                    (continuousWin + 1) / winPerPreserve
                )
            } else {
                State(
                    rank,
                    star + 1,
                    (continuousWin + 1) % winPerPreserve,
                    (continuousWin + 1) / winPerPreserve
                )
            }
        }

        //如果失败，下一场次的状态
        fun State.fail(): State = failCache.computeIfAbsent(this) {
            if (preserveStars > 0) {
                State(
                    rank,
                    star,
                    0,
                    preserveStars - 1
                )
            } else if (star == 0) {
                State(
                    if (rank == 1) 1 else rank - 1,
                    starPerRank - 1,
                    0,
                    0
                )
            } else {
                State(
                    rank,
                    star + 1,
                    0,
                    0
                )
            }
        }
        //计算胜利场次数量

        val restWins = totalWin - gameRecord.count { it == '1' }

        var maxRank = 1

        //模拟
        fun simulate(i: Int, currentState: State, chooseWins: Int) {
            if (chooseWins > restWins) {
                return
            }
            if (i >= gameRecord.length) {
                if (chooseWins == restWins) {
                    maxRank = max(maxRank, currentState.rank)
                }
                return
            }
            when (gameRecord[i]) {
                '0' -> simulate(i + 1, currentState.fail(), chooseWins)
                '1' -> simulate(i + 1, currentState.win(), chooseWins)
                '?' -> {
                    simulate(i + 1, currentState.fail(), chooseWins)
                    simulate(i + 1, currentState.win(), chooseWins + 1)
                }
                else -> throw IllegalArgumentException("Game record should only contains '0', '1' and '?'")
            }
        }

        simulate(0, State(1, 1, 0, 0), 0)
        return maxRank >= targetRank
    }

    fun run() {
        val (m, d, B, C) = readLine()!!.split(" ").map { it.trim().toInt() }
        val S = readLine()!!.split(" ").filter { it.isNotEmpty() }.joinToString("") { it }

        val time = measureTimeMillis {
            val calc = calc(m, d, B, C, S)
            println(calc)
        }

        println("方法执行耗时 $time ms")

    }

}

fun main() {
    Solution().run()

}

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

  public final boolean calc(int, int, int, int, java.lang.String);
    Code:
       0: aload         5
       2: ldc           #15                 // String gameRecord
       4: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #23                 // class java/util/HashMap
      10: dup
      11: invokespecial #24                 // Method java/util/HashMap."<init>":()V
      14: astore        6
      16: new           #23                 // class java/util/HashMap
      19: dup
      20: invokespecial #24                 // Method java/util/HashMap."<init>":()V
      23: astore        7
      25: iload_3
      26: aload         5
      28: checkcast     #26                 // class java/lang/CharSequence
      31: astore        9
      33: istore        16
      35: iconst_0
      36: istore        10
      38: iconst_0
      39: istore        11
      41: iconst_0
      42: istore        12
      44: iload         12
      46: aload         9
      48: invokeinterface #30,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      53: if_icmpge     98
      56: aload         9
      58: iload         12
      60: invokeinterface #34,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      65: istore        13
      67: iload         13
      69: istore        14
      71: iconst_0
      72: istore        15
      74: iload         14
      76: bipush        49
      78: if_icmpne     85
      81: iconst_1
      82: goto          86
      85: iconst_0
      86: ifeq          92
      89: iinc          11, 1
      92: iinc          12, 1
      95: goto          44
      98: iload         11
     100: istore        17
     102: iload         16
     104: iload         17
     106: isub
     107: istore        8
     109: new           #36                 // class kotlin/jvm/internal/Ref$IntRef
     112: dup
     113: invokespecial #37                 // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
     116: astore        9
     118: aload         9
     120: iconst_1
     121: putfield      #41                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
     124: iload         8
     126: aload         5
     128: aload         9
     130: aload         7
     132: iload_1
     133: aload         6
     135: iload_2
     136: iconst_0
     137: new           #43                 // class misc/State
     140: dup
     141: iconst_1
     142: iconst_1
     143: iconst_0
     144: iconst_0
     145: invokespecial #46                 // Method misc/State."<init>":(IIII)V
     148: iconst_0
     149: invokestatic  #50                 // Method calc$simulate:(ILjava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/HashMap;ILjava/util/HashMap;IILmisc/State;I)V
     152: aload         9
     154: getfield      #41                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
     157: iload         4
     159: if_icmplt     166
     162: iconst_1
     163: goto          167
     166: iconst_0
     167: ireturn

  public final void run();
    Code:
       0: invokestatic  #78                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #82                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: checkcast     #26                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #71                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #84                 // String
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #92                 // class java/lang/Iterable
      32: astore_2
      33: iconst_0
      34: istore_3
      35: aload_2
      36: astore        4
      38: new           #94                 // class java/util/ArrayList
      41: dup
      42: aload_2
      43: bipush        10
      45: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      48: invokespecial #103                // Method java/util/ArrayList."<init>":(I)V
      51: checkcast     #105                // class java/util/Collection
      54: astore        5
      56: iconst_0
      57: istore        6
      59: aload         4
      61: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      66: astore        7
      68: aload         7
      70: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      75: ifeq          132
      78: aload         7
      80: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      85: astore        8
      87: aload         5
      89: aload         8
      91: checkcast     #71                 // class java/lang/String
      94: astore        9
      96: astore        16
      98: iconst_0
      99: istore        10
     101: nop
     102: aload         9
     104: checkcast     #26                 // class java/lang/CharSequence
     107: invokestatic  #123                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     110: invokevirtual #126                // Method java/lang/Object.toString:()Ljava/lang/String;
     113: invokestatic  #132                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     116: nop
     117: invokestatic  #136                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: aload         16
     122: swap
     123: invokeinterface #140,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     128: pop
     129: goto          68
     132: aload         5
     134: checkcast     #142                // class java/util/List
     137: nop
     138: astore_1
     139: aload_1
     140: iconst_0
     141: invokeinterface #146,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     146: checkcast     #148                // class java/lang/Number
     149: invokevirtual #151                // Method java/lang/Number.intValue:()I
     152: istore_2
     153: aload_1
     154: iconst_1
     155: invokeinterface #146,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     160: checkcast     #148                // class java/lang/Number
     163: invokevirtual #151                // Method java/lang/Number.intValue:()I
     166: istore_3
     167: aload_1
     168: iconst_2
     169: invokeinterface #146,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     174: checkcast     #148                // class java/lang/Number
     177: invokevirtual #151                // Method java/lang/Number.intValue:()I
     180: istore        4
     182: aload_1
     183: iconst_3
     184: invokeinterface #146,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     189: checkcast     #148                // class java/lang/Number
     192: invokevirtual #151                // Method java/lang/Number.intValue:()I
     195: istore        5
     197: invokestatic  #78                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
     200: dup
     201: invokestatic  #82                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     204: checkcast     #26                 // class java/lang/CharSequence
     207: iconst_1
     208: anewarray     #71                 // class java/lang/String
     211: astore        7
     213: aload         7
     215: iconst_0
     216: ldc           #84                 // String
     218: aastore
     219: aload         7
     221: iconst_0
     222: iconst_0
     223: bipush        6
     225: aconst_null
     226: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     229: checkcast     #92                 // class java/lang/Iterable
     232: astore        7
     234: iconst_0
     235: istore        8
     237: aload         7
     239: astore        9
     241: new           #94                 // class java/util/ArrayList
     244: dup
     245: invokespecial #152                // Method java/util/ArrayList."<init>":()V
     248: checkcast     #105                // class java/util/Collection
     251: astore        10
     253: iconst_0
     254: istore        11
     256: aload         9
     258: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     263: astore        12
     265: aload         12
     267: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     272: ifeq          329
     275: aload         12
     277: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     282: astore        13
     284: aload         13
     286: checkcast     #71                 // class java/lang/String
     289: astore        14
     291: iconst_0
     292: istore        15
     294: aload         14
     296: checkcast     #26                 // class java/lang/CharSequence
     299: invokeinterface #30,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     304: ifle          311
     307: iconst_1
     308: goto          312
     311: iconst_0
     312: nop
     313: ifeq          265
     316: aload         10
     318: aload         13
     320: invokeinterface #140,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     325: pop
     326: goto          265
     329: aload         10
     331: checkcast     #142                // class java/util/List
     334: nop
     335: checkcast     #92                 // class java/lang/Iterable
     338: ldc           #154                // String
     340: checkcast     #26                 // class java/lang/CharSequence
     343: aconst_null
     344: aconst_null
     345: iconst_0
     346: aconst_null
     347: invokedynamic #173,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     352: bipush        30
     354: aconst_null
     355: invokestatic  #177                // 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;
     358: astore        6
     360: iconst_0
     361: istore        9
     363: invokestatic  #183                // Method java/lang/System.currentTimeMillis:()J
     366: lstore        10
     368: iconst_0
     369: istore        12
     371: aload_0
     372: iload_2
     373: iload_3
     374: iload         4
     376: iload         5
     378: aload         6
     380: invokevirtual #185                // Method calc:(IIIILjava/lang/String;)Z
     383: istore        13
     385: getstatic     #189                // Field java/lang/System.out:Ljava/io/PrintStream;
     388: iload         13
     390: invokevirtual #195                // Method java/io/PrintStream.println:(Z)V
     393: nop
     394: nop
     395: invokestatic  #183                // Method java/lang/System.currentTimeMillis:()J
     398: lload         10
     400: lsub
     401: lstore        7
     403: new           #197                // class java/lang/StringBuilder
     406: dup
     407: invokespecial #198                // Method java/lang/StringBuilder."<init>":()V
     410: ldc           #200                // String 方法执行耗时
     412: invokevirtual #204                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     415: lload         7
     417: invokevirtual #207                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     420: ldc           #209                // String  ms
     422: invokevirtual #204                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     425: invokevirtual #210                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     428: getstatic     #189                // Field java/lang/System.out:Ljava/io/PrintStream;
     431: swap
     432: invokevirtual #212                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     435: return

  private static final misc.State calc$win$lambda$0(misc.State, int, int, misc.State);
    Code:
       0: aload_3
       1: ldc           #241                // String it
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #244                // Method misc/State.getStar:()I
      10: iload_1
      11: if_icmpne     47
      14: new           #43                 // class misc/State
      17: dup
      18: aload_0
      19: invokevirtual #247                // Method misc/State.getRank:()I
      22: iconst_1
      23: iadd
      24: iconst_1
      25: aload_0
      26: invokevirtual #250                // Method misc/State.getContinuousWin:()I
      29: iconst_1
      30: iadd
      31: iload_2
      32: irem
      33: aload_0
      34: invokevirtual #250                // Method misc/State.getContinuousWin:()I
      37: iconst_1
      38: iadd
      39: iload_2
      40: idiv
      41: invokespecial #46                 // Method misc/State."<init>":(IIII)V
      44: goto          80
      47: new           #43                 // class misc/State
      50: dup
      51: aload_0
      52: invokevirtual #247                // Method misc/State.getRank:()I
      55: aload_0
      56: invokevirtual #244                // Method misc/State.getStar:()I
      59: iconst_1
      60: iadd
      61: aload_0
      62: invokevirtual #250                // Method misc/State.getContinuousWin:()I
      65: iconst_1
      66: iadd
      67: iload_2
      68: irem
      69: aload_0
      70: invokevirtual #250                // Method misc/State.getContinuousWin:()I
      73: iconst_1
      74: iadd
      75: iload_2
      76: idiv
      77: invokespecial #46                 // Method misc/State."<init>":(IIII)V
      80: areturn

  private static final misc.State calc$win$lambda$1(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #260,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #43                 // class misc/State
      10: areturn

  private static final misc.State calc$win(misc.State, java.util.HashMap<misc.State, misc.State>, int, int);
    Code:
       0: aload_1
       1: aload_0
       2: aload_0
       3: iload_2
       4: iload_3
       5: invokedynamic #274,  0            // InvokeDynamic #1:invoke:(Lmisc/State;II)Lkotlin/jvm/functions/Function1;
      10: invokedynamic #283,  0            // InvokeDynamic #2:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
      15: invokevirtual #287                // Method java/util/HashMap.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
      18: dup
      19: ldc_w         #289                // String computeIfAbsent(...)
      22: invokestatic  #292                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      25: checkcast     #43                 // class misc/State
      28: areturn

  private static final misc.State calc$fail$lambda$2(misc.State, int, misc.State);
    Code:
       0: aload_2
       1: ldc           #241                // String it
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #298                // Method misc/State.getPreserveStars:()I
      10: ifle          38
      13: new           #43                 // class misc/State
      16: dup
      17: aload_0
      18: invokevirtual #247                // Method misc/State.getRank:()I
      21: aload_0
      22: invokevirtual #244                // Method misc/State.getStar:()I
      25: iconst_0
      26: aload_0
      27: invokevirtual #298                // Method misc/State.getPreserveStars:()I
      30: iconst_1
      31: isub
      32: invokespecial #46                 // Method misc/State."<init>":(IIII)V
      35: goto          97
      38: aload_0
      39: invokevirtual #244                // Method misc/State.getStar:()I
      42: ifne          78
      45: new           #43                 // class misc/State
      48: dup
      49: aload_0
      50: invokevirtual #247                // Method misc/State.getRank:()I
      53: iconst_1
      54: if_icmpne     61
      57: iconst_1
      58: goto          67
      61: aload_0
      62: invokevirtual #247                // Method misc/State.getRank:()I
      65: iconst_1
      66: isub
      67: iload_1
      68: iconst_1
      69: isub
      70: iconst_0
      71: iconst_0
      72: invokespecial #46                 // Method misc/State."<init>":(IIII)V
      75: goto          97
      78: new           #43                 // class misc/State
      81: dup
      82: aload_0
      83: invokevirtual #247                // Method misc/State.getRank:()I
      86: aload_0
      87: invokevirtual #244                // Method misc/State.getStar:()I
      90: iconst_1
      91: iadd
      92: iconst_0
      93: iconst_0
      94: invokespecial #46                 // Method misc/State."<init>":(IIII)V
      97: areturn

  private static final misc.State calc$fail$lambda$3(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #260,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #43                 // class misc/State
      10: areturn

  private static final misc.State calc$fail(misc.State, java.util.HashMap<misc.State, misc.State>, int);
    Code:
       0: aload_1
       1: aload_0
       2: aload_0
       3: iload_2
       4: invokedynamic #309,  0            // InvokeDynamic #3:invoke:(Lmisc/State;I)Lkotlin/jvm/functions/Function1;
       9: invokedynamic #313,  0            // InvokeDynamic #4:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
      14: invokevirtual #287                // Method java/util/HashMap.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
      17: dup
      18: ldc_w         #289                // String computeIfAbsent(...)
      21: invokestatic  #292                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      24: checkcast     #43                 // class misc/State
      27: areturn

  private static final void calc$simulate(int, java.lang.String, kotlin.jvm.internal.Ref$IntRef, java.util.HashMap<misc.State, misc.State>, int, java.util.HashMap<misc.State, misc.State>, int, int, misc.State, int);
    Code:
       0: iload         9
       2: iload_0
       3: if_icmple     7
       6: return
       7: iload         7
       9: aload_1
      10: invokevirtual #316                // Method java/lang/String.length:()I
      13: if_icmplt     39
      16: iload         9
      18: iload_0
      19: if_icmpne     38
      22: aload_2
      23: aload_2
      24: getfield      #41                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      27: aload         8
      29: invokevirtual #247                // Method misc/State.getRank:()I
      32: invokestatic  #322                // Method java/lang/Math.max:(II)I
      35: putfield      #41                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      38: return
      39: aload_1
      40: iload         7
      42: invokevirtual #323                // Method java/lang/String.charAt:(I)C
      45: lookupswitch  { // 3
                    48: 80
                    49: 110
                    63: 143
               default: 205
          }
      80: iload_0
      81: aload_1
      82: aload_2
      83: aload_3
      84: iload         4
      86: aload         5
      88: iload         6
      90: iload         7
      92: iconst_1
      93: iadd
      94: aload         8
      96: aload_3
      97: iload         4
      99: invokestatic  #325                // Method calc$fail:(Lmisc/State;Ljava/util/HashMap;I)Lmisc/State;
     102: iload         9
     104: invokestatic  #50                 // Method calc$simulate:(ILjava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/HashMap;ILjava/util/HashMap;IILmisc/State;I)V
     107: goto          216
     110: iload_0
     111: aload_1
     112: aload_2
     113: aload_3
     114: iload         4
     116: aload         5
     118: iload         6
     120: iload         7
     122: iconst_1
     123: iadd
     124: aload         8
     126: aload         5
     128: iload         4
     130: iload         6
     132: invokestatic  #327                // Method calc$win:(Lmisc/State;Ljava/util/HashMap;II)Lmisc/State;
     135: iload         9
     137: invokestatic  #50                 // Method calc$simulate:(ILjava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/HashMap;ILjava/util/HashMap;IILmisc/State;I)V
     140: goto          216
     143: iload_0
     144: aload_1
     145: aload_2
     146: aload_3
     147: iload         4
     149: aload         5
     151: iload         6
     153: iload         7
     155: iconst_1
     156: iadd
     157: aload         8
     159: aload_3
     160: iload         4
     162: invokestatic  #325                // Method calc$fail:(Lmisc/State;Ljava/util/HashMap;I)Lmisc/State;
     165: iload         9
     167: invokestatic  #50                 // Method calc$simulate:(ILjava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/HashMap;ILjava/util/HashMap;IILmisc/State;I)V
     170: iload_0
     171: aload_1
     172: aload_2
     173: aload_3
     174: iload         4
     176: aload         5
     178: iload         6
     180: iload         7
     182: iconst_1
     183: iadd
     184: aload         8
     186: aload         5
     188: iload         4
     190: iload         6
     192: invokestatic  #327                // Method calc$win:(Lmisc/State;Ljava/util/HashMap;II)Lmisc/State;
     195: iload         9
     197: iconst_1
     198: iadd
     199: invokestatic  #50                 // Method calc$simulate:(ILjava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/HashMap;ILjava/util/HashMap;IILmisc/State;I)V
     202: goto          216
     205: new           #329                // class java/lang/IllegalArgumentException
     208: dup
     209: ldc_w         #331                // String Game record should only contains \'0\', \'1\' and \'?\'
     212: invokespecial #334                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     215: athrow
     216: return

  private static final java.lang.CharSequence run$lambda$7(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #241                // String it
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #26                 // class java/lang/CharSequence
      10: areturn
}

Compiled from "Solution.kt"
public final class misc.SolutionKt {
  public static final void main();
    Code:
       0: new           #8                  // class misc/Solution
       3: dup
       4: invokespecial #11                 // Method misc/Solution."<init>":()V
       7: invokevirtual #14                 // Method misc/Solution.run:()V
      10: return

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


package y2015

fun runY2015D2(input: String): Pair<String, String> {
    val result = input.lines()
        .map { parse(it) }
        .map { calc(it) }
        .reduce { acc, pair -> Pair(acc.first + pair.first, acc.second + pair.second) }
    return Pair(result.first.toString(), result.second.toString())
}

private fun parse(input: String): List<Int> {
    val list = input.split("x").mapNotNull { it.toIntOrNull() }
    if (list.size == 3) {
        return list
    } else {
        throw IllegalStateException("Invalid number of sides: $input")
    }
}

private fun calc(input: List<Int>): Pair<Int, Int> {
    val highest = input.maxOrNull()!!
    val smallerSides = ArrayList(input).apply { remove(highest) }

    val paper = (2 * input[0] * input[1]) + (2 * input[1] * input[2]) + (2 * input[0] * input[2]) + (smallerSides[0] * smallerSides[1])
    val ribbon = (smallerSides[0] + smallerSides[0] + smallerSides[1] + smallerSides[1]) + (input[0] * input[1] * input[2])

    return Pair(paper, ribbon)
}

Compiled from "Day2.kt"
public final class y2015.Day2Kt {
  public static final kotlin.Pair<java.lang.String, java.lang.String> runY2015D2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/CharSequence
      10: invokestatic  #24                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      13: checkcast     #26                 // class java/lang/Iterable
      16: astore_2
      17: nop
      18: iconst_0
      19: istore_3
      20: aload_2
      21: astore        4
      23: new           #28                 // class java/util/ArrayList
      26: dup
      27: aload_2
      28: bipush        10
      30: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #40                 // class java/util/Collection
      39: astore        5
      41: iconst_0
      42: istore        6
      44: aload         4
      46: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        7
      53: aload         7
      55: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          103
      63: aload         7
      65: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        8
      72: aload         5
      74: aload         8
      76: checkcast     #56                 // class java/lang/String
      79: astore        9
      81: astore        11
      83: iconst_0
      84: istore        10
      86: aload         9
      88: invokestatic  #60                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
      91: aload         11
      93: swap
      94: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      99: pop
     100: goto          53
     103: aload         5
     105: checkcast     #66                 // class java/util/List
     108: nop
     109: checkcast     #26                 // class java/lang/Iterable
     112: astore_2
     113: nop
     114: iconst_0
     115: istore_3
     116: aload_2
     117: astore        4
     119: new           #28                 // class java/util/ArrayList
     122: dup
     123: aload_2
     124: bipush        10
     126: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     129: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     132: checkcast     #40                 // class java/util/Collection
     135: astore        5
     137: iconst_0
     138: istore        6
     140: aload         4
     142: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     147: astore        7
     149: aload         7
     151: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     156: ifeq          199
     159: aload         7
     161: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: astore        8
     168: aload         5
     170: aload         8
     172: checkcast     #66                 // class java/util/List
     175: astore        9
     177: astore        11
     179: iconst_0
     180: istore        10
     182: aload         9
     184: invokestatic  #70                 // Method calc:(Ljava/util/List;)Lkotlin/Pair;
     187: aload         11
     189: swap
     190: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     195: pop
     196: goto          149
     199: aload         5
     201: checkcast     #66                 // class java/util/List
     204: nop
     205: checkcast     #26                 // class java/lang/Iterable
     208: astore_2
     209: nop
     210: iconst_0
     211: istore_3
     212: aload_2
     213: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     218: astore        4
     220: aload         4
     222: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     227: ifne          240
     230: new           #72                 // class java/lang/UnsupportedOperationException
     233: dup
     234: ldc           #74                 // String Empty collection can\'t be reduced.
     236: invokespecial #77                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     239: athrow
     240: aload         4
     242: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     247: astore        5
     249: aload         4
     251: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     256: ifeq          345
     259: aload         5
     261: aload         4
     263: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     268: checkcast     #79                 // class kotlin/Pair
     271: astore        6
     273: checkcast     #79                 // class kotlin/Pair
     276: astore        7
     278: iconst_0
     279: istore        8
     281: new           #79                 // class kotlin/Pair
     284: dup
     285: aload         7
     287: invokevirtual #82                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     290: checkcast     #84                 // class java/lang/Number
     293: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     296: aload         6
     298: invokevirtual #82                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     301: checkcast     #84                 // class java/lang/Number
     304: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     307: iadd
     308: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     311: aload         7
     313: invokevirtual #97                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     316: checkcast     #84                 // class java/lang/Number
     319: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     322: aload         6
     324: invokevirtual #97                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     327: checkcast     #84                 // class java/lang/Number
     330: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     333: iadd
     334: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     337: invokespecial #100                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     340: astore        5
     342: goto          249
     345: aload         5
     347: checkcast     #79                 // class kotlin/Pair
     350: astore_1
     351: new           #79                 // class kotlin/Pair
     354: dup
     355: aload_1
     356: invokevirtual #82                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     359: checkcast     #84                 // class java/lang/Number
     362: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     365: invokestatic  #103                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     368: aload_1
     369: invokevirtual #97                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     372: checkcast     #84                 // class java/lang/Number
     375: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     378: invokestatic  #103                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     381: invokespecial #100                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     384: areturn

  private static final java.util.List<java.lang.Integer> parse(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #18                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #56                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #131                // String x
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #135                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #26                 // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #28                 // class java/util/ArrayList
      35: dup
      36: invokespecial #138                // Method java/util/ArrayList."<init>":()V
      39: checkcast     #40                 // class java/util/Collection
      42: astore        5
      44: iconst_0
      45: istore        6
      47: aload         4
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload         7
      56: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        9
      63: aload         9
      65: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          131
      73: aload         9
      75: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        10
      82: aload         10
      84: astore        11
      86: iconst_0
      87: istore        12
      89: aload         11
      91: checkcast     #56                 // class java/lang/String
      94: astore        13
      96: iconst_0
      97: istore        14
      99: aload         13
     101: invokestatic  #142                // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;
     104: dup
     105: ifnull        126
     108: astore        15
     110: iconst_0
     111: istore        16
     113: aload         5
     115: aload         15
     117: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     122: pop
     123: goto          127
     126: pop
     127: nop
     128: goto          63
     131: nop
     132: aload         5
     134: checkcast     #66                 // class java/util/List
     137: nop
     138: astore_1
     139: aload_1
     140: invokeinterface #145,  1          // InterfaceMethod java/util/List.size:()I
     145: iconst_3
     146: if_icmpne     151
     149: aload_1
     150: areturn
     151: new           #147                // class java/lang/IllegalStateException
     154: dup
     155: new           #149                // class java/lang/StringBuilder
     158: dup
     159: invokespecial #150                // Method java/lang/StringBuilder."<init>":()V
     162: ldc           #152                // String Invalid number of sides:
     164: invokevirtual #156                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     167: aload_0
     168: invokevirtual #156                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     171: invokevirtual #160                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     174: invokespecial #161                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     177: athrow

  private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> calc(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #26                 // class java/lang/Iterable
       4: invokestatic  #179                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
       7: dup
       8: invokestatic  #183                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      11: checkcast     #84                 // class java/lang/Number
      14: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: new           #28                 // class java/util/ArrayList
      21: dup
      22: aload_0
      23: checkcast     #40                 // class java/util/Collection
      26: invokespecial #186                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
      29: astore_3
      30: aload_3
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload         4
      38: iload_1
      39: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      42: invokevirtual #189                // Method java/util/ArrayList.remove:(Ljava/lang/Object;)Z
      45: pop
      46: aload_3
      47: astore_2
      48: iconst_2
      49: aload_0
      50: iconst_0
      51: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      56: checkcast     #84                 // class java/lang/Number
      59: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      62: imul
      63: aload_0
      64: iconst_1
      65: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      70: checkcast     #84                 // class java/lang/Number
      73: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      76: imul
      77: iconst_2
      78: aload_0
      79: iconst_1
      80: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      85: checkcast     #84                 // class java/lang/Number
      88: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      91: imul
      92: aload_0
      93: iconst_2
      94: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      99: checkcast     #84                 // class java/lang/Number
     102: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     105: imul
     106: iadd
     107: iconst_2
     108: aload_0
     109: iconst_0
     110: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #84                 // class java/lang/Number
     118: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     121: imul
     122: aload_0
     123: iconst_2
     124: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #84                 // class java/lang/Number
     132: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     135: imul
     136: iadd
     137: aload_2
     138: iconst_0
     139: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     142: checkcast     #84                 // class java/lang/Number
     145: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     148: aload_2
     149: iconst_1
     150: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     153: dup
     154: ldc           #196                // String get(...)
     156: invokestatic  #199                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     159: checkcast     #84                 // class java/lang/Number
     162: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     165: imul
     166: iadd
     167: istore_3
     168: aload_2
     169: iconst_0
     170: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     173: checkcast     #84                 // class java/lang/Number
     176: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     179: aload_2
     180: iconst_0
     181: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     184: dup
     185: ldc           #196                // String get(...)
     187: invokestatic  #199                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     190: checkcast     #84                 // class java/lang/Number
     193: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     196: iadd
     197: aload_2
     198: iconst_1
     199: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     202: dup
     203: ldc           #196                // String get(...)
     205: invokestatic  #199                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     208: checkcast     #84                 // class java/lang/Number
     211: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     214: iadd
     215: aload_2
     216: iconst_1
     217: invokevirtual #194                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     220: dup
     221: ldc           #196                // String get(...)
     223: invokestatic  #199                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     226: checkcast     #84                 // class java/lang/Number
     229: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     232: iadd
     233: aload_0
     234: iconst_0
     235: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     240: checkcast     #84                 // class java/lang/Number
     243: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     246: aload_0
     247: iconst_1
     248: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     253: checkcast     #84                 // class java/lang/Number
     256: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     259: imul
     260: aload_0
     261: iconst_2
     262: invokeinterface #193,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     267: checkcast     #84                 // class java/lang/Number
     270: invokevirtual #88                 // Method java/lang/Number.intValue:()I
     273: imul
     274: iadd
     275: istore        4
     277: new           #79                 // class kotlin/Pair
     280: dup
     281: iload_3
     282: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     285: iload         4
     287: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     290: invokespecial #100                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     293: areturn
}


package y2016

import kotlin.math.abs

fun runY2016D1(input: String): Pair<String, String> {
    val steps = input.split(",")
        .map { parse(it.trim()) }

    val (distance, firstRepeat) = travel(steps)

    return Pair(distance.toString(), firstRepeat.toString())
}

fun parse(input: String): Move {
    if (input.length == 1) {
        throw IllegalArgumentException("Too short: $input")
    }
    val number = input.substring(1).toIntOrNull() ?: throw IllegalArgumentException("Invalid number: $input")
    return when (input.first()) {
        'R' -> Move.Right(number)
        'L' -> Move.Left(number)
        else -> throw IllegalArgumentException("Invalid letter: $input")
    }
}

fun travel(moves: List<Move>): Pair<Int, Int> {
    val visited = HashSet<Coord>()
    val pos = Coord(0,0)
    var dir = Direction.North
    var firstRepeat: Coord? = null
    for (move in moves) {
        dir = dir.update(move)
        val walked = pos.walk(dir, move)
        for (step in walked) {
            if (firstRepeat == null) {
                if (visited.contains(step)) {
                    firstRepeat = step
                }
                println("Visited ${step.x},${step.y}");
                visited.add(step)
            }
        }
    }
    return Pair(pos.distance(), firstRepeat?.distance() ?: 0)
}

data class Coord(
    var x: Int,
    var y: Int
) {
    fun distance(): Int {
        return abs(x) + abs(y)
    }

    fun walk(dir: Direction, move: Move): List<Coord> {
        var list = listOf<Coord>()
        when (dir) {
            Direction.North -> {
                list = (1..move.dist).map { Coord(this.x, this.y + it) }
                this.y += move.dist
            }
            Direction.East -> {
                list = (1..move.dist).map { Coord(this.x + it, this.y) }
                this.x += move.dist
            }
            Direction.South -> {
                list = (1..move.dist).map { Coord(this.x, this.y - it) }
                this.y -= move.dist
            }
            Direction.West -> {
                list = (1..move.dist).map { Coord(this.x - it, this.y) }
                this.x -= move.dist
            }
        }
        return list
    }
}

enum class Direction {
    North,
    East,
    South,
    West;

    fun update(move: Move): Direction {
        return when (this) {
            North -> if (move is Move.Left) West else East
            East -> if (move is Move.Left) North else South
            South -> if (move is Move.Left) East else West
            West -> if (move is Move.Left) South else North
        }
    }
}

sealed class Move(val dist: Int) {
    class Left(dist: Int): Move(dist)
    class Right(dist: Int): Move(dist)
}

Compiled from "Day1.kt"
public final class y2016.Day1Kt {
  public static final kotlin.Pair<java.lang.String, java.lang.String> runY2016D1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #20                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #22                 // String ,
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #30                 // class java/lang/Iterable
      32: astore_2
      33: nop
      34: iconst_0
      35: istore_3
      36: aload_2
      37: astore        4
      39: new           #32                 // class java/util/ArrayList
      42: dup
      43: aload_2
      44: bipush        10
      46: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #44                 // class java/util/Collection
      55: astore        5
      57: iconst_0
      58: istore        6
      60: aload         4
      62: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        7
      69: aload         7
      71: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          128
      79: aload         7
      81: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        8
      88: aload         5
      90: aload         8
      92: checkcast     #20                 // class java/lang/String
      95: astore        9
      97: astore        11
      99: iconst_0
     100: istore        10
     102: aload         9
     104: checkcast     #18                 // class java/lang/CharSequence
     107: invokestatic  #62                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     110: invokevirtual #66                 // Method java/lang/Object.toString:()Ljava/lang/String;
     113: invokestatic  #70                 // Method parse:(Ljava/lang/String;)Ly2016/Move;
     116: aload         11
     118: swap
     119: invokeinterface #74,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          69
     128: aload         5
     130: checkcast     #76                 // class java/util/List
     133: nop
     134: astore_1
     135: aload_1
     136: invokestatic  #80                 // Method travel:(Ljava/util/List;)Lkotlin/Pair;
     139: astore_2
     140: aload_2
     141: invokevirtual #85                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     144: checkcast     #87                 // class java/lang/Number
     147: invokevirtual #91                 // Method java/lang/Number.intValue:()I
     150: istore_3
     151: aload_2
     152: invokevirtual #94                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     155: checkcast     #87                 // class java/lang/Number
     158: invokevirtual #91                 // Method java/lang/Number.intValue:()I
     161: istore        4
     163: new           #82                 // class kotlin/Pair
     166: dup
     167: iload_3
     168: invokestatic  #98                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     171: iload         4
     173: invokestatic  #98                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     176: invokespecial #101                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     179: areturn

  public static final y2016.Move parse(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #121                // Method java/lang/String.length:()I
      10: iconst_1
      11: if_icmpne     41
      14: new           #123                // class java/lang/IllegalArgumentException
      17: dup
      18: new           #125                // class java/lang/StringBuilder
      21: dup
      22: invokespecial #128                // Method java/lang/StringBuilder."<init>":()V
      25: ldc           #130                // String Too short:
      27: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: aload_0
      31: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      34: invokevirtual #135                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      37: invokespecial #138                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      40: athrow
      41: aload_0
      42: iconst_1
      43: invokevirtual #141                // Method java/lang/String.substring:(I)Ljava/lang/String;
      46: dup
      47: ldc           #143                // String substring(...)
      49: invokestatic  #146                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      52: invokestatic  #150                // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;
      55: dup
      56: ifnull        65
      59: invokevirtual #153                // Method java/lang/Integer.intValue:()I
      62: goto          93
      65: pop
      66: new           #123                // class java/lang/IllegalArgumentException
      69: dup
      70: new           #125                // class java/lang/StringBuilder
      73: dup
      74: invokespecial #128                // Method java/lang/StringBuilder."<init>":()V
      77: ldc           #155                // String Invalid number:
      79: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      82: aload_0
      83: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      86: invokevirtual #135                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      89: invokespecial #138                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      92: athrow
      93: istore_1
      94: aload_0
      95: checkcast     #18                 // class java/lang/CharSequence
      98: invokestatic  #159                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     101: lookupswitch  { // 2
                    76: 142
                    82: 128
               default: 156
          }
     128: new           #161                // class y2016/Move$Right
     131: dup
     132: iload_1
     133: invokespecial #162                // Method y2016/Move$Right."<init>":(I)V
     136: checkcast     #164                // class y2016/Move
     139: goto          183
     142: new           #166                // class y2016/Move$Left
     145: dup
     146: iload_1
     147: invokespecial #167                // Method y2016/Move$Left."<init>":(I)V
     150: checkcast     #164                // class y2016/Move
     153: goto          183
     156: new           #123                // class java/lang/IllegalArgumentException
     159: dup
     160: new           #125                // class java/lang/StringBuilder
     163: dup
     164: invokespecial #128                // Method java/lang/StringBuilder."<init>":()V
     167: ldc           #169                // String Invalid letter:
     169: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     172: aload_0
     173: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     176: invokevirtual #135                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     179: invokespecial #138                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     182: athrow
     183: areturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> travel(java.util.List<? extends y2016.Move>);
    Code:
       0: aload_0
       1: ldc           #173                // String moves
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #175                // class java/util/HashSet
       9: dup
      10: invokespecial #176                // Method java/util/HashSet."<init>":()V
      13: astore_1
      14: new           #178                // class y2016/Coord
      17: dup
      18: iconst_0
      19: iconst_0
      20: invokespecial #181                // Method y2016/Coord."<init>":(II)V
      23: astore_2
      24: getstatic     #187                // Field y2016/Direction.North:Ly2016/Direction;
      27: astore_3
      28: aconst_null
      29: astore        4
      31: aload_0
      32: invokeinterface #188,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          179
      49: aload         5
      51: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: checkcast     #164                // class y2016/Move
      59: astore        6
      61: aload_3
      62: aload         6
      64: invokevirtual #192                // Method y2016/Direction.update:(Ly2016/Move;)Ly2016/Direction;
      67: astore_3
      68: aload_2
      69: aload_3
      70: aload         6
      72: invokevirtual #196                // Method y2016/Coord.walk:(Ly2016/Direction;Ly2016/Move;)Ljava/util/List;
      75: astore        7
      77: aload         7
      79: invokeinterface #188,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      84: astore        8
      86: aload         8
      88: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      93: ifeq          39
      96: aload         8
      98: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     103: checkcast     #178                // class y2016/Coord
     106: astore        9
     108: aload         4
     110: ifnonnull     86
     113: aload_1
     114: aload         9
     116: invokevirtual #199                // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z
     119: ifeq          126
     122: aload         9
     124: astore        4
     126: new           #125                // class java/lang/StringBuilder
     129: dup
     130: invokespecial #128                // Method java/lang/StringBuilder."<init>":()V
     133: ldc           #201                // String Visited
     135: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     138: aload         9
     140: invokevirtual #204                // Method y2016/Coord.getX:()I
     143: invokevirtual #207                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     146: bipush        44
     148: invokevirtual #210                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     151: aload         9
     153: invokevirtual #213                // Method y2016/Coord.getY:()I
     156: invokevirtual #207                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     159: invokevirtual #135                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     162: getstatic     #219                // Field java/lang/System.out:Ljava/io/PrintStream;
     165: swap
     166: invokevirtual #225                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     169: aload_1
     170: aload         9
     172: invokevirtual #226                // Method java/util/HashSet.add:(Ljava/lang/Object;)Z
     175: pop
     176: goto          86
     179: new           #82                 // class kotlin/Pair
     182: dup
     183: aload_2
     184: invokevirtual #228                // Method y2016/Coord.distance:()I
     187: invokestatic  #231                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     190: aload         4
     192: dup
     193: ifnull        202
     196: invokevirtual #228                // Method y2016/Coord.distance:()I
     199: goto          204
     202: pop
     203: iconst_0
     204: invokestatic  #231                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     207: invokespecial #101                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     210: areturn
}


package ru.spbstu.wheels

inline class ComparatorScope<T>(val comparator: Comparator<T>) {
    operator fun T.compareTo(that: T) = comparator.compare(this, that)

    fun Iterable<T>.maxOrNull() = maxWithOrNull(comparator)
    fun Iterable<T>.minOrNull() = minWithOrNull(comparator)
    fun Collection<T>.sorted() = sortedWith(comparator)
    fun MutableList<T>.sort() = sortWith(comparator)
}

inline fun <T, R> Comparator<T>.use(body: ComparatorScope<T>.() -> R) = ComparatorScope(this).body()

fun combineCompares(cmp0: Int, cmp1: Int): Int = when {
    cmp0 != 0 -> cmp0
    else -> cmp1
}

fun combineCompares(cmp0: Int, cmp1: Int, cmp2: Int): Int = when {
    cmp0 != 0 -> cmp0
    cmp1 != 0 -> cmp1
    else -> cmp2
}

fun combineCompares(vararg cmps: Int): Int = cmps.find { it != 0 } ?: 0

fun <A: Comparable<A>> Pair<A, A>.sorted() = when {
    first <= second -> this
    else -> second to first
}

fun <A> Pair<A, A>.sortedWith(cmp: Comparator<A>) = cmp.use {
    when {
        first <= second -> this@sortedWith
        else -> second to first
    }
}

fun <A> Triple<A, A, A>.sortedWith(cmp: Comparator<A>) = cmp.use {
    when {
        first <= second -> when {
            // first <= second && second <= third
            second <= third -> this@sortedWith // Triple(first, second, third)
            // first <= second && third < second && first <= third
            // => first <= third < second
            first <= third -> Triple(first, third, second)
            // first <= second && third < second && third < first
            // => third < first <= second
            else -> Triple(third, first, second)
        }
        // second < first
        else -> when {
            // second < first && third <= second
            // => third <= second < first
            third <= second -> Triple(third, second, first)
            // second < first && second < third && third <= first
            // => second < third <= first
            third <= first -> Triple(second, third, first)
            // second < first && second < third && first < third
            // => second < first < third
            else -> Triple(second, first, third)
        }
    }
}

fun <A: Comparable<A>> Triple<A, A, A>.sorted() = sortedWith(naturalOrder())

Compiled from "Comparables.kt"
public final class ru.spbstu.wheels.ComparablesKt {
  public static final <T, R> R use(java.util.Comparator<T>, kotlin.jvm.functions.Function1<? super ru.spbstu.wheels.ComparatorScope<T>, ? extends R>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String body
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aload_1
      15: aload_0
      16: invokestatic  #24                 // Method ru/spbstu/wheels/ComparatorScope."constructor-impl":(Ljava/util/Comparator;)Ljava/util/Comparator;
      19: invokestatic  #28                 // Method ru/spbstu/wheels/ComparatorScope."box-impl":(Ljava/util/Comparator;)Lru/spbstu/wheels/ComparatorScope;
      22: invokeinterface #34,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      27: areturn

  public static final int combineCompares(int, int);
    Code:
       0: nop
       1: iload_0
       2: ifeq          9
       5: iload_0
       6: goto          10
       9: iload_1
      10: ireturn

  public static final int combineCompares(int, int, int);
    Code:
       0: nop
       1: iload_0
       2: ifeq          9
       5: iload_0
       6: goto          18
       9: iload_1
      10: ifeq          17
      13: iload_1
      14: goto          18
      17: iload_2
      18: ireturn

  public static final int combineCompares(int...);
    Code:
       0: aload_0
       1: ldc           #48                 // String cmps
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: arraylength
      12: istore_3
      13: iload_2
      14: iload_3
      15: if_icmpge     57
      18: aload_1
      19: iload_2
      20: iaload
      21: istore        4
      23: iload         4
      25: istore        5
      27: iconst_0
      28: istore        6
      30: iload         5
      32: ifeq          39
      35: iconst_1
      36: goto          40
      39: iconst_0
      40: ifeq          51
      43: iload         4
      45: invokestatic  #54                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: goto          58
      51: iinc          2, 1
      54: goto          13
      57: aconst_null
      58: dup
      59: ifnull        68
      62: invokevirtual #58                 // Method java/lang/Integer.intValue:()I
      65: goto          70
      68: pop
      69: iconst_0
      70: ireturn

  public static final <A extends java.lang.Comparable<? super A>> kotlin.Pair<A, A> sorted(kotlin.Pair<? extends A, ? extends A>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: aload_0
       8: invokevirtual #71                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      11: checkcast     #73                 // class java/lang/Comparable
      14: aload_0
      15: invokevirtual #76                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      18: invokeinterface #80,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      23: ifgt          30
      26: aload_0
      27: goto          41
      30: aload_0
      31: invokevirtual #76                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      34: aload_0
      35: invokevirtual #71                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      38: invokestatic  #86                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      41: areturn

  public static final <A> kotlin.Pair<A, A> sortedWith(kotlin.Pair<? extends A, ? extends A>, java.util.Comparator<A>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #93                 // String cmp
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: invokestatic  #24                 // Method ru/spbstu/wheels/ComparatorScope."constructor-impl":(Ljava/util/Comparator;)Ljava/util/Comparator;
      20: astore        4
      22: iconst_0
      23: istore        5
      25: nop
      26: aload         4
      28: aload_0
      29: invokevirtual #71                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      32: aload_0
      33: invokevirtual #76                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      36: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
      39: ifgt          46
      42: aload_0
      43: goto          57
      46: aload_0
      47: invokevirtual #76                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      50: aload_0
      51: invokevirtual #71                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      54: invokestatic  #86                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      57: nop
      58: nop
      59: areturn

  public static final <A> kotlin.Triple<A, A, A> sortedWith(kotlin.Triple<? extends A, ? extends A, ? extends A>, java.util.Comparator<A>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #93                 // String cmp
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: invokestatic  #24                 // Method ru/spbstu/wheels/ComparatorScope."constructor-impl":(Ljava/util/Comparator;)Ljava/util/Comparator;
      20: astore        4
      22: iconst_0
      23: istore        5
      25: nop
      26: aload         4
      28: aload_0
      29: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      32: aload_0
      33: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
      36: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
      39: ifgt          122
      42: aload         4
      44: aload_0
      45: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
      48: aload_0
      49: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
      52: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
      55: ifgt          62
      58: aload_0
      59: goto          218
      62: aload         4
      64: aload_0
      65: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      68: aload_0
      69: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
      72: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
      75: ifgt          100
      78: new           #107                // class kotlin/Triple
      81: dup
      82: aload_0
      83: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      86: aload_0
      87: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
      90: aload_0
      91: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
      94: invokespecial #116                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      97: goto          218
     100: new           #107                // class kotlin/Triple
     103: dup
     104: aload_0
     105: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     108: aload_0
     109: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     112: aload_0
     113: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     116: invokespecial #116                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     119: goto          218
     122: nop
     123: aload         4
     125: aload_0
     126: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     129: aload_0
     130: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     133: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
     136: ifgt          161
     139: new           #107                // class kotlin/Triple
     142: dup
     143: aload_0
     144: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     147: aload_0
     148: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     151: aload_0
     152: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     155: invokespecial #116                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     158: goto          218
     161: aload         4
     163: aload_0
     164: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     167: aload_0
     168: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     171: invokestatic  #97                 // Method ru/spbstu/wheels/ComparatorScope."compareTo-impl":(Ljava/util/Comparator;Ljava/lang/Object;Ljava/lang/Object;)I
     174: ifgt          199
     177: new           #107                // class kotlin/Triple
     180: dup
     181: aload_0
     182: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     185: aload_0
     186: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     189: aload_0
     190: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     193: invokespecial #116                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     196: goto          218
     199: new           #107                // class kotlin/Triple
     202: dup
     203: aload_0
     204: invokevirtual #109                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     207: aload_0
     208: invokevirtual #108                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     211: aload_0
     212: invokevirtual #112                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     215: invokespecial #116                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     218: nop
     219: nop
     220: areturn

  public static final <A extends java.lang.Comparable<? super A>> kotlin.Triple<A, A, A> sorted(kotlin.Triple<? extends A, ? extends A, ? extends A>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #127                // Method kotlin/comparisons/ComparisonsKt.naturalOrder:()Ljava/util/Comparator;
      10: invokestatic  #129                // Method sortedWith:(Lkotlin/Triple;Ljava/util/Comparator;)Lkotlin/Triple;
      13: areturn
}