/**
 *  Algorithm: Diameter of Binary Tree
 *  Language: Kotlin
 *  Input:
 *      Sample Binary Tree
 *  Output:
 *      Diameter of Binary Tree
 *  Time Complexity: O(n) as we are visiting every node once.
 *  Space Complexity: O(d) where d is the depth of the binary tree
 *
 *  Sample Input:
 *          8
 *        /   \
 *      3      10
 *    /  \       \
 *   1    6       14
 *      /  \     /
 *     4   7   13
 *
 *  Sample Output:
 *  Diameter of Binary Tree: 6
 */

import kotlin.math.max

class BinaryTree(var value: Int) {
    var leftChild: BinaryTree? = null
    var rightChild: BinaryTree? = null
}

class DiameterBinaryTree {
    private fun dfs(root: BinaryTree?): Pair<Int, Int> {
        if (root == null) {
            return Pair(0, 0)
        }
        val leftChild = dfs(root.leftChild)
        val rightChild = dfs(root.rightChild)
        val diameter = max(leftChild.first, max(rightChild.first, leftChild.second + rightChild.second))
        return Pair(diameter, max(leftChild.second, rightChild.second) + 1)
    }

    fun diameterOfBinaryTree(root: BinaryTree?): Int {
        return dfs(root).first
    }
}

fun main() {
    val tree = BinaryTree(8)
    tree.leftChild = BinaryTree(3)
    tree.rightChild = BinaryTree(10)
    tree.leftChild?.leftChild = BinaryTree(1)
    tree.leftChild?.rightChild = BinaryTree(6)
    tree.leftChild?.rightChild?.leftChild = BinaryTree(4)
    tree.leftChild?.rightChild?.rightChild = BinaryTree(7)
    tree.rightChild?.rightChild = BinaryTree(14)
    tree.rightChild?.rightChild?.leftChild = BinaryTree(13)

    val diam = DiameterBinaryTree()
    val diameter = diam.diameterOfBinaryTree(tree)
    println("Diameter of Binary Tree: $diameter")
}

Compiled from "DiameterBinaryTree.kt"
public final class DiameterBinaryTreeKt {
  public static final void main();
    Code:
       0: new           #8                  // class BinaryTree
       3: dup
       4: bipush        8
       6: invokespecial #12                 // Method BinaryTree."<init>":(I)V
       9: astore_0
      10: aload_0
      11: new           #8                  // class BinaryTree
      14: dup
      15: iconst_3
      16: invokespecial #12                 // Method BinaryTree."<init>":(I)V
      19: invokevirtual #16                 // Method BinaryTree.setLeftChild:(LBinaryTree;)V
      22: aload_0
      23: new           #8                  // class BinaryTree
      26: dup
      27: bipush        10
      29: invokespecial #12                 // Method BinaryTree."<init>":(I)V
      32: invokevirtual #19                 // Method BinaryTree.setRightChild:(LBinaryTree;)V
      35: aload_0
      36: invokevirtual #23                 // Method BinaryTree.getLeftChild:()LBinaryTree;
      39: dup
      40: ifnull        57
      43: new           #8                  // class BinaryTree
      46: dup
      47: iconst_1
      48: invokespecial #12                 // Method BinaryTree."<init>":(I)V
      51: invokevirtual #16                 // Method BinaryTree.setLeftChild:(LBinaryTree;)V
      54: goto          58
      57: pop
      58: aload_0
      59: invokevirtual #23                 // Method BinaryTree.getLeftChild:()LBinaryTree;
      62: dup
      63: ifnull        81
      66: new           #8                  // class BinaryTree
      69: dup
      70: bipush        6
      72: invokespecial #12                 // Method BinaryTree."<init>":(I)V
      75: invokevirtual #19                 // Method BinaryTree.setRightChild:(LBinaryTree;)V
      78: goto          82
      81: pop
      82: aload_0
      83: invokevirtual #23                 // Method BinaryTree.getLeftChild:()LBinaryTree;
      86: dup
      87: ifnull        111
      90: invokevirtual #26                 // Method BinaryTree.getRightChild:()LBinaryTree;
      93: dup
      94: ifnull        111
      97: new           #8                  // class BinaryTree
     100: dup
     101: iconst_4
     102: invokespecial #12                 // Method BinaryTree."<init>":(I)V
     105: invokevirtual #16                 // Method BinaryTree.setLeftChild:(LBinaryTree;)V
     108: goto          112
     111: pop
     112: aload_0
     113: invokevirtual #23                 // Method BinaryTree.getLeftChild:()LBinaryTree;
     116: dup
     117: ifnull        142
     120: invokevirtual #26                 // Method BinaryTree.getRightChild:()LBinaryTree;
     123: dup
     124: ifnull        142
     127: new           #8                  // class BinaryTree
     130: dup
     131: bipush        7
     133: invokespecial #12                 // Method BinaryTree."<init>":(I)V
     136: invokevirtual #19                 // Method BinaryTree.setRightChild:(LBinaryTree;)V
     139: goto          143
     142: pop
     143: aload_0
     144: invokevirtual #26                 // Method BinaryTree.getRightChild:()LBinaryTree;
     147: dup
     148: ifnull        166
     151: new           #8                  // class BinaryTree
     154: dup
     155: bipush        14
     157: invokespecial #12                 // Method BinaryTree."<init>":(I)V
     160: invokevirtual #19                 // Method BinaryTree.setRightChild:(LBinaryTree;)V
     163: goto          167
     166: pop
     167: aload_0
     168: invokevirtual #26                 // Method BinaryTree.getRightChild:()LBinaryTree;
     171: dup
     172: ifnull        197
     175: invokevirtual #26                 // Method BinaryTree.getRightChild:()LBinaryTree;
     178: dup
     179: ifnull        197
     182: new           #8                  // class BinaryTree
     185: dup
     186: bipush        13
     188: invokespecial #12                 // Method BinaryTree."<init>":(I)V
     191: invokevirtual #16                 // Method BinaryTree.setLeftChild:(LBinaryTree;)V
     194: goto          198
     197: pop
     198: new           #28                 // class DiameterBinaryTree
     201: dup
     202: invokespecial #30                 // Method DiameterBinaryTree."<init>":()V
     205: astore_1
     206: aload_1
     207: aload_0
     208: invokevirtual #34                 // Method DiameterBinaryTree.diameterOfBinaryTree:(LBinaryTree;)I
     211: istore_2
     212: new           #36                 // class java/lang/StringBuilder
     215: dup
     216: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
     219: ldc           #39                 // String Diameter of Binary Tree:
     221: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     224: iload_2
     225: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     228: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     231: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     234: swap
     235: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     238: return

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

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

