package main.algorithms.searching

fun main(args: Array<String>) {
    val input = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray()    // to read an array (from user input)
    val eleToSearch = readLine()!!.trim().toInt()   // to read the element to be searched (from user input)
    val pos = binarySearchRecursive(input, eleToSearch, 0, input.size -1)
    if(pos >= 0 ) {
        println(pos)    // to print position at last
    } else {
        println("Position not found")
    }
}

fun binarySearchRecursive(input: IntArray, eleToSearch: Int, low:Int, high:Int): Int {

    while(low <=high) {
      val mid = (low + high) /2
        when {
            eleToSearch > input[mid] -> return binarySearchRecursive(input, eleToSearch, mid+1, high)   // element is greater than middle element of array, so it will be in right half. Recursion will call the right half again
            eleToSearch < input[mid] -> return binarySearchRecursive(input, eleToSearch, low, mid-1)    //element is less than middle element of array, so it will be in left half of the array. Recursion will call the left half again.
            eleToSearch == input[mid] -> return mid // element found.
        }
    }
    return -1
}

Compiled from "BinarySearchRecursive.kt"
public final class main.algorithms.searching.BinarySearchRecursiveKt {
  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: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       9: dup
      10: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: checkcast     #27                 // class java/lang/CharSequence
      16: invokestatic  #33                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      19: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
      22: checkcast     #27                 // class java/lang/CharSequence
      25: iconst_1
      26: anewarray     #38                 // class java/lang/String
      29: astore_2
      30: aload_2
      31: iconst_0
      32: ldc           #40                 // String
      34: aastore
      35: aload_2
      36: iconst_0
      37: iconst_0
      38: bipush        6
      40: aconst_null
      41: invokestatic  #44                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      44: checkcast     #46                 // class java/lang/Iterable
      47: astore_2
      48: iconst_0
      49: istore_3
      50: aload_2
      51: astore        4
      53: new           #48                 // class java/util/ArrayList
      56: dup
      57: aload_2
      58: bipush        10
      60: invokestatic  #54                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      63: invokespecial #58                 // Method java/util/ArrayList."<init>":(I)V
      66: checkcast     #60                 // class java/util/Collection
      69: astore        5
      71: iconst_0
      72: istore        6
      74: aload         4
      76: invokeinterface #64,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      81: astore        7
      83: aload         7
      85: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      90: ifeq          137
      93: aload         7
      95: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     100: astore        8
     102: aload         5
     104: aload         8
     106: checkcast     #38                 // class java/lang/String
     109: astore        9
     111: astore        11
     113: iconst_0
     114: istore        10
     116: aload         9
     118: invokestatic  #80                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     121: nop
     122: invokestatic  #84                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     125: aload         11
     127: swap
     128: invokeinterface #88,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     133: pop
     134: goto          83
     137: aload         5
     139: checkcast     #90                 // class java/util/List
     142: nop
     143: checkcast     #60                 // class java/util/Collection
     146: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     149: astore_1
     150: nop
     151: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
     154: dup
     155: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     158: checkcast     #27                 // class java/lang/CharSequence
     161: invokestatic  #33                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     164: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
     167: invokestatic  #80                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     170: istore_2
     171: aload_1
     172: iload_2
     173: iconst_0
     174: aload_1
     175: arraylength
     176: iconst_1
     177: isub
     178: invokestatic  #98                 // Method binarySearchRecursive:([IIII)I
     181: istore_3
     182: iload_3
     183: iflt          196
     186: getstatic     #104                // Field java/lang/System.out:Ljava/io/PrintStream;
     189: iload_3
     190: invokevirtual #109                // Method java/io/PrintStream.println:(I)V
     193: goto          205
     196: ldc           #111                // String Position not found
     198: getstatic     #104                // Field java/lang/System.out:Ljava/io/PrintStream;
     201: swap
     202: invokevirtual #113                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     205: return

  public static final int binarySearchRecursive(int[], int, int, int);
    Code:
       0: aload_0
       1: ldc           #134                // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_2
       7: iload_3
       8: if_icmpgt     68
      11: iload_2
      12: iload_3
      13: iadd
      14: iconst_2
      15: idiv
      16: istore        4
      18: nop
      19: iload_1
      20: aload_0
      21: iload         4
      23: iaload
      24: if_icmple     38
      27: aload_0
      28: iload_1
      29: iload         4
      31: iconst_1
      32: iadd
      33: iload_3
      34: invokestatic  #98                 // Method binarySearchRecursive:([IIII)I
      37: ireturn
      38: iload_1
      39: aload_0
      40: iload         4
      42: iaload
      43: if_icmpge     57
      46: aload_0
      47: iload_1
      48: iload_2
      49: iload         4
      51: iconst_1
      52: isub
      53: invokestatic  #98                 // Method binarySearchRecursive:([IIII)I
      56: ireturn
      57: iload_1
      58: aload_0
      59: iload         4
      61: iaload
      62: if_icmpne     6
      65: iload         4
      67: ireturn
      68: iconst_m1
      69: ireturn
}


package main.algorithms.sorting

fun main(args: Array<String>) {
    val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array
    mergeSort(array)
    for(i in array) println(i)
}

fun mergeSort(array : IntArray, helper:IntArray = IntArray(array.size), low:Int = 0, high : Int = array.size-1) {
    if(low < high) {
        val middle:Int = (low+high)/2 // 2) calculating the middle element
        mergeSort(array, helper, low, middle) // 3) to sort left half
        mergeSort(array, helper, middle+1, high) // 4) to sort right half
        merge(array, helper, low, middle, high) // 5) Merge them
    }
}