  private final kotlin.Pair<java.lang.Integer, java.lang.Integer> dfs(BinaryTree);
    Code:
       0: aload_1
       1: ifnonnull     20
       4: new           #15                 // class kotlin/Pair
       7: dup
       8: iconst_0
       9: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: iconst_0
      13: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      16: invokespecial #24                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      19: areturn
      20: aload_0
      21: aload_1
      22: invokevirtual #30                 // Method BinaryTree.getLeftChild:()LBinaryTree;
      25: invokespecial #32                 // Method dfs:(LBinaryTree;)Lkotlin/Pair;
      28: astore_2
      29: aload_0
      30: aload_1
      31: invokevirtual #35                 // Method BinaryTree.getRightChild:()LBinaryTree;
      34: invokespecial #32                 // Method dfs:(LBinaryTree;)Lkotlin/Pair;
      37: astore_3
      38: nop
      39: aload_2
      40: invokevirtual #39                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      43: checkcast     #41                 // class java/lang/Number
      46: invokevirtual #45                 // Method java/lang/Number.intValue:()I
      49: aload_3
      50: invokevirtual #39                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      53: checkcast     #41                 // class java/lang/Number
      56: invokevirtual #45                 // Method java/lang/Number.intValue:()I
      59: aload_2
      60: invokevirtual #48                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      63: checkcast     #41                 // class java/lang/Number
      66: invokevirtual #45                 // Method java/lang/Number.intValue:()I
      69: aload_3
      70: invokevirtual #48                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      73: checkcast     #41                 // class java/lang/Number
      76: invokevirtual #45                 // Method java/lang/Number.intValue:()I
      79: iadd
      80: invokestatic  #54                 // Method java/lang/Math.max:(II)I
      83: invokestatic  #54                 // Method java/lang/Math.max:(II)I
      86: istore        4
      88: new           #15                 // class kotlin/Pair
      91: dup
      92: iload         4
      94: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      97: aload_2
      98: invokevirtual #48                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     101: checkcast     #41                 // class java/lang/Number
     104: invokevirtual #45                 // Method java/lang/Number.intValue:()I
     107: aload_3
     108: invokevirtual #48                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     111: checkcast     #41                 // class java/lang/Number
     114: invokevirtual #45                 // Method java/lang/Number.intValue:()I
     117: invokestatic  #54                 // Method java/lang/Math.max:(II)I
     120: iconst_1
     121: iadd
     122: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     125: invokespecial #24                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     128: areturn

  public final int diameterOfBinaryTree(BinaryTree);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #32                 // Method dfs:(LBinaryTree;)Lkotlin/Pair;
       5: invokevirtual #39                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       8: checkcast     #41                 // class java/lang/Number
      11: invokevirtual #45                 // Method java/lang/Number.intValue:()I
      14: ireturn
}


/**
 *  Algorithm: Longest Common Sub-Sequence using Dynamic Programming
 *  Language: Kotlin
 *  Input:
 *      String1 and String2 -> Two Strings
 *  Output:
 *      Integer -> The longest common sub-sequence of String1 and String2
 *  Time Complexity: O(nStr1*nStr2)
 *  Space Complexity: O(nStr1*nStr2)
 *
 *  Sample Input:
 *      Enter the first String:
 *          AGGTAB
 *      Enter the second String:
 *          GXTXAYB
 *
 *  Sample Output:
 *      The length of longest common sub-sequence is:
 */

import kotlin.math.max

class LongestCommonSubSequence {
    fun longestCommonSubSequence(str1: String, str2: String): Int {
        val nStr1 = str1.length
        val nStr2 = str2.length
        val dp = Array(nStr1 + 1) { IntArray(nStr2 + 1) }

        (1 until nStr1 + 1).forEach { i ->
            (1 until (nStr2 + 1)).forEach { j ->
                if (str1[i - 1] == str2[j - 1]) {
                    dp[i][j] = 1 + dp[i - 1][j - 1]
                } else {
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
                }
            }
        }
        return dp[nStr1][nStr2]
    }
}

fun main() {
    println("Enter the first string: ")
    val string1 = readLine()!!
    println("Enter the second string: ")
    val string2 = readLine()!!

    val lcs = LongestCommonSubSequence()
    println("The length of longest common sub-sequence is: ${lcs.longestCommonSubSequence(string1, string2)}")
}

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

  public final int longestCommonSubSequence(java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String str1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String str2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokevirtual #29                 // Method java/lang/String.length:()I
      16: istore_3
      17: aload_2
      18: invokevirtual #29                 // Method java/lang/String.length:()I
      21: istore        4
      23: iconst_0
      24: istore        6
      26: iload_3
      27: iconst_1
      28: iadd
      29: istore        7
      31: iload         7
      33: anewarray     #31                 // class "[I"
      36: astore        8
      38: iload         6
      40: iload         7
      42: if_icmpge     66
      45: iload         6
      47: istore        9
      49: aload         8
      51: iload         9
      53: iload         4
      55: iconst_1
      56: iadd
      57: newarray       int
      59: aastore
      60: iinc          6, 1
      63: goto          38
      66: aload         8
      68: astore        5
      70: iconst_1
      71: iload_3
      72: iconst_1
      73: iadd
      74: invokestatic  #37                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      77: checkcast     #39                 // class java/lang/Iterable
      80: astore        6
      82: iconst_0
      83: istore        7
      85: aload         6
      87: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      92: astore        8
      94: aload         8
      96: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     101: ifeq          259
     104: aload         8
     106: checkcast     #51                 // class kotlin/collections/IntIterator
     109: invokevirtual #54                 // Method kotlin/collections/IntIterator.nextInt:()I
     112: istore        9
     114: iload         9
     116: istore        10
     118: iconst_0
     119: istore        11
     121: iconst_1
     122: iload         4
     124: iconst_1
     125: iadd
     126: invokestatic  #37                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     129: checkcast     #39                 // class java/lang/Iterable
     132: astore        12
     134: iconst_0
     135: istore        13
     137: aload         12
     139: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     144: astore        14
     146: aload         14
     148: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     153: ifeq          253
     156: aload         14
     158: checkcast     #51                 // class kotlin/collections/IntIterator
     161: invokevirtual #54                 // Method kotlin/collections/IntIterator.nextInt:()I
     164: istore        15
     166: iload         15
     168: istore        16
     170: iconst_0
     171: istore        17
     173: aload_1
     174: iload         10
     176: iconst_1
     177: isub
     178: invokevirtual #58                 // Method java/lang/String.charAt:(I)C
     181: aload_2
     182: iload         16
     184: iconst_1
     185: isub
     186: invokevirtual #58                 // Method java/lang/String.charAt:(I)C
     189: if_icmpne     217
     192: aload         5
     194: iload         10
     196: aaload
     197: iload         16
     199: iconst_1
     200: aload         5
     202: iload         10
     204: iconst_1
     205: isub
     206: aaload
     207: iload         16
     209: iconst_1
     210: isub
     211: iaload
     212: iadd
     213: iastore
     214: goto          248
     217: aload         5
     219: iload         10
     221: aaload
     222: iload         16
     224: aload         5
     226: iload         10
     228: iconst_1
     229: isub
     230: aaload
     231: iload         16
     233: iaload
     234: aload         5
     236: iload         10
     238: aaload
     239: iload         16
     241: iconst_1
     242: isub
     243: iaload
     244: invokestatic  #64                 // Method java/lang/Math.max:(II)I
     247: iastore
     248: nop
     249: nop
     250: goto          146
     253: nop
     254: nop
     255: nop
     256: goto          94
     259: nop
     260: aload         5
     262: iload_3
     263: aaload
     264: iload         4
     266: iaload
     267: ireturn
}

Compiled from "LongestCommonSubSequence.kt"
public final class LongestCommonSubSequenceKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Enter the first string:
       2: getstatic     #14                 // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #20                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      12: dup
      13: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      16: astore_0
      17: ldc           #33                 // String Enter the second string:
      19: getstatic     #14                 // Field java/lang/System.out:Ljava/io/PrintStream;
      22: swap
      23: invokevirtual #20                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      26: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      29: dup
      30: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      33: astore_1
      34: new           #35                 // class LongestCommonSubSequence
      37: dup
      38: invokespecial #38                 // Method LongestCommonSubSequence."<init>":()V
      41: astore_2
      42: new           #40                 // class java/lang/StringBuilder
      45: dup
      46: invokespecial #41                 // Method java/lang/StringBuilder."<init>":()V
      49: ldc           #43                 // String The length of longest common sub-sequence is:
      51: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      54: aload_2
      55: aload_0
      56: aload_1
      57: invokevirtual #51                 // Method LongestCommonSubSequence.longestCommonSubSequence:(Ljava/lang/String;Ljava/lang/String;)I
      60: invokevirtual #54                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      63: invokevirtual #57                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      66: getstatic     #14                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: swap
      70: invokevirtual #20                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      73: return

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


/**
 *  Algorithm: Merge Sorting
 *  Language: Kotlin
 *  Input:
 *   a) n: Size of Array
 *   b) arr: Integer Array of size n
 *  Output:
 *   a) Array before applying Merge Sorting
 *   b) Array after applying Merge Sorting
 *  Time Complexity: O(n * log n)
 *  Space Complexity: O(n)
 *
 *  Sample Input:
 *  Enter the size of the integer array:
 *  5
 *  Enter an integer array:
 *  5 4 8 2 1
 *
 *  Sample Output:
 *  Array before sorting is:
 *  5 4 8 2 1
 *  Array after sorting is:
 *  1 2 4 5 8
 */

import MergeSort.Companion.printIArray
import java.util.*

class MergeSort {
    fun mergeSort(array: IntArray) {
        val n = array.size
        if (n < 2) return
        val mid = n / 2
        val left = IntArray(mid)
        val right = IntArray(n - mid)
        for (i in 0 until mid) left[i] = array[i]
        for (i in mid until n) right[i - mid] = array[i]
        mergeSort(left)
        mergeSort(right)
        merge(left, right, array)
    }

    private fun merge(left: IntArray, right: IntArray, array: IntArray) {
        val nLeft = left.size
        val nRight = right.size
        var i = 0
        var j = 0
        var k = 0
        while (i < nLeft && j < nRight) {
            if (left[i] <= right[j]) {
                array[k] = left[i]
                k++
                i++
            } else {
                array[k] = right[j]
                k++
                j++
            }
        }
        while (i < nLeft) {
            array[k] = left[i]
            i++
            k++
        }
        while (j < nRight) {
            array[k] = right[j]
            j++
            k++
        }
    }

    companion object {
        fun printIArray(array: IntArray) {
            println(array.joinToString(" "))
        }
    }
}