fun merge (array: IntArray, helper: IntArray, low: Int, middle:Int, high: Int){
//    a) copying both halves into helper array
    for(i in low..high) helper[i] = array[i]

    var helperLeft = low
    var helperRight = middle + 1 // b) helper variables
    var current = low

    /*Iterate through helper array. Compare the left and right half, copying back the smaller element
    * from the two halves into original array*/

    while (helperLeft <= middle && helperRight <= high) { // c) condition to check helper left and helper right
        if(helper[helperLeft] <= helper[helperRight]) { // d) Check if value at helperLeft index is less than that of value at helper right
            array[current] = helper[helperLeft]
            helperLeft++
        } else { // e) right element is smaller than left element
            array[current] = helper[helperRight]
            helperRight++
        }
        current++
    }

//   f) copy the rest of leftside of array into target
    val remaining = middle - helperLeft
    for (i in 0..remaining) {
        array[current + i] = helper[helperLeft + i]
    }

}

Compiled from "MergeSort.kt"
public final class main.algorithms.sorting.MergeSortKt {
  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: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       9: dup
      10: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: checkcast     #27                 // class java/lang/CharSequence
      16: iconst_1
      17: anewarray     #29                 // class java/lang/String
      20: astore_2
      21: aload_2
      22: iconst_0
      23: ldc           #31                 // String
      25: aastore
      26: aload_2
      27: iconst_0
      28: iconst_0
      29: bipush        6
      31: aconst_null
      32: invokestatic  #37                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      35: checkcast     #39                 // class java/lang/Iterable
      38: astore_2
      39: iconst_0
      40: istore_3
      41: aload_2
      42: astore        4
      44: new           #41                 // class java/util/ArrayList
      47: dup
      48: aload_2
      49: bipush        10
      51: invokestatic  #47                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      54: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      57: checkcast     #53                 // class java/util/Collection
      60: astore        5
      62: iconst_0
      63: istore        6
      65: aload         4
      67: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      72: astore        7
      74: aload         7
      76: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      81: ifeq          128
      84: aload         7
      86: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      91: astore        8
      93: aload         5
      95: aload         8
      97: checkcast     #29                 // class java/lang/String
     100: astore        9
     102: astore        11
     104: iconst_0
     105: istore        10
     107: aload         9
     109: invokestatic  #73                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     112: nop
     113: invokestatic  #77                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     116: aload         11
     118: swap
     119: invokeinterface #81,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          74
     128: aload         5
     130: checkcast     #83                 // class java/util/List
     133: nop
     134: checkcast     #53                 // class java/util/Collection
     137: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     140: astore_1
     141: aload_1
     142: aconst_null
     143: iconst_0
     144: iconst_0
     145: bipush        14
     147: aconst_null
     148: invokestatic  #91                 // Method mergeSort$default:([I[IIIILjava/lang/Object;)V
     151: iconst_0
     152: istore_2
     153: aload_1
     154: arraylength
     155: istore_3
     156: iload_2
     157: iload_3
     158: if_icmpge     180
     161: aload_1
     162: iload_2
     163: iaload
     164: istore        4
     166: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     169: iload         4
     171: invokevirtual #102                // Method java/io/PrintStream.println:(I)V
     174: iinc          2, 1
     177: goto          156
     180: return

  public static final void mergeSort(int[], int[], int, int);
    Code:
       0: aload_0
       1: ldc           #124                // String array
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #126                // String helper
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: iload_3
      14: if_icmpge     51
      17: iload_2
      18: iload_3
      19: iadd
      20: iconst_2
      21: idiv
      22: istore        4
      24: aload_0
      25: aload_1
      26: iload_2
      27: iload         4
      29: invokestatic  #128                // Method mergeSort:([I[III)V
      32: aload_0
      33: aload_1
      34: iload         4
      36: iconst_1
      37: iadd
      38: iload_3
      39: invokestatic  #128                // Method mergeSort:([I[III)V
      42: aload_0
      43: aload_1
      44: iload_2
      45: iload         4
      47: iload_3
      48: invokestatic  #132                // Method merge:([I[IIII)V
      51: return