fun main() {
    val scanner = Scanner(System.`in`)
    println("Enter the size of the integer array: ")
    val n = scanner.nextInt()
    println("Enter an integer array: ")
    val arr = IntArray(n)
    arr.indices.forEach {
        arr[it] = scanner.nextInt()
    }
    val merge = MergeSort()
    println("Array before sorting is: ")
    printIArray(arr)
    merge.mergeSort(arr)
    println("Array after sorting is: ")
    printIArray(arr)
}

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

  public final void printIArray(int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String array
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #23                 // String
       9: checkcast     #25                 // class java/lang/CharSequence
      12: aconst_null
      13: aconst_null
      14: iconst_0
      15: aconst_null
      16: aconst_null
      17: bipush        62
      19: aconst_null
      20: invokestatic  #31                 // Method kotlin/collections/ArraysKt.joinToString$default:([ILjava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      23: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: swap
      27: invokevirtual #43                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      30: return

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

Compiled from "MergeSort.kt"
public final class MergeSortKt {
  public static final void main();
    Code:
       0: new           #8                  // class java/util/Scanner
       3: dup
       4: getstatic     #14                 // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #18                 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: astore_0
      11: ldc           #20                 // String Enter the size of the integer array:
      13: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      16: swap
      17: invokevirtual #30                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      20: aload_0
      21: invokevirtual #34                 // Method java/util/Scanner.nextInt:()I
      24: istore_1
      25: ldc           #36                 // String Enter an integer array:
      27: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      30: swap
      31: invokevirtual #30                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      34: iload_1
      35: newarray       int
      37: astore_2
      38: aload_2
      39: invokestatic  #42                 // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
      42: checkcast     #44                 // class java/lang/Iterable
      45: astore_3
      46: iconst_0
      47: istore        4
      49: aload_3
      50: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        5
      57: aload         5
      59: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifeq          97
      67: aload         5
      69: checkcast     #56                 // class kotlin/collections/IntIterator
      72: invokevirtual #57                 // Method kotlin/collections/IntIterator.nextInt:()I
      75: istore        6
      77: iload         6
      79: istore        7
      81: iconst_0
      82: istore        8
      84: aload_2
      85: iload         7
      87: aload_0
      88: invokevirtual #34                 // Method java/util/Scanner.nextInt:()I
      91: iastore
      92: nop
      93: nop
      94: goto          57
      97: nop
      98: new           #59                 // class MergeSort
     101: dup
     102: invokespecial #61                 // Method MergeSort."<init>":()V
     105: astore_3
     106: ldc           #63                 // String Array before sorting is:
     108: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
     111: swap
     112: invokevirtual #30                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     115: getstatic     #67                 // Field MergeSort.Companion:LMergeSort$Companion;
     118: aload_2
     119: invokevirtual #73                 // Method MergeSort$Companion.printIArray:([I)V
     122: aload_3
     123: aload_2
     124: invokevirtual #76                 // Method MergeSort.mergeSort:([I)V
     127: ldc           #78                 // String Array after sorting is:
     129: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
     132: swap
     133: invokevirtual #30                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     136: getstatic     #67                 // Field MergeSort.Companion:LMergeSort$Companion;
     139: aload_2
     140: invokevirtual #73                 // Method MergeSort$Companion.printIArray:([I)V
     143: return

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

Compiled from "MergeSort.kt"
public final class MergeSort {
  public static final MergeSort$Companion Companion;

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

  public final void mergeSort(int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String array
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: istore_2
       9: iload_2
      10: iconst_2
      11: if_icmpge     15
      14: return
      15: iload_2
      16: iconst_2
      17: idiv
      18: istore_3
      19: iload_3
      20: newarray       int
      22: astore        4
      24: iload_2
      25: iload_3
      26: isub
      27: newarray       int
      29: astore        5
      31: iconst_0
      32: istore        6
      34: iload         6
      36: iload_3
      37: if_icmpge     55
      40: aload         4
      42: iload         6
      44: aload_1
      45: iload         6
      47: iaload
      48: iastore
      49: iinc          6, 1
      52: goto          34
      55: iload_3
      56: istore        6
      58: iload         6
      60: iload_2
      61: if_icmpge     81
      64: aload         5
      66: iload         6
      68: iload_3
      69: isub
      70: aload_1
      71: iload         6
      73: iaload
      74: iastore
      75: iinc          6, 1
      78: goto          58
      81: aload_0
      82: aload         4
      84: invokevirtual #23                 // Method mergeSort:([I)V
      87: aload_0
      88: aload         5
      90: invokevirtual #23                 // Method mergeSort:([I)V
      93: aload_0
      94: aload         4
      96: aload         5
      98: aload_1
      99: invokespecial #27                 // Method merge:([I[I[I)V
     102: return

  private final void merge(int[], int[], int[]);
    Code:
       0: aload_1
       1: arraylength
       2: istore        4
       4: aload_2
       5: arraylength
       6: istore        5
       8: iconst_0
       9: istore        6
      11: iconst_0
      12: istore        7
      14: iconst_0
      15: istore        8
      17: iload         6
      19: iload         4
      21: if_icmpge     76
      24: iload         7
      26: iload         5
      28: if_icmpge     76
      31: aload_1
      32: iload         6
      34: iaload
      35: aload_2
      36: iload         7
      38: iaload
      39: if_icmpgt     59
      42: aload_3
      43: iload         8
      45: aload_1
      46: iload         6
      48: iaload
      49: iastore
      50: iinc          8, 1
      53: iinc          6, 1
      56: goto          17
      59: aload_3
      60: iload         8
      62: aload_2
      63: iload         7
      65: iaload
      66: iastore
      67: iinc          8, 1
      70: iinc          7, 1
      73: goto          17
      76: iload         6
      78: iload         4
      80: if_icmpge     100
      83: aload_3
      84: iload         8
      86: aload_1
      87: iload         6
      89: iaload
      90: iastore
      91: iinc          6, 1
      94: iinc          8, 1
      97: goto          76
     100: iload         7
     102: iload         5
     104: if_icmpge     124
     107: aload_3
     108: iload         8
     110: aload_2
     111: iload         7
     113: iaload
     114: iastore
     115: iinc          7, 1
     118: iinc          8, 1
     121: goto          100
     124: return

  static {};
    Code:
       0: new           #42                 // class MergeSort$Companion
       3: dup
       4: aconst_null
       5: invokespecial #45                 // Method MergeSort$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #49                 // Field Companion:LMergeSort$Companion;
      11: return
}


/**
 * Proof for the Riddler problem from March 18, 2016
 *
 * http://fivethirtyeight.com/features/can-you-best-the-mysterious-man-in-the-trench-coat/
 */

fun main(args: Array<String>) {
  findBestOutcome(1, 1000, 9)
}

fun findBestOutcome(lowerBound: Int, upperBound: Int, maxGuesses: Int, verbose: Boolean = false) {
  var best = 0
  var bestGuess = 0
  for (guess in lowerBound..upperBound) {
    val outcome = outcome(lowerBound, upperBound, maxGuesses, guess)
    if (outcome > best) {
      best = outcome
      bestGuess = guess
    }

    if (verbose) {
      println(String.format("Guessing %d yields an outcome of %d", guess, outcome))
    }
  }

  println(String.format("Best outcome: guess %d", bestGuess))
}

/**
 * A measure of how profitable a guess will be - the sum of all successful amounts it can get to
 */
fun outcome(lowerBound: Int, upperBound: Int, maxGuesses: Int, guess: Int): Int {
  var outcome = 0
  for (actual in lowerBound..upperBound) {
    val result = binary(lowerBound, upperBound, guess, actual)
    if (result <= maxGuesses) {
      outcome += actual
    }
  }
  return outcome
}

/**
 * Counts how many times it takes to guess the amount of money.
 *
 * This is a non-standard binary search because it allows you to start
 * on any number (but splits the halves after that).
 */
fun binary(lowerBound: Int, upperBound: Int, guess: Int, actual: Int): Int {
  if (lowerBound > upperBound
      || guess < lowerBound || guess > upperBound
      || actual < lowerBound || actual > upperBound) {
    throw IllegalArgumentException("You entered something wrong...")
  }

  var left: Int = lowerBound
  var right: Int = upperBound
  var iterations: Int = 0
  var isFirst: Boolean = true

  while (true) {
    // On the first runthrough, don't calculate the midpoint; use the guess provided
    val current = if (isFirst) guess else (left + right) / 2
    isFirst = false

    iterations += 1 // Each time we do this, it counts as a guess
    if (current == actual) {
      break;
    } else if (current < actual) {
      left = current + 1
    } else if (current > actual) {
      right = current - 1
    }
  }

  return iterations
}

Compiled from "binary.kt"
public final class BinaryKt {
  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_1
       7: sipush        1000
      10: bipush        9
      12: iconst_0
      13: bipush        8
      15: aconst_null
      16: invokestatic  #19                 // Method findBestOutcome$default:(IIIZILjava/lang/Object;)V
      19: return

  public static final void findBestOutcome(int, int, int, boolean);
    Code:
       0: iconst_0
       1: istore        4
       3: iconst_0
       4: istore        5
       6: iload_0
       7: istore        6
       9: iload         6
      11: iload_1
      12: if_icmpgt     121
      15: iload_0
      16: iload_1
      17: iload_2
      18: iload         6
      20: invokestatic  #26                 // Method outcome:(IIII)I
      23: istore        7
      25: iload         7
      27: iload         4
      29: if_icmple     40
      32: iload         7
      34: istore        4
      36: iload         6
      38: istore        5
      40: iload_3
      41: ifeq          109
      44: getstatic     #32                 // Field kotlin/jvm/internal/StringCompanionObject.INSTANCE:Lkotlin/jvm/internal/StringCompanionObject;
      47: pop
      48: ldc           #34                 // String Guessing %d yields an outcome of %d
      50: astore        9
      52: iconst_2
      53: anewarray     #4                  // class java/lang/Object
      56: astore        10
      58: aload         10
      60: iconst_0
      61: iload         6
      63: invokestatic  #40                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      66: aastore
      67: aload         10
      69: iconst_1
      70: iload         7
      72: invokestatic  #40                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      75: aastore
      76: aload         10
      78: astore        10
      80: aload         9
      82: aload         10
      84: aload         10
      86: arraylength
      87: invokestatic  #46                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
      90: invokestatic  #52                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
      93: dup
      94: ldc           #54                 // String format(...)
      96: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      99: astore        8
     101: getstatic     #63                 // Field java/lang/System.out:Ljava/io/PrintStream;
     104: aload         8
     106: invokevirtual #69                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     109: iload         6
     111: iload_1
     112: if_icmpeq     121
     115: iinc          6, 1
     118: goto          15
     121: getstatic     #32                 // Field kotlin/jvm/internal/StringCompanionObject.INSTANCE:Lkotlin/jvm/internal/StringCompanionObject;
     124: pop
     125: ldc           #71                 // String Best outcome: guess %d
     127: astore        7
     129: iconst_1
     130: anewarray     #4                  // class java/lang/Object
     133: astore        8
     135: aload         8
     137: iconst_0
     138: iload         5
     140: invokestatic  #40                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     143: aastore
     144: aload         8
     146: astore        8
     148: aload         7
     150: aload         8
     152: aload         8
     154: arraylength
     155: invokestatic  #46                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     158: invokestatic  #52                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     161: dup
     162: ldc           #54                 // String format(...)
     164: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     167: astore        6
     169: getstatic     #63                 // Field java/lang/System.out:Ljava/io/PrintStream;
     172: aload         6
     174: invokevirtual #69                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     177: return

  public static void findBestOutcome$default(int, int, int, boolean, int, java.lang.Object);
    Code:
       0: iload         4
       2: bipush        8
       4: iand
       5: ifeq          10
       8: iconst_0
       9: istore_3
      10: iload_0
      11: iload_1
      12: iload_2
      13: iload_3
      14: invokestatic  #82                 // Method findBestOutcome:(IIIZ)V
      17: return

  public static final int outcome(int, int, int, int);
    Code:
       0: iconst_0
       1: istore        4
       3: iload_0
       4: istore        5
       6: iload         5
       8: iload_1
       9: if_icmpgt     47
      12: iload_0
      13: iload_1
      14: iload_3
      15: iload         5
      17: invokestatic  #85                 // Method binary:(IIII)I
      20: istore        6
      22: iload         6
      24: iload_2
      25: if_icmpgt     35
      28: iload         4
      30: iload         5
      32: iadd
      33: istore        4
      35: iload         5
      37: iload_1
      38: if_icmpeq     47
      41: iinc          5, 1
      44: goto          12
      47: iload         4
      49: ireturn

  public static final int binary(int, int, int, int);
    Code:
       0: iload_0
       1: iload_1
       2: if_icmpgt     25
       5: iload_2
       6: iload_0
       7: if_icmplt     25
      10: iload_2
      11: iload_1
      12: if_icmpgt     25
      15: iload_3
      16: iload_0
      17: if_icmplt     25
      20: iload_3
      21: iload_1
      22: if_icmple     35
      25: new           #89                 // class java/lang/IllegalArgumentException
      28: dup
      29: ldc           #91                 // String You entered something wrong...
      31: invokespecial #95                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      34: athrow
      35: iload_0
      36: istore        4
      38: iload_1
      39: istore        5
      41: iconst_0
      42: istore        6
      44: iconst_1
      45: istore        7
      47: nop
      48: iload         7
      50: ifeq          57
      53: iload_2
      54: goto          64
      57: iload         4
      59: iload         5
      61: iadd
      62: iconst_2
      63: idiv
      64: istore        8
      66: iconst_0
      67: istore        7
      69: iinc          6, 1
      72: iload         8
      74: iload_3
      75: if_icmpne     81
      78: goto          111
      81: iload         8
      83: iload_3
      84: if_icmpge     96
      87: iload         8
      89: iconst_1
      90: iadd
      91: istore        4
      93: goto          47
      96: iload         8
      98: iload_3
      99: if_icmple     47
     102: iload         8
     104: iconst_1
     105: isub
     106: istore        5
     108: goto          47
     111: iload         6
     113: ireturn
}


private fun thomas(a: DoubleArray, b: DoubleArray, c: DoubleArray, d: DoubleArray): DoubleArray {
    val cPrime = c.clone()
    val x = d.clone()
    val size = a.size
    cPrime[0] /= b[0]
    x[0] /= b[0]
    for (i in 1 until size) {
        val scale = 1.0 / (b[i] - cPrime[i - 1] * a[i])
        cPrime[i] *= scale
        x[i] = (x[i] - a[i] * x[i - 1]) * scale
    }
    for (i in (size - 2) downTo 0) {
        x[i] -= cPrime[i] * x[i + 1]
    }
    return x
}

fun main(args: Array<String>) {
    val a = doubleArrayOf(0.0, 2.0, 3.0)
    val b = doubleArrayOf(1.0, 3.0, 6.0)
    val c = doubleArrayOf(4.0, 5.0, 0.0)
    val x = doubleArrayOf(7.0, 5.0, 3.0)
    val solution = thomas(a, b, c, x)

    println("System:")
    println("[%.1f, %.1f, %.1f][x] = [%.1f]".format(b[0], c[0], 0f, x[0]))
    println("[%.1f, %.1f, %.1f][y] = [%.1f]".format(a[1], b[1], c[1], x[1]))
    println("[%.1f, %.1f, %.1f][z] = [%.1f]\n".format(0f, a[2], b[2], x[2]))
    println("Solution:")
    for (i in solution.indices) {
        println("[% .5f]".format(solution[i]))
    }
}

Compiled from "thomas.kt"
public final class ThomasKt {
  private static final double[] thomas(double[], double[], double[], double[]);
    Code:
       0: aload_2
       1: invokevirtual #10                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       4: checkcast     #12                 // class "[D"
       7: astore        4
       9: aload_3
      10: invokevirtual #10                 // Method java/lang/Object.clone:()Ljava/lang/Object;
      13: checkcast     #12                 // class "[D"
      16: astore        5
      18: aload_0
      19: arraylength
      20: istore        6
      22: aload         4
      24: iconst_0
      25: aload         4
      27: iconst_0
      28: daload
      29: aload_1
      30: iconst_0
      31: daload
      32: ddiv
      33: dastore
      34: aload         5
      36: iconst_0
      37: aload         5
      39: iconst_0
      40: daload
      41: aload_1
      42: iconst_0
      43: daload
      44: ddiv
      45: dastore
      46: iconst_1
      47: istore        7
      49: iload         7
      51: iload         6
      53: if_icmpge     126
      56: dconst_1
      57: aload_1
      58: iload         7
      60: daload
      61: aload         4
      63: iload         7
      65: iconst_1
      66: isub
      67: daload
      68: aload_0
      69: iload         7
      71: daload
      72: dmul
      73: dsub
      74: ddiv
      75: dstore        8
      77: iload         7
      79: istore        10
      81: aload         4
      83: iload         10
      85: aload         4
      87: iload         10
      89: daload
      90: dload         8
      92: dmul
      93: dastore
      94: aload         5
      96: iload         7
      98: aload         5
     100: iload         7
     102: daload
     103: aload_0
     104: iload         7
     106: daload
     107: aload         5
     109: iload         7
     111: iconst_1
     112: isub
     113: daload
     114: dmul
     115: dsub
     116: dload         8
     118: dmul
     119: dastore
     120: iinc          7, 1
     123: goto          49
     126: iload         6
     128: iconst_2
     129: isub
     130: istore        7
     132: iconst_m1
     133: iload         7
     135: if_icmpge     172
     138: iload         7
     140: istore        8
     142: aload         5
     144: iload         8
     146: aload         5
     148: iload         8
     150: daload
     151: aload         4
     153: iload         7
     155: daload
     156: aload         5
     158: iload         7
     160: iconst_1
     161: iadd
     162: daload
     163: dmul
     164: dsub
     165: dastore
     166: iinc          7, -1
     169: goto          132
     172: aload         5
     174: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #28                 // String args
       3: invokestatic  #34                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_3
       7: newarray       double
       9: astore_2
      10: aload_2
      11: iconst_0
      12: dconst_0
      13: dastore
      14: aload_2
      15: iconst_1
      16: ldc2_w        #35                 // double 2.0d
      19: dastore
      20: aload_2
      21: iconst_2
      22: ldc2_w        #37                 // double 3.0d
      25: dastore
      26: aload_2
      27: astore_1
      28: iconst_3
      29: newarray       double
      31: astore_3
      32: aload_3
      33: iconst_0
      34: dconst_1
      35: dastore
      36: aload_3
      37: iconst_1
      38: ldc2_w        #37                 // double 3.0d
      41: dastore
      42: aload_3
      43: iconst_2
      44: ldc2_w        #39                 // double 6.0d
      47: dastore
      48: aload_3
      49: astore_2
      50: iconst_3
      51: newarray       double
      53: astore        4
      55: aload         4
      57: iconst_0
      58: ldc2_w        #41                 // double 4.0d
      61: dastore
      62: aload         4
      64: iconst_1
      65: ldc2_w        #43                 // double 5.0d
      68: dastore
      69: aload         4
      71: iconst_2
      72: dconst_0
      73: dastore
      74: aload         4
      76: astore_3
      77: iconst_3
      78: newarray       double
      80: astore        5
      82: aload         5
      84: iconst_0
      85: ldc2_w        #45                 // double 7.0d
      88: dastore
      89: aload         5
      91: iconst_1
      92: ldc2_w        #43                 // double 5.0d
      95: dastore
      96: aload         5
      98: iconst_2
      99: ldc2_w        #37                 // double 3.0d
     102: dastore
     103: aload         5
     105: astore        4
     107: aload_1
     108: aload_2
     109: aload_3
     110: aload         4
     112: invokestatic  #48                 // Method thomas:([D[D[D[D)[D
     115: astore        5
     117: ldc           #50                 // String System:
     119: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     122: swap
     123: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     126: ldc           #64                 // String [%.1f, %.1f, %.1f][x] = [%.1f]
     128: astore        6
     130: iconst_4
     131: anewarray     #4                  // class java/lang/Object
     134: astore        7
     136: aload         7
     138: iconst_0
     139: aload_2
     140: iconst_0
     141: daload
     142: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     145: aastore
     146: aload         7
     148: iconst_1
     149: aload_3
     150: iconst_0
     151: daload
     152: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     155: aastore
     156: aload         7
     158: iconst_2
     159: fconst_0
     160: invokestatic  #75                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
     163: aastore
     164: aload         7
     166: iconst_3
     167: aload         4
     169: iconst_0
     170: daload
     171: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     174: aastore
     175: aload         7
     177: astore        7
     179: aload         6
     181: aload         7
     183: aload         7
     185: arraylength
     186: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     189: invokestatic  #87                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     192: dup
     193: ldc           #89                 // String format(...)
     195: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     198: astore        6
     200: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     203: aload         6
     205: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     208: ldc           #94                 // String [%.1f, %.1f, %.1f][y] = [%.1f]
     210: astore        6
     212: iconst_4
     213: anewarray     #4                  // class java/lang/Object
     216: astore        7
     218: aload         7
     220: iconst_0
     221: aload_1
     222: iconst_1
     223: daload
     224: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     227: aastore
     228: aload         7
     230: iconst_1
     231: aload_2
     232: iconst_1
     233: daload
     234: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     237: aastore
     238: aload         7
     240: iconst_2
     241: aload_3
     242: iconst_1
     243: daload
     244: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     247: aastore
     248: aload         7
     250: iconst_3
     251: aload         4
     253: iconst_1
     254: daload
     255: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     258: aastore
     259: aload         7
     261: astore        7
     263: aload         6
     265: aload         7
     267: aload         7
     269: arraylength
     270: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     273: invokestatic  #87                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     276: dup
     277: ldc           #89                 // String format(...)
     279: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     282: astore        6
     284: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     287: aload         6
     289: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     292: ldc           #96                 // String [%.1f, %.1f, %.1f][z] = [%.1f]\n
     294: astore        6
     296: iconst_4
     297: anewarray     #4                  // class java/lang/Object
     300: astore        7
     302: aload         7
     304: iconst_0
     305: fconst_0
     306: invokestatic  #75                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
     309: aastore
     310: aload         7
     312: iconst_1
     313: aload_1
     314: iconst_2
     315: daload
     316: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     319: aastore
     320: aload         7
     322: iconst_2
     323: aload_2
     324: iconst_2
     325: daload
     326: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     329: aastore
     330: aload         7
     332: iconst_3
     333: aload         4
     335: iconst_2
     336: daload
     337: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     340: aastore
     341: aload         7
     343: astore        7
     345: aload         6
     347: aload         7
     349: aload         7
     351: arraylength
     352: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     355: invokestatic  #87                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     358: dup
     359: ldc           #89                 // String format(...)
     361: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     364: astore        6
     366: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     369: aload         6
     371: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     374: ldc           #98                 // String Solution:
     376: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     379: swap
     380: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     383: iconst_0
     384: istore        6
     386: aload         5
     388: arraylength
     389: istore        7
     391: iload         6
     393: iload         7
     395: if_icmpge     459
     398: ldc           #100                // String [% .5f]
     400: astore        8
     402: iconst_1
     403: anewarray     #4                  // class java/lang/Object
     406: astore        9
     408: aload         9
     410: iconst_0
     411: aload         5
     413: iload         6
     415: daload
     416: invokestatic  #70                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     419: aastore
     420: aload         9
     422: astore        9
     424: aload         8
     426: aload         9
     428: aload         9
     430: arraylength
     431: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     434: invokestatic  #87                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     437: dup
     438: ldc           #89                 // String format(...)
     440: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     443: astore        8
     445: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
     448: aload         8
     450: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     453: iinc          6, 1
     456: goto          391
     459: return
}


val vowels: List<Char> = listOf('a', 'e', 'i', 'o', 'u', 'y')
val consonants: List<Char> = listOf('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z')

fun fixClusterVowels(cluster: String): String {
    val listOfVowels: MutableList<Char> = cluster.toMutableList()

    val correctionI = listOfVowels.size / 2
    for (i in 2 until(listOfVowels.lastIndex + correctionI) step 3) {
        listOfVowels.add(i, consonants.random())
    }
    return listOfVowels.joinToString("")
}

fun fixClusterConsonants(cluster:String): String {
    val listOfConsonants: MutableList<Char> = cluster.toMutableList()

    val correctionI = listOfConsonants.size / 2
    for (i in 2 until(listOfConsonants.lastIndex + correctionI) step 3) { // start in the index 2 because a vowel is put in the 3rd element if a put index 3 the word fit in the 4th and don't solve the problem
        listOfConsonants.add(i, vowels.random())
    }
    return listOfConsonants.joinToString("")
}

fun findClusters(word: String): List<Int?> {
    val clusterIndices: List<Int?>
    for (i in word.indices) {
        var quantV = 0
        do {
            if (vowels.contains(word[i + quantV]) && i + quantV + 1 <= word.lastIndex) {
                ++quantV
            } else if (i + quantV == word.lastIndex && vowels.contains(word[i + quantV])) {
                ++quantV
            }
        } while (i + quantV <= word.lastIndex && vowels.contains(word[i + quantV]))

        if (quantV >= 3) {
            clusterIndices = listOf(i, i + quantV)
            return clusterIndices
        }

        var quantC = 0
        do {
            if (consonants.contains(word[i + quantC]) && i + quantC + 1 <= word.lastIndex) {
                ++quantC
            } else if (i + quantC == word.lastIndex && consonants.contains(word[i + quantC])) {
                ++quantC
            }
        } while (i + quantC <= word.lastIndex && consonants.contains(word[i + quantC]))

        if (quantC >= 3) {
            clusterIndices = listOf(i, i + quantC)
            return clusterIndices
        }
    }
    clusterIndices = listOf(null)
    return clusterIndices
}

fun solveClusters(wordParam: String): String {
    var word = wordParam
    var indexCluster = findClusters(word)
    while (indexCluster[0] != null) {
        val cluster: String = word.substring(indexCluster[0] ?: 0, indexCluster[1] ?: 0)

        if (vowels.contains(cluster[0])) {
            val fixedCluster = fixClusterVowels(cluster)
            word = word.replaceFirst(cluster, fixedCluster)
            indexCluster = findClusters(word)

        } else if (consonants.contains(cluster[0])) {
            val fixedCluster = fixClusterConsonants(cluster)
            word = word.replaceFirst(cluster, fixedCluster)
            indexCluster = findClusters(word)
        } else {
            break
        }
    }
    return word
}

fun main() {
    val word = readln()
    println(solveClusters(word))
    println(solveClusters(word).length - word.length)
}

/*
val vowels: List<Char> = listOf('a', 'e', 'i', 'o', 'u', 'y')
val consonants: List<Char> = listOf('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
    'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z')

fun findClusters(word: String):MutableList<Int?> {
    val sizesOfClusters: MutableList<Int?> = mutableListOf()
    var countV = 2
    var countC = 2
    var lastLetter: Char? = null
    var nextToLetter: Char? = null

    for (letter in word) {
        if (vowels.contains(letter) && (if (lastLetter != null ) vowels.contains(lastLetter) else false) && vowels.contains(nextToLetter)) {
            ++countV
        } else if (consonants.contains(letter) && (if (lastLetter != null ) consonants.contains(lastLetter) else false) && consonants.contains(nextToLetter)){
            ++countC
        } else if (countV >= 3) {
            sizesOfClusters.add(countV)
            countV = 2
        } else if (countC >= 3) {
            sizesOfClusters.add(countC)
            countC = 2
        }
        nextToLetter = lastLetter
        lastLetter = letter
    }
    if (countV >= 3) {
        sizesOfClusters.add(countV)
    } else if (countC >= 3) {
        sizesOfClusters.add(countC)
    }
        return sizesOfClusters
}

fun lettersToPut(clusters: MutableList<Int?>): Int {
    if (clusters.size == 0) {
        return 0
    }
    for (i in clusters.indices) {
        if (clusters[i]!! % 2 == 0 ) {
            clusters[i] = clusters[i]!! / 2 - 1
        } else if (clusters[i]!! % 2 == 1) {
            clusters[i] = clusters[i]!! / 2
        }
    }
    var sum = 0
    for (size in clusters){

        sum += size!!
    }
    return sum
}

fun main() {
    val word = readln()
    println(lettersToPut(findClusters(word)))
}
*/

Compiled from "Main.kt"
public final class MainKt {
  private static final java.util.List<java.lang.Character> vowels;

  private static final java.util.List<java.lang.Character> consonants;

  public static final java.util.List<java.lang.Character> getVowels();
    Code:
       0: getstatic     #12                 // Field vowels:Ljava/util/List;
       3: areturn

  public static final java.util.List<java.lang.Character> getConsonants();
    Code:
       0: getstatic     #16                 // Field consonants:Ljava/util/List;
       3: areturn

  public static final java.lang.String fixClusterVowels(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #20                 // String cluster
       3: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #28                 // class java/lang/CharSequence
      10: invokestatic  #34                 // Method kotlin/text/StringsKt.toMutableList:(Ljava/lang/CharSequence;)Ljava/util/List;
      13: astore_1
      14: aload_1
      15: invokeinterface #40,  1           // InterfaceMethod java/util/List.size:()I
      20: iconst_2
      21: idiv
      22: istore_2
      23: iconst_2
      24: aload_1
      25: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      28: iload_2
      29: iadd
      30: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      33: checkcast     #54                 // class kotlin/ranges/IntProgression
      36: iconst_3
      37: invokestatic  #58                 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;
      40: astore_3
      41: aload_3
      42: invokevirtual #61                 // Method kotlin/ranges/IntProgression.getFirst:()I
      45: istore        4
      47: aload_3
      48: invokevirtual #64                 // Method kotlin/ranges/IntProgression.getLast:()I
      51: istore        5
      53: aload_3
      54: invokevirtual #67                 // Method kotlin/ranges/IntProgression.getStep:()I
      57: istore        6
      59: iload         6
      61: ifle          71
      64: iload         4
      66: iload         5
      68: if_icmple     83
      71: iload         6
      73: ifge          123
      76: iload         5
      78: iload         4
      80: if_icmpgt     123
      83: aload_1
      84: iload         4
      86: getstatic     #16                 // Field consonants:Ljava/util/List;
      89: checkcast     #69                 // class java/util/Collection
      92: getstatic     #75                 // Field kotlin/random/Random.Default:Lkotlin/random/Random$Default;
      95: checkcast     #71                 // class kotlin/random/Random
      98: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.random:(Ljava/util/Collection;Lkotlin/random/Random;)Ljava/lang/Object;
     101: invokeinterface #83,  3           // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     106: iload         4
     108: iload         5
     110: if_icmpeq     123
     113: iload         4
     115: iload         6
     117: iadd
     118: istore        4
     120: goto          83
     123: aload_1
     124: checkcast     #85                 // class java/lang/Iterable
     127: ldc           #87                 // String
     129: checkcast     #28                 // class java/lang/CharSequence
     132: aconst_null
     133: aconst_null
     134: iconst_0
     135: aconst_null
     136: aconst_null
     137: bipush        62
     139: aconst_null
     140: invokestatic  #91                 // 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;
     143: areturn

  public static final java.lang.String fixClusterConsonants(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #20                 // String cluster
       3: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #28                 // class java/lang/CharSequence
      10: invokestatic  #34                 // Method kotlin/text/StringsKt.toMutableList:(Ljava/lang/CharSequence;)Ljava/util/List;
      13: astore_1
      14: aload_1
      15: invokeinterface #40,  1           // InterfaceMethod java/util/List.size:()I
      20: iconst_2
      21: idiv
      22: istore_2
      23: iconst_2
      24: aload_1
      25: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      28: iload_2
      29: iadd
      30: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      33: checkcast     #54                 // class kotlin/ranges/IntProgression
      36: iconst_3
      37: invokestatic  #58                 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;
      40: astore_3
      41: aload_3
      42: invokevirtual #61                 // Method kotlin/ranges/IntProgression.getFirst:()I
      45: istore        4
      47: aload_3
      48: invokevirtual #64                 // Method kotlin/ranges/IntProgression.getLast:()I
      51: istore        5
      53: aload_3
      54: invokevirtual #67                 // Method kotlin/ranges/IntProgression.getStep:()I
      57: istore        6
      59: iload         6
      61: ifle          71
      64: iload         4
      66: iload         5
      68: if_icmple     83
      71: iload         6
      73: ifge          123
      76: iload         5
      78: iload         4
      80: if_icmpgt     123
      83: aload_1
      84: iload         4
      86: getstatic     #12                 // Field vowels:Ljava/util/List;
      89: checkcast     #69                 // class java/util/Collection
      92: getstatic     #75                 // Field kotlin/random/Random.Default:Lkotlin/random/Random$Default;
      95: checkcast     #71                 // class kotlin/random/Random
      98: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.random:(Ljava/util/Collection;Lkotlin/random/Random;)Ljava/lang/Object;
     101: invokeinterface #83,  3           // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     106: iload         4
     108: iload         5
     110: if_icmpeq     123
     113: iload         4
     115: iload         6
     117: iadd
     118: istore        4
     120: goto          83
     123: aload_1
     124: checkcast     #85                 // class java/lang/Iterable
     127: ldc           #87                 // String
     129: checkcast     #28                 // class java/lang/CharSequence
     132: aconst_null
     133: aconst_null
     134: iconst_0
     135: aconst_null
     136: aconst_null
     137: bipush        62
     139: aconst_null
     140: invokestatic  #91                 // 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;
     143: areturn

  public static final java.util.List<java.lang.Integer> findClusters(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #105                // String word
       3: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aconst_null
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_0
      11: checkcast     #28                 // class java/lang/CharSequence
      14: invokeinterface #108,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      19: istore_3
      20: iload_2
      21: iload_3
      22: if_icmpge     353
      25: iconst_0
      26: istore        4
      28: getstatic     #12                 // Field vowels:Ljava/util/List;
      31: aload_0
      32: iload_2
      33: iload         4
      35: iadd
      36: invokevirtual #112                // Method java/lang/String.charAt:(I)C
      39: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      42: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
      47: ifeq          72
      50: iload_2
      51: iload         4
      53: iadd
      54: iconst_1
      55: iadd
      56: aload_0
      57: checkcast     #28                 // class java/lang/CharSequence
      60: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      63: if_icmpgt     72
      66: iinc          4, 1
      69: goto          111
      72: iload_2
      73: iload         4
      75: iadd
      76: aload_0
      77: checkcast     #28                 // class java/lang/CharSequence
      80: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      83: if_icmpne     111
      86: getstatic     #12                 // Field vowels:Ljava/util/List;
      89: aload_0
      90: iload_2
      91: iload         4
      93: iadd
      94: invokevirtual #112                // Method java/lang/String.charAt:(I)C
      97: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     100: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     105: ifeq          111
     108: iinc          4, 1
     111: iload_2
     112: iload         4
     114: iadd
     115: aload_0
     116: checkcast     #28                 // class java/lang/CharSequence
     119: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     122: if_icmpgt     147
     125: getstatic     #12                 // Field vowels:Ljava/util/List;
     128: aload_0
     129: iload_2
     130: iload         4
     132: iadd
     133: invokevirtual #112                // Method java/lang/String.charAt:(I)C
     136: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     139: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     144: ifne          28
     147: iload         4
     149: iconst_3
     150: if_icmplt     186
     153: iconst_2
     154: anewarray     #127                // class java/lang/Integer
     157: astore        5
     159: aload         5
     161: iconst_0
     162: iload_2
     163: invokestatic  #130                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     166: aastore
     167: aload         5
     169: iconst_1
     170: iload_2
     171: iload         4
     173: iadd
     174: invokestatic  #130                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     177: aastore
     178: aload         5
     180: invokestatic  #134                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     183: astore_1
     184: aload_1
     185: areturn
     186: iconst_0
     187: istore        5
     189: getstatic     #16                 // Field consonants:Ljava/util/List;
     192: aload_0
     193: iload_2
     194: iload         5
     196: iadd
     197: invokevirtual #112                // Method java/lang/String.charAt:(I)C
     200: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     203: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     208: ifeq          233
     211: iload_2
     212: iload         5
     214: iadd
     215: iconst_1
     216: iadd
     217: aload_0
     218: checkcast     #28                 // class java/lang/CharSequence
     221: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     224: if_icmpgt     233
     227: iinc          5, 1
     230: goto          272
     233: iload_2
     234: iload         5
     236: iadd
     237: aload_0
     238: checkcast     #28                 // class java/lang/CharSequence
     241: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     244: if_icmpne     272
     247: getstatic     #16                 // Field consonants:Ljava/util/List;
     250: aload_0
     251: iload_2
     252: iload         5
     254: iadd
     255: invokevirtual #112                // Method java/lang/String.charAt:(I)C
     258: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     261: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     266: ifeq          272
     269: iinc          5, 1
     272: iload_2
     273: iload         5
     275: iadd
     276: aload_0
     277: checkcast     #28                 // class java/lang/CharSequence
     280: invokestatic  #125                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     283: if_icmpgt     308
     286: getstatic     #16                 // Field consonants:Ljava/util/List;
     289: aload_0
     290: iload_2
     291: iload         5
     293: iadd
     294: invokevirtual #112                // Method java/lang/String.charAt:(I)C
     297: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     300: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     305: ifne          189
     308: iload         5
     310: iconst_3
     311: if_icmplt     347
     314: iconst_2
     315: anewarray     #127                // class java/lang/Integer
     318: astore        6
     320: aload         6
     322: iconst_0
     323: iload_2
     324: invokestatic  #130                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     327: aastore
     328: aload         6
     330: iconst_1
     331: iload_2
     332: iload         5
     334: iadd
     335: invokestatic  #130                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     338: aastore
     339: aload         6
     341: invokestatic  #134                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     344: astore_1
     345: aload_1
     346: areturn
     347: iinc          2, 1
     350: goto          20
     353: aconst_null
     354: invokestatic  #137                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     357: astore_1
     358: aload_1
     359: areturn

  public static final java.lang.String solveClusters(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #143                // String wordParam
       3: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: invokestatic  #145                // Method findClusters:(Ljava/lang/String;)Ljava/util/List;
      12: astore_2
      13: aload_2
      14: iconst_0
      15: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      20: ifnull        181
      23: aload_1
      24: astore        4
      26: aload_2
      27: iconst_0
      28: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #127                // class java/lang/Integer
      36: dup
      37: ifnull        46
      40: invokevirtual #152                // Method java/lang/Integer.intValue:()I
      43: goto          48
      46: pop
      47: iconst_0
      48: istore        5
      50: aload_2
      51: iconst_1
      52: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      57: checkcast     #127                // class java/lang/Integer
      60: dup
      61: ifnull        70
      64: invokevirtual #152                // Method java/lang/Integer.intValue:()I
      67: goto          72
      70: pop
      71: iconst_0
      72: istore        6
      74: aload         4
      76: iload         5
      78: iload         6
      80: invokevirtual #156                // Method java/lang/String.substring:(II)Ljava/lang/String;
      83: dup
      84: ldc           #158                // String substring(...)
      86: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      89: astore_3
      90: getstatic     #12                 // Field vowels:Ljava/util/List;
      93: aload_3
      94: iconst_0
      95: invokevirtual #112                // Method java/lang/String.charAt:(I)C
      98: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     101: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     106: ifeq          134
     109: aload_3
     110: invokestatic  #163                // Method fixClusterVowels:(Ljava/lang/String;)Ljava/lang/String;
     113: astore        4
     115: aload_1
     116: aload_3
     117: aload         4
     119: iconst_0
     120: iconst_4
     121: aconst_null
     122: invokestatic  #167                // Method kotlin/text/StringsKt.replaceFirst$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     125: astore_1
     126: aload_1
     127: invokestatic  #145                // Method findClusters:(Ljava/lang/String;)Ljava/util/List;
     130: astore_2
     131: goto          13
     134: getstatic     #16                 // Field consonants:Ljava/util/List;
     137: aload_3
     138: iconst_0
     139: invokevirtual #112                // Method java/lang/String.charAt:(I)C
     142: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     145: invokeinterface #122,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     150: ifeq          178
     153: aload_3
     154: invokestatic  #169                // Method fixClusterConsonants:(Ljava/lang/String;)Ljava/lang/String;
     157: astore        4
     159: aload_1
     160: aload_3
     161: aload         4
     163: iconst_0
     164: iconst_4
     165: aconst_null
     166: invokestatic  #167                // Method kotlin/text/StringsKt.replaceFirst$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     169: astore_1
     170: aload_1
     171: invokestatic  #145                // Method findClusters:(Ljava/lang/String;)Ljava/util/List;
     174: astore_2
     175: goto          13
     178: goto          181
     181: aload_1
     182: areturn

  public static final void main();
    Code:
       0: invokestatic  #179                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: astore_0
       4: aload_0
       5: invokestatic  #181                // Method solveClusters:(Ljava/lang/String;)Ljava/lang/String;
       8: getstatic     #187                // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #193                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      15: aload_0
      16: invokestatic  #181                // Method solveClusters:(Ljava/lang/String;)Ljava/lang/String;
      19: invokevirtual #194                // Method java/lang/String.length:()I
      22: aload_0
      23: invokevirtual #194                // Method java/lang/String.length:()I
      26: isub
      27: istore_1
      28: getstatic     #187                // Field java/lang/System.out:Ljava/io/PrintStream;
      31: iload_1
      32: invokevirtual #197                // Method java/io/PrintStream.println:(I)V
      35: return

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

  static {};
    Code:
       0: bipush        6
       2: anewarray     #114                // class java/lang/Character
       5: astore_0
       6: aload_0
       7: iconst_0
       8: bipush        97
      10: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      13: aastore
      14: aload_0
      15: iconst_1
      16: bipush        101
      18: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      21: aastore
      22: aload_0
      23: iconst_2
      24: bipush        105
      26: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      29: aastore
      30: aload_0
      31: iconst_3
      32: bipush        111
      34: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      37: aastore
      38: aload_0
      39: iconst_4
      40: bipush        117
      42: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      45: aastore
      46: aload_0
      47: iconst_5
      48: bipush        121
      50: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      53: aastore
      54: aload_0
      55: invokestatic  #134                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      58: putstatic     #12                 // Field vowels:Ljava/util/List;
      61: bipush        20
      63: anewarray     #114                // class java/lang/Character
      66: astore_0
      67: aload_0
      68: iconst_0
      69: bipush        98
      71: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      74: aastore
      75: aload_0
      76: iconst_1
      77: bipush        99
      79: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      82: aastore
      83: aload_0
      84: iconst_2
      85: bipush        100
      87: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      90: aastore
      91: aload_0
      92: iconst_3
      93: bipush        102
      95: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      98: aastore
      99: aload_0
     100: iconst_4
     101: bipush        103
     103: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     106: aastore
     107: aload_0
     108: iconst_5
     109: bipush        104
     111: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     114: aastore
     115: aload_0
     116: bipush        6
     118: bipush        106
     120: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     123: aastore
     124: aload_0
     125: bipush        7
     127: bipush        107
     129: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     132: aastore
     133: aload_0
     134: bipush        8
     136: bipush        108
     138: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     141: aastore
     142: aload_0
     143: bipush        9
     145: bipush        109
     147: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     150: aastore
     151: aload_0
     152: bipush        10
     154: bipush        110
     156: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     159: aastore
     160: aload_0
     161: bipush        11
     163: bipush        112
     165: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     168: aastore
     169: aload_0
     170: bipush        12
     172: bipush        113
     174: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     177: aastore
     178: aload_0
     179: bipush        13
     181: bipush        114
     183: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     186: aastore
     187: aload_0
     188: bipush        14
     190: bipush        115
     192: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     195: aastore
     196: aload_0
     197: bipush        15
     199: bipush        116
     201: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     204: aastore
     205: aload_0
     206: bipush        16
     208: bipush        118
     210: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     213: aastore
     214: aload_0
     215: bipush        17
     217: bipush        119
     219: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     222: aastore
     223: aload_0
     224: bipush        18
     226: bipush        120
     228: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     231: aastore
     232: aload_0
     233: bipush        19
     235: bipush        122
     237: invokestatic  #118                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     240: aastore
     241: aload_0
     242: invokestatic  #134                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     245: putstatic     #16                 // Field consonants:Ljava/util/List;
     248: return
}