  public static void mergeSort$default(int[], int[], int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          12
       7: aload_0
       8: arraylength
       9: newarray       int
      11: astore_1
      12: iload         4
      14: iconst_4
      15: iand
      16: ifeq          21
      19: iconst_0
      20: istore_2
      21: iload         4
      23: bipush        8
      25: iand
      26: ifeq          34
      29: aload_0
      30: arraylength
      31: iconst_1
      32: isub
      33: istore_3
      34: aload_0
      35: aload_1
      36: iload_2
      37: iload_3
      38: invokestatic  #128                // Method mergeSort:([I[III)V
      41: return

  public static final void merge(int[], int[], int, int, int);
    Code:
       0: aload_0
       1: ldc           #124                // String array
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #126                // String helper
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: istore        5
      15: iload         5
      17: iload         4
      19: if_icmpgt     43
      22: aload_1
      23: iload         5
      25: aload_0
      26: iload         5
      28: iaload
      29: iastore
      30: iload         5
      32: iload         4
      34: if_icmpeq     43
      37: iinc          5, 1
      40: goto          22
      43: iload_2
      44: istore        5
      46: iload_3
      47: iconst_1
      48: iadd
      49: istore        6
      51: iload_2
      52: istore        7
      54: iload         5
      56: iload_3
      57: if_icmpgt     109
      60: iload         6
      62: iload         4
      64: if_icmpgt     109
      67: aload_1
      68: iload         5
      70: iaload
      71: aload_1
      72: iload         6
      74: iaload
      75: if_icmpgt     92
      78: aload_0
      79: iload         7
      81: aload_1
      82: iload         5
      84: iaload
      85: iastore
      86: iinc          5, 1
      89: goto          103
      92: aload_0
      93: iload         7
      95: aload_1
      96: iload         6
      98: iaload
      99: iastore
     100: iinc          6, 1
     103: iinc          7, 1
     106: goto          54
     109: iload_3
     110: iload         5
     112: isub
     113: istore        8
     115: iconst_0
     116: istore        9
     118: iload         9
     120: iload         8
     122: if_icmpgt     152
     125: aload_0
     126: iload         7
     128: iload         9
     130: iadd
     131: aload_1
     132: iload         5
     134: iload         9
     136: iadd
     137: iaload
     138: iastore
     139: iload         9
     141: iload         8
     143: if_icmpeq     152
     146: iinc          9, 1
     149: goto          125
     152: return
}


package main.algorithms.sorting

fun main(args: Array<String>) {
    val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array
    quickSort(array, 0, array.size-1)

    for(i in array) println(i)
}

fun quickSort(array: IntArray, left: Int, right: Int) {
    val index = partition (array, left, right)
    if(left < index-1) { // 2) Sorting left half
        quickSort(array, left, index-1)
    }
    if(index < right) { // 3) Sorting right half
        quickSort(array,index, right)
    }
}

fun partition(array: IntArray, l: Int, r: Int): Int {
    var left = l
    var right = r
    val pivot = array[(left + right)/2] // 4) Pivot Point
    while (left <= right) {
        while (array[left] < pivot) left++ // 5) Find the elements on left that should be on right

        while (array[right] > pivot) right-- // 6) Find the elements on right that should be on left

        // 7) Swap elements, and move left and right indices
        if (left <= right) {
            swapArray(array, left,right)
            left++
            right--
        }

    }
    return left
}

fun swapArray(a: IntArray, b: Int, c: Int) {
    val temp = a[b]
    a[b] = a[c]
    a[c] = temp
}

Compiled from "QuickSort.kt"
public final class main.algorithms.sorting.QuickSortKt {
  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: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       9: dup
      10: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: checkcast     #27                 // class java/lang/CharSequence
      16: iconst_1
      17: anewarray     #29                 // class java/lang/String
      20: astore_2
      21: aload_2
      22: iconst_0
      23: ldc           #31                 // String
      25: aastore
      26: aload_2
      27: iconst_0
      28: iconst_0
      29: bipush        6
      31: aconst_null
      32: invokestatic  #37                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      35: checkcast     #39                 // class java/lang/Iterable
      38: astore_2
      39: iconst_0
      40: istore_3
      41: aload_2
      42: astore        4
      44: new           #41                 // class java/util/ArrayList
      47: dup
      48: aload_2
      49: bipush        10
      51: invokestatic  #47                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      54: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      57: checkcast     #53                 // class java/util/Collection
      60: astore        5
      62: iconst_0
      63: istore        6
      65: aload         4
      67: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      72: astore        7
      74: aload         7
      76: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      81: ifeq          128
      84: aload         7
      86: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      91: astore        8
      93: aload         5
      95: aload         8
      97: checkcast     #29                 // class java/lang/String
     100: astore        9
     102: astore        11
     104: iconst_0
     105: istore        10
     107: aload         9
     109: invokestatic  #73                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     112: nop
     113: invokestatic  #77                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     116: aload         11
     118: swap
     119: invokeinterface #81,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          74
     128: aload         5
     130: checkcast     #83                 // class java/util/List
     133: nop
     134: checkcast     #53                 // class java/util/Collection
     137: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     140: astore_1
     141: aload_1
     142: iconst_0
     143: aload_1
     144: arraylength
     145: iconst_1
     146: isub
     147: invokestatic  #91                 // Method quickSort:([III)V
     150: iconst_0
     151: istore_2
     152: aload_1
     153: arraylength
     154: istore_3
     155: iload_2
     156: iload_3
     157: if_icmpge     179
     160: aload_1
     161: iload_2
     162: iaload
     163: istore        4
     165: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     168: iload         4
     170: invokevirtual #102                // Method java/io/PrintStream.println:(I)V
     173: iinc          2, 1
     176: goto          155
     179: return

  public static final void quickSort(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #122                // String array
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: iload_2
       9: invokestatic  #126                // Method partition:([III)I
      12: istore_3
      13: iload_1
      14: iload_3
      15: iconst_1
      16: isub
      17: if_icmpge     28
      20: aload_0
      21: iload_1
      22: iload_3
      23: iconst_1
      24: isub
      25: invokestatic  #91                 // Method quickSort:([III)V
      28: iload_3
      29: iload_2
      30: if_icmpge     39
      33: aload_0
      34: iload_3
      35: iload_2
      36: invokestatic  #91                 // Method quickSort:([III)V
      39: return

  public static final int partition(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #122                // String array
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: istore_3
       8: iload_2
       9: istore        4
      11: aload_0
      12: iload_3
      13: iload         4
      15: iadd
      16: iconst_2
      17: idiv
      18: iaload
      19: istore        5
      21: iload_3
      22: iload         4
      24: if_icmpgt     78
      27: aload_0
      28: iload_3
      29: iaload
      30: iload         5
      32: if_icmpge     41
      35: iinc          3, 1
      38: goto          27
      41: aload_0
      42: iload         4
      44: iaload
      45: iload         5
      47: if_icmple     56
      50: iinc          4, -1
      53: goto          41
      56: iload_3
      57: iload         4
      59: if_icmpgt     21
      62: aload_0
      63: iload_3
      64: iload         4
      66: invokestatic  #132                // Method swapArray:([III)V
      69: iinc          3, 1
      72: iinc          4, -1
      75: goto          21
      78: iload_3
      79: ireturn

  public static final void swapArray(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #137                // String a
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: iaload
       9: istore_3
      10: aload_0
      11: iload_1
      12: aload_0
      13: iload_2
      14: iaload
      15: iastore
      16: aload_0
      17: iload_2
      18: iload_3
      19: iastore
      20: return
}


package main.basicprogramming.implementation.kotlin

fun main(args: Array<String>) {

    var testCases:Int = readLine()!!.toInt()

    while(testCases-- > 0) {
        val line1 = readLine()!!
        val line2 = readLine()!!
        val line3 = readLine()!!
        val line4 = readLine()!!

        if(ticTacToeLogic(line1,line2,line3,line4)) println("YES") else println("NO")
    }

}

fun ticTacToeLogic(line1:String, line2:String, line3:String, line4:String) : Boolean {
//    TODO: need to change some logic in case of expected next move

//    case -1 row check:
    if(checkPattern(line1) || checkPattern(line2)  || checkPattern(line3) || checkPattern(line4)) return true

//    case -2 column check
    else if(performColumnCheck(line1,line2,line3,line4)) return true

//    case -3 diagonal check
    else if(performDiagonalCheck(line1, line2, line3, line4)) return true
    return false
}

fun performDiagonalCheck(line1: String, line2: String, line3: String, line4: String): Boolean {
//    diagonals with 4 nodes
    val diagonalString1 = (line1[0].toString() + line2[1] + line3[2] + line4[3])
    val diagonalString2 = (line1[3].toString() + line2[2] + line3[1] + line4[0])

//    small diagonals with 3 nodes
    val diagonalString3 = (line1[1].toString() + line2[2] + line3[3])
    val diagonalString4 = (line1[2].toString() + line2[1] + line3[0])
    val diagonalString5 = (line2[0].toString() + line3[1] + line4[2])
    val diagonalString6 = (line2[2].toString() + line3[1] + line4[0])
    val diagonalString7 = (line2[3].toString() + line3[2] + line4[1])

    return (checkPattern(diagonalString1) || checkPattern(diagonalString2) || checkPattern(diagonalString3) || checkPattern(diagonalString4) || checkPattern(diagonalString5) || checkPattern(diagonalString6) || checkPattern(diagonalString7))

}

fun performColumnCheck(line1: String, line2: String, line3: String, line4: String): Boolean {
    for(i in 0..3) {
        val columnString = (line1[i].toString()+line2[i]+line3[i]+line4[i])
        if(checkPattern(columnString)) return true
    }
    return false
}

fun checkPattern(str:String) : Boolean{
    return str.contains("xx.") || str.contains(".xx") || str.contains("x.x")
}

Compiled from "BatmanAndTicTacToe.kt"
public final class main.basicprogramming.implementation.kotlin.BatmanAndTicTacToeKt {
  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: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       9: dup
      10: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: invokestatic  #31                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      16: istore_1
      17: iload_1
      18: iinc          1, -1
      21: ifle          94
      24: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      27: dup
      28: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      31: astore_2
      32: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      35: dup
      36: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      39: astore_3
      40: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      43: dup
      44: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      47: astore        4
      49: invokestatic  #21                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      52: dup
      53: invokestatic  #25                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      56: astore        5
      58: aload_2
      59: aload_3
      60: aload         4
      62: aload         5
      64: invokestatic  #35                 // Method ticTacToeLogic:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
      67: ifeq          82
      70: ldc           #37                 // String YES
      72: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      75: swap
      76: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      79: goto          17
      82: ldc           #50                 // String NO
      84: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      87: swap
      88: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      91: goto          17
      94: return

  public static final boolean ticTacToeLogic(java.lang.String, java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #62                 // String line1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #63                 // String line2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #64                 // String line3
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_3
      19: ldc           #65                 // String line4
      21: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      24: aload_0
      25: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
      28: ifne          52
      31: aload_1
      32: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
      35: ifne          52
      38: aload_2
      39: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
      42: ifne          52
      45: aload_3
      46: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
      49: ifeq          54
      52: iconst_1
      53: ireturn
      54: aload_0
      55: aload_1
      56: aload_2
      57: aload_3
      58: invokestatic  #72                 // Method performColumnCheck:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
      61: ifeq          66
      64: iconst_1
      65: ireturn
      66: aload_0
      67: aload_1
      68: aload_2
      69: aload_3
      70: invokestatic  #75                 // Method performDiagonalCheck:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
      73: ifeq          78
      76: iconst_1
      77: ireturn
      78: iconst_0
      79: ireturn

  public static final boolean performDiagonalCheck(java.lang.String, java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #62                 // String line1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #63                 // String line2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #64                 // String line3
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_3
      19: ldc           #65                 // String line4
      21: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      24: new           #77                 // class java/lang/StringBuilder
      27: dup
      28: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
      31: aload_0
      32: iconst_0
      33: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      36: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      39: aload_1
      40: iconst_1
      41: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      44: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      47: aload_2
      48: iconst_2
      49: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      52: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      55: aload_3
      56: iconst_3
      57: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      60: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      63: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      66: astore        4
      68: new           #77                 // class java/lang/StringBuilder
      71: dup
      72: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
      75: aload_0
      76: iconst_3
      77: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      80: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      83: aload_1
      84: iconst_2
      85: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      88: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      91: aload_2
      92: iconst_1
      93: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      96: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      99: aload_3
     100: iconst_0
     101: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     104: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     107: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     110: astore        5
     112: new           #77                 // class java/lang/StringBuilder
     115: dup
     116: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
     119: aload_0
     120: iconst_1
     121: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     124: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     127: aload_1
     128: iconst_2
     129: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     132: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     135: aload_2
     136: iconst_3
     137: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     140: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     143: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     146: astore        6
     148: new           #77                 // class java/lang/StringBuilder
     151: dup
     152: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
     155: aload_0
     156: iconst_2
     157: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     160: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     163: aload_1
     164: iconst_1
     165: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     168: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     171: aload_2
     172: iconst_0
     173: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     176: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     179: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     182: astore        7
     184: new           #77                 // class java/lang/StringBuilder
     187: dup
     188: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
     191: aload_1
     192: iconst_0
     193: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     196: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     199: aload_2
     200: iconst_1
     201: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     204: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     207: aload_3
     208: iconst_2
     209: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     212: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     215: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     218: astore        8
     220: new           #77                 // class java/lang/StringBuilder
     223: dup
     224: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
     227: aload_1
     228: iconst_2
     229: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     232: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     235: aload_2
     236: iconst_1
     237: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     240: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     243: aload_3
     244: iconst_0
     245: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     248: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     251: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     254: astore        9
     256: new           #77                 // class java/lang/StringBuilder
     259: dup
     260: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
     263: aload_1
     264: iconst_3
     265: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     268: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     271: aload_2
     272: iconst_2
     273: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     276: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     279: aload_3
     280: iconst_1
     281: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     284: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     287: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     290: astore        10
     292: aload         4
     294: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     297: ifne          348
     300: aload         5
     302: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     305: ifne          348
     308: aload         6
     310: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     313: ifne          348
     316: aload         7
     318: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     321: ifne          348
     324: aload         8
     326: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     329: ifne          348
     332: aload         9
     334: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     337: ifne          348
     340: aload         10
     342: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
     345: ifeq          352
     348: iconst_1
     349: goto          353
     352: iconst_0
     353: ireturn

  public static final boolean performColumnCheck(java.lang.String, java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #62                 // String line1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #63                 // String line2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #64                 // String line3
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_3
      19: ldc           #65                 // String line4
      21: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      24: iconst_0
      25: istore        4
      27: iload         4
      29: iconst_4
      30: if_icmpge     97
      33: new           #77                 // class java/lang/StringBuilder
      36: dup
      37: invokespecial #81                 // Method java/lang/StringBuilder."<init>":()V
      40: aload_0
      41: iload         4
      43: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      46: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      49: aload_1
      50: iload         4
      52: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      55: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      58: aload_2
      59: iload         4
      61: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      64: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      67: aload_3
      68: iload         4
      70: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
      73: invokevirtual #89                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      76: invokevirtual #92                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      79: astore        5
      81: aload         5
      83: invokestatic  #69                 // Method checkPattern:(Ljava/lang/String;)Z
      86: ifeq          91
      89: iconst_1
      90: ireturn
      91: iinc          4, 1
      94: goto          27
      97: iconst_0
      98: ireturn

  public static final boolean checkPattern(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #103                // String str
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #105                // class java/lang/CharSequence
      10: ldc           #107                // String xx.
      12: checkcast     #105                // class java/lang/CharSequence
      15: iconst_0
      16: iconst_2
      17: aconst_null
      18: invokestatic  #113                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      21: ifne          60
      24: aload_0
      25: checkcast     #105                // class java/lang/CharSequence
      28: ldc           #115                // String .xx
      30: checkcast     #105                // class java/lang/CharSequence
      33: iconst_0
      34: iconst_2
      35: aconst_null
      36: invokestatic  #113                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      39: ifne          60
      42: aload_0
      43: checkcast     #105                // class java/lang/CharSequence
      46: ldc           #117                // String x.x
      48: checkcast     #105                // class java/lang/CharSequence
      51: iconst_0
      52: iconst_2
      53: aconst_null
      54: invokestatic  #113                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      57: ifeq          64
      60: iconst_1
      61: goto          65
      64: iconst_0
      65: ireturn
}


package boj

import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs

class ChickenDelivery constructor(private val map: Array<Array<Int>>) {

    private val stores: List<Point> by lazy { getObjects(2) }
    private val houses: List<Point> by lazy { getObjects(1) }

    fun solution(m: Int): Int {
        val openStores = BooleanArray(stores.size)
        var result = Int.MAX_VALUE
        combination(0, m, 0, openStores) {
            val t = houses.asSequence().map { house ->
                stores.asSequence().filterIndexed { index, _ -> openStores[index] }
                    .map { it.distance(house) }.minOf { it }
            }.sum()
            result = result.coerceAtMost(t)
        }
        return result
    }

    private fun combination(s: Int, m: Int, c: Int, visited: BooleanArray, action: () -> Unit) {
        if (c == m) {
            action()
            return
        }
        for (i in s until stores.size) {
            if (visited[i]) continue

            visited[i] = true
            combination(i, m, c + 1, visited, action)
            visited[i] = false
        }
    }

    data class Point constructor(val x: Int, val y: Int) {

        fun distance(other: Point) = abs(x - other.x) + abs(y - other.y)
    }

    private fun getObjects(type: Int): List<Point> {
        val result = LinkedList<Point>()
        for (i in map.indices) {
            for (j in map[0].indices) {
                if (map[i][j] == type) {
                    result.add(Point(j, i))
                }
            }
        }
        return result
    }
}

fun chickenDelivery(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val (n, m) = br.readLine().trim().split(" ").map { it.toInt() }
    val map = Array(n) { br.readLine().trim().split(" ").map { it.toInt() }.toTypedArray() }

    val solution = ChickenDelivery(map)
    print(solution.solution(m))
}

Compiled from "ChickenDelivery.kt"
public final class boj.ChickenDelivery {
  private final java.lang.Integer[][] map;

  private final kotlin.Lazy stores$delegate;

  private final kotlin.Lazy houses$delegate;

  public boj.ChickenDelivery(java.lang.Integer[][]);
    Code:
       0: aload_1
       1: ldc           #9                  // String map
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field map:[[Ljava/lang/Integer;
      15: aload_0
      16: aload_0
      17: invokedynamic #41,  0             // InvokeDynamic #0:invoke:(Lboj/ChickenDelivery;)Lkotlin/jvm/functions/Function0;
      22: invokestatic  #47                 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;
      25: putfield      #51                 // Field stores$delegate:Lkotlin/Lazy;
      28: aload_0
      29: aload_0
      30: invokedynamic #56,  0             // InvokeDynamic #1:invoke:(Lboj/ChickenDelivery;)Lkotlin/jvm/functions/Function0;
      35: invokestatic  #47                 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;
      38: putfield      #59                 // Field houses$delegate:Lkotlin/Lazy;
      41: return

  private final java.util.List<boj.ChickenDelivery$Point> getStores();
    Code:
       0: aload_0
       1: getfield      #51                 // Field stores$delegate:Lkotlin/Lazy;
       4: astore_1
       5: aload_1
       6: invokeinterface #68,  1           // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;
      11: checkcast     #70                 // class java/util/List
      14: areturn

  private final java.util.List<boj.ChickenDelivery$Point> getHouses();
    Code:
       0: aload_0
       1: getfield      #59                 // Field houses$delegate:Lkotlin/Lazy;
       4: astore_1
       5: aload_1
       6: invokeinterface #68,  1           // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;
      11: checkcast     #70                 // class java/util/List
      14: areturn

  public final int solution(int);
    Code:
       0: aload_0
       1: invokespecial #75                 // Method getStores:()Ljava/util/List;
       4: invokeinterface #79,  1           // InterfaceMethod java/util/List.size:()I
       9: newarray       boolean
      11: astore_2
      12: new           #81                 // class kotlin/jvm/internal/Ref$IntRef
      15: dup
      16: invokespecial #82                 // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
      19: astore_3
      20: aload_3
      21: ldc           #83                 // int 2147483647
      23: putfield      #87                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      26: aload_0
      27: iconst_0
      28: iload_1
      29: iconst_0
      30: aload_2
      31: aload_0
      32: aload_3
      33: aload_2
      34: invokedynamic #97,  0             // InvokeDynamic #2:invoke:(Lboj/ChickenDelivery;Lkotlin/jvm/internal/Ref$IntRef;[Z)Lkotlin/jvm/functions/Function0;
      39: invokespecial #101                // Method combination:(III[ZLkotlin/jvm/functions/Function0;)V
      42: aload_3
      43: getfield      #87                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      46: ireturn

  private final void combination(int, int, int, boolean[], kotlin.jvm.functions.Function0<kotlin.Unit>);
    Code:
       0: iload_3
       1: iload_2
       2: if_icmpne     14
       5: aload         5
       7: invokeinterface #111,  1          // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;
      12: pop
      13: return
      14: iload_1
      15: istore        6
      17: aload_0
      18: invokespecial #75                 // Method getStores:()Ljava/util/List;
      21: invokeinterface #79,  1           // InterfaceMethod java/util/List.size:()I
      26: istore        7
      28: iload         6
      30: iload         7
      32: if_icmpge     75
      35: aload         4
      37: iload         6
      39: baload
      40: ifne          69
      43: aload         4
      45: iload         6
      47: iconst_1
      48: bastore
      49: aload_0
      50: iload         6
      52: iload_2
      53: iload_3
      54: iconst_1
      55: iadd
      56: aload         4
      58: aload         5
      60: invokespecial #101                // Method combination:(III[ZLkotlin/jvm/functions/Function0;)V
      63: aload         4
      65: iload         6
      67: iconst_0
      68: bastore
      69: iinc          6, 1
      72: goto          28
      75: return

  private final java.util.List<boj.ChickenDelivery$Point> getObjects(int);
    Code:
       0: new           #122                // class java/util/LinkedList
       3: dup
       4: invokespecial #123                // Method java/util/LinkedList."<init>":()V
       7: astore_2
       8: iconst_0
       9: istore_3
      10: aload_0
      11: getfield      #21                 // Field map:[[Ljava/lang/Integer;
      14: checkcast     #125                // class "[Ljava/lang/Object;"
      17: arraylength
      18: istore        4
      20: iload_3
      21: iload         4
      23: if_icmpge     88
      26: iconst_0
      27: istore        5
      29: aload_0
      30: getfield      #21                 // Field map:[[Ljava/lang/Integer;
      33: iconst_0
      34: aaload
      35: arraylength
      36: istore        6
      38: iload         5
      40: iload         6
      42: if_icmpge     82
      45: aload_0
      46: getfield      #21                 // Field map:[[Ljava/lang/Integer;
      49: iload_3
      50: aaload
      51: iload         5
      53: aaload
      54: invokevirtual #130                // Method java/lang/Integer.intValue:()I
      57: iload_1
      58: if_icmpne     76
      61: aload_2
      62: new           #132                // class boj/ChickenDelivery$Point
      65: dup
      66: iload         5
      68: iload_3
      69: invokespecial #135                // Method boj/ChickenDelivery$Point."<init>":(II)V
      72: invokevirtual #139                // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z
      75: pop
      76: iinc          5, 1
      79: goto          38
      82: iinc          3, 1
      85: goto          20
      88: aload_2
      89: checkcast     #70                 // class java/util/List
      92: areturn

  private static final java.util.List stores_delegate$lambda$0(boj.ChickenDelivery);
    Code:
       0: aload_0
       1: iconst_2
       2: invokespecial #144                // Method getObjects:(I)Ljava/util/List;
       5: areturn

  private static final java.util.List houses_delegate$lambda$1(boj.ChickenDelivery);
    Code:
       0: aload_0
       1: iconst_1
       2: invokespecial #144                // Method getObjects:(I)Ljava/util/List;
       5: areturn

  private static final boolean solution$lambda$6$lambda$5$lambda$2(boolean[], int, boj.ChickenDelivery$Point);
    Code:
       0: aload_2
       1: ldc           #149                // String <unused var>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: baload
       9: ireturn

  private static final int solution$lambda$6$lambda$5$lambda$3(boj.ChickenDelivery$Point, boj.ChickenDelivery$Point);
    Code:
       0: aload_1
       1: ldc           #155                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: aload_0
       8: invokevirtual #159                // Method boj/ChickenDelivery$Point.distance:(Lboj/ChickenDelivery$Point;)I
      11: ireturn

  private static final int solution$lambda$6$lambda$5(boj.ChickenDelivery, boolean[], boj.ChickenDelivery$Point);
    Code:
       0: aload_2
       1: ldc           #165                // String house
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #75                 // Method getStores:()Ljava/util/List;
      10: checkcast     #167                // class java/lang/Iterable
      13: invokestatic  #173                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      16: aload_1
      17: invokedynamic #183,  0            // InvokeDynamic #3:invoke:([Z)Lkotlin/jvm/functions/Function2;
      22: invokestatic  #189                // Method kotlin/sequences/SequencesKt.filterIndexed:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      25: aload_2
      26: invokedynamic #199,  0            // InvokeDynamic #4:invoke:(Lboj/ChickenDelivery$Point;)Lkotlin/jvm/functions/Function1;
      31: invokestatic  #202                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      34: invokeinterface #208,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      39: astore_3
      40: aload_3
      41: invokeinterface #214,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifne          57
      49: new           #216                // class java/util/NoSuchElementException
      52: dup
      53: invokespecial #217                // Method java/util/NoSuchElementException."<init>":()V
      56: athrow
      57: aload_3
      58: invokeinterface #220,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #222                // class java/lang/Number
      66: invokevirtual #223                // Method java/lang/Number.intValue:()I
      69: istore        4
      71: iconst_0
      72: istore        5
      74: iload         4
      76: istore        4
      78: aload_3
      79: invokeinterface #214,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          122
      87: aload_3
      88: invokeinterface #220,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      93: checkcast     #222                // class java/lang/Number
      96: invokevirtual #223                // Method java/lang/Number.intValue:()I
      99: istore        5
     101: iconst_0
     102: istore        6
     104: iload         5
     106: istore        5
     108: iload         4
     110: iload         5
     112: if_icmple     78
     115: iload         5
     117: istore        4
     119: goto          78
     122: iload         4
     124: ireturn

  private static final kotlin.Unit solution$lambda$6(boj.ChickenDelivery, kotlin.jvm.internal.Ref$IntRef, boolean[]);
    Code:
       0: aload_0
       1: invokespecial #226                // Method getHouses:()Ljava/util/List;
       4: checkcast     #167                // class java/lang/Iterable
       7: invokestatic  #173                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      10: aload_0
      11: aload_2
      12: invokedynamic #232,  0            // InvokeDynamic #5:invoke:(Lboj/ChickenDelivery;[Z)Lkotlin/jvm/functions/Function1;
      17: invokestatic  #202                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      20: invokestatic  #236                // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I
      23: istore_3
      24: aload_1
      25: aload_1
      26: getfield      #87                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      29: iload_3
      30: invokestatic  #242                // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I
      33: putfield      #87                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      36: getstatic     #248                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      39: areturn
}

Compiled from "ChickenDelivery.kt"
public final class boj.ChickenDeliveryKt {
  public static final void chickenDelivery(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: new           #17                 // class java/io/BufferedReader
       9: dup
      10: new           #19                 // class java/io/InputStreamReader
      13: dup
      14: getstatic     #25                 // Field java/lang/System.in:Ljava/io/InputStream;
      17: invokespecial #29                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      20: checkcast     #31                 // class java/io/Reader
      23: invokespecial #34                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
      26: astore_1
      27: aload_1
      28: invokevirtual #38                 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;
      31: dup
      32: ldc           #40                 // String readLine(...)
      34: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      37: checkcast     #45                 // class java/lang/CharSequence
      40: invokestatic  #51                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      43: invokevirtual #54                 // Method java/lang/Object.toString:()Ljava/lang/String;
      46: checkcast     #45                 // class java/lang/CharSequence
      49: iconst_1
      50: anewarray     #56                 // class java/lang/String
      53: astore_3
      54: aload_3
      55: iconst_0
      56: ldc           #58                 // String
      58: aastore
      59: aload_3
      60: iconst_0
      61: iconst_0
      62: bipush        6
      64: aconst_null
      65: invokestatic  #62                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      68: checkcast     #64                 // class java/lang/Iterable
      71: astore_3
      72: iconst_0
      73: istore        4
      75: aload_3
      76: astore        5
      78: new           #66                 // class java/util/ArrayList
      81: dup
      82: aload_3
      83: bipush        10
      85: invokestatic  #72                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      88: invokespecial #75                 // Method java/util/ArrayList."<init>":(I)V
      91: checkcast     #77                 // class java/util/Collection
      94: astore        6
      96: iconst_0
      97: istore        7
      99: aload         5
     101: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     106: astore        8
     108: aload         8
     110: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     115: ifeq          162
     118: aload         8
     120: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     125: astore        9
     127: aload         6
     129: aload         9
     131: checkcast     #56                 // class java/lang/String
     134: astore        10
     136: astore        18
     138: iconst_0
     139: istore        11
     141: aload         10
     143: invokestatic  #97                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     146: nop
     147: invokestatic  #101                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     150: aload         18
     152: swap
     153: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     158: pop
     159: goto          108
     162: aload         6
     164: checkcast     #107                // class java/util/List
     167: nop
     168: astore_2
     169: aload_2
     170: iconst_0
     171: invokeinterface #111,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     176: checkcast     #113                // class java/lang/Number
     179: invokevirtual #117                // Method java/lang/Number.intValue:()I
     182: istore_3
     183: aload_2
     184: iconst_1
     185: invokeinterface #111,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     190: checkcast     #113                // class java/lang/Number
     193: invokevirtual #117                // Method java/lang/Number.intValue:()I
     196: istore        4
     198: iconst_0
     199: istore        6
     201: iload_3
     202: anewarray     #119                // class "[Ljava/lang/Integer;"
     205: astore        7
     207: iload         6
     209: iload_3
     210: if_icmpge     411
     213: iload         6
     215: istore        8
     217: aload         7
     219: iload         8
     221: aload_1
     222: invokevirtual #38                 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;
     225: dup
     226: ldc           #40                 // String readLine(...)
     228: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     231: checkcast     #45                 // class java/lang/CharSequence
     234: invokestatic  #51                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     237: invokevirtual #54                 // Method java/lang/Object.toString:()Ljava/lang/String;
     240: checkcast     #45                 // class java/lang/CharSequence
     243: iconst_1
     244: anewarray     #56                 // class java/lang/String
     247: astore        9
     249: aload         9
     251: iconst_0
     252: ldc           #58                 // String
     254: aastore
     255: aload         9
     257: iconst_0
     258: iconst_0
     259: bipush        6
     261: aconst_null
     262: invokestatic  #62                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     265: checkcast     #64                 // class java/lang/Iterable
     268: astore        9
     270: istore        19
     272: astore        18
     274: iconst_0
     275: istore        10
     277: aload         9
     279: astore        11
     281: new           #66                 // class java/util/ArrayList
     284: dup
     285: aload         9
     287: bipush        10
     289: invokestatic  #72                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     292: invokespecial #75                 // Method java/util/ArrayList."<init>":(I)V
     295: checkcast     #77                 // class java/util/Collection
     298: astore        12
     300: iconst_0
     301: istore        13
     303: aload         11
     305: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     310: astore        14
     312: aload         14
     314: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     319: ifeq          366
     322: aload         14
     324: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     329: astore        15
     331: aload         12
     333: aload         15
     335: checkcast     #56                 // class java/lang/String
     338: astore        16
     340: astore        20
     342: iconst_0
     343: istore        17
     345: aload         16
     347: invokestatic  #97                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     350: nop
     351: invokestatic  #101                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     354: aload         20
     356: swap
     357: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     362: pop
     363: goto          312
     366: aload         12
     368: checkcast     #107                // class java/util/List
     371: nop
     372: astore        20
     374: aload         18
     376: iload         19
     378: aload         20
     380: checkcast     #77                 // class java/util/Collection
     383: astore        9
     385: nop
     386: iconst_0
     387: istore        10
     389: aload         9
     391: astore        11
     393: aload         11
     395: iconst_0
     396: anewarray     #93                 // class java/lang/Integer
     399: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     404: aastore
     405: iinc          6, 1
     408: goto          207
     411: aload         7
     413: astore        5
     415: new           #125                // class boj/ChickenDelivery
     418: dup
     419: aload         5
     421: invokespecial #128                // Method boj/ChickenDelivery."<init>":([[Ljava/lang/Integer;)V
     424: astore        6
     426: aload         6
     428: iload         4
     430: invokevirtual #132                // Method boj/ChickenDelivery.solution:(I)I
     433: istore        7
     435: getstatic     #136                // Field java/lang/System.out:Ljava/io/PrintStream;
     438: iload         7
     440: invokevirtual #141                // Method java/io/PrintStream.print:(I)V
     443: return
}

Compiled from "ChickenDelivery.kt"
public final class boj.ChickenDelivery$Point {
  private final int x;

  private final int y;

  public boj.ChickenDelivery$Point(int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field x:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field y:I
      14: return

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

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

  public final int distance(boj.ChickenDelivery$Point);
    Code:
       0: aload_1
       1: ldc           #26                 // String other
       3: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #13                 // Field x:I
      10: aload_1
      11: getfield      #13                 // Field x:I
      14: isub
      15: invokestatic  #38                 // Method java/lang/Math.abs:(I)I
      18: aload_0
      19: getfield      #16                 // Field y:I
      22: aload_1
      23: getfield      #16                 // Field y:I
      26: isub
      27: invokestatic  #38                 // Method java/lang/Math.abs:(I)I
      30: iadd
      31: ireturn

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

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

  public final boj.ChickenDelivery$Point copy(int, int);
    Code:
       0: new           #2                  // class boj/ChickenDelivery$Point
       3: dup
       4: iload_1
       5: iload_2
       6: invokespecial #44                 // Method "<init>":(II)V
       9: areturn

  public static boj.ChickenDelivery$Point copy$default(boj.ChickenDelivery$Point, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #13                 // Field x:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #16                 // Field y:I
      21: istore_2
      22: aload_0
      23: iload_1
      24: iload_2
      25: invokevirtual #48                 // Method copy:(II)Lboj/ChickenDelivery$Point;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #52                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #55                 // String Point(x=
       9: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field x:I
      16: invokevirtual #62                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #64                 // String , y=
      21: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field y:I
      28: invokevirtual #62                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #67                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #69                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field x:I
       4: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field y:I
      16: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class boj/ChickenDelivery$Point
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class boj/ChickenDelivery$Point
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field x:I
      25: aload_2
      26: getfield      #13                 // Field x:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field y:I
      38: aload_2
      39: getfield      #16                 // Field y:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: iconst_1
      48: ireturn
}