// https://app.codility.com/programmers/lessons/6-sorting/distinct/
fun distinct(A: IntArray): Int {
  return A.toSet().size
}

// https://app.codility.com/programmers/lessons/6-sorting/max_product_of_three/
fun maxProductOfThree(A: IntArray): Int {
  val indexWithA = A.withIndex().sortedBy { it.value }
  val length = A.size
  val positiveMaxValue = indexWithA[length - 1].value * indexWithA[length - 2].value * indexWithA[length - 3].value
  val negativeMaxValue = indexWithA[0].value * indexWithA[1].value * indexWithA[length - 1].value

  return if (positiveMaxValue > negativeMaxValue) positiveMaxValue else negativeMaxValue
}

// https://app.codility.com/programmers/lessons/6-sorting/number_of_disc_intersections/
// TODO: Refactor this O(N^2) time complexity
fun numberOfDiscIntersections(A: IntArray): Int {
  val sortedA = A.withIndex().sortedBy { it.index - it.value }

  return sortedA.asSequence().mapIndexed { index, sortedValue ->
    val rightEnd = if (sortedValue.index + sortedValue.value >= Int.MAX_VALUE) {
      Int.MAX_VALUE
    } else {
      sortedValue.index + sortedValue.value
    }
    sortedA.subList(index + 1, A.size).count {
      indexedValue ->
      rightEnd >= indexedValue.index - indexedValue.value
    }
  }.reduce { acc, number ->
    if (acc > 10000000) return -1
    acc + number
  }
}

// https://app.codility.com/programmers/lessons/6-sorting/triangle/
fun triangle(A: IntArray): Int {
  val windowedA = A.sorted().reversed().windowed(3, 1)

  windowedA.forEach {
    if (it[0] < it[1] + it[2]) return 1
  }
  return 0
}

Compiled from "Comparisons.kt"
public final class SortingKt$maxProductOfThree$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public SortingKt$maxProductOfThree$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/collections/IndexedValue
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Integer
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/collections/IndexedValue
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Integer
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "Comparisons.kt"
public final class SortingKt$numberOfDiscIntersections$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public SortingKt$numberOfDiscIntersections$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/collections/IndexedValue
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getIndex:()I
      12: aload_3
      13: invokevirtual #31                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      16: checkcast     #33                 // class java/lang/Number
      19: invokevirtual #36                 // Method java/lang/Number.intValue:()I
      22: isub
      23: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: checkcast     #44                 // class java/lang/Comparable
      29: aload_2
      30: checkcast     #23                 // class kotlin/collections/IndexedValue
      33: astore_3
      34: astore        5
      36: iconst_0
      37: istore        4
      39: aload_3
      40: invokevirtual #27                 // Method kotlin/collections/IndexedValue.getIndex:()I
      43: aload_3
      44: invokevirtual #31                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      47: checkcast     #33                 // class java/lang/Number
      50: invokevirtual #36                 // Method java/lang/Number.intValue:()I
      53: isub
      54: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: aload         5
      59: swap
      60: checkcast     #44                 // class java/lang/Comparable
      63: invokestatic  #50                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      66: ireturn
}

Compiled from "Sorting.kt"
public final class SortingKt {
  public static final int distinct(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String A
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #21                 // Method kotlin/collections/ArraysKt.toSet:([I)Ljava/util/Set;
      10: invokeinterface #27,  1           // InterfaceMethod java/util/Set.size:()I
      15: ireturn

  public static final int maxProductOfThree(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String A
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #33                 // Method kotlin/collections/ArraysKt.withIndex:([I)Ljava/lang/Iterable;
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: new           #35                 // class SortingKt$maxProductOfThree$$inlined$sortedBy$1
      17: dup
      18: invokespecial #39                 // Method SortingKt$maxProductOfThree$$inlined$sortedBy$1."<init>":()V
      21: checkcast     #41                 // class java/util/Comparator
      24: invokestatic  #47                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      27: astore_1
      28: aload_0
      29: arraylength
      30: istore_2
      31: aload_1
      32: iload_2
      33: iconst_1
      34: isub
      35: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #55                 // class kotlin/collections/IndexedValue
      43: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      46: checkcast     #61                 // class java/lang/Number
      49: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      52: aload_1
      53: iload_2
      54: iconst_2
      55: isub
      56: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #55                 // class kotlin/collections/IndexedValue
      64: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      67: checkcast     #61                 // class java/lang/Number
      70: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      73: imul
      74: aload_1
      75: iload_2
      76: iconst_3
      77: isub
      78: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      83: checkcast     #55                 // class kotlin/collections/IndexedValue
      86: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      89: checkcast     #61                 // class java/lang/Number
      92: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      95: imul
      96: istore_3
      97: aload_1
      98: iconst_0
      99: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     104: checkcast     #55                 // class kotlin/collections/IndexedValue
     107: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     110: checkcast     #61                 // class java/lang/Number
     113: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     116: aload_1
     117: iconst_1
     118: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     123: checkcast     #55                 // class kotlin/collections/IndexedValue
     126: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     129: checkcast     #61                 // class java/lang/Number
     132: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     135: imul
     136: aload_1
     137: iload_2
     138: iconst_1
     139: isub
     140: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: checkcast     #55                 // class kotlin/collections/IndexedValue
     148: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     151: checkcast     #61                 // class java/lang/Number
     154: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     157: imul
     158: istore        4
     160: iload_3
     161: iload         4
     163: if_icmple     170
     166: iload_3
     167: goto          172
     170: iload         4
     172: ireturn

  public static final int numberOfDiscIntersections(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String A
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #33                 // Method kotlin/collections/ArraysKt.withIndex:([I)Ljava/lang/Iterable;
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: new           #77                 // class SortingKt$numberOfDiscIntersections$$inlined$sortedBy$1
      17: dup
      18: invokespecial #78                 // Method SortingKt$numberOfDiscIntersections$$inlined$sortedBy$1."<init>":()V
      21: checkcast     #41                 // class java/util/Comparator
      24: invokestatic  #47                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      27: astore_1
      28: aload_1
      29: checkcast     #80                 // class java/lang/Iterable
      32: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      35: aload_1
      36: aload_0
      37: invokedynamic #104,  0            // InvokeDynamic #0:invoke:(Ljava/util/List;[I)Lkotlin/jvm/functions/Function2;
      42: invokestatic  #110                // Method kotlin/sequences/SequencesKt.mapIndexed:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      45: astore_2
      46: nop
      47: iconst_0
      48: istore_3
      49: aload_2
      50: invokeinterface #116,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      55: astore        4
      57: aload         4
      59: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifne          77
      67: new           #124                // class java/lang/UnsupportedOperationException
      70: dup
      71: ldc           #126                // String Empty sequence can\'t be reduced.
      73: invokespecial #129                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      76: athrow
      77: aload         4
      79: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        5
      86: aload         4
      88: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      93: ifeq          146
      96: aload         5
      98: aload         4
     100: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     105: checkcast     #61                 // class java/lang/Number
     108: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     111: istore        6
     113: checkcast     #61                 // class java/lang/Number
     116: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     119: istore        7
     121: iconst_0
     122: istore        8
     124: iload         7
     126: ldc           #133                // int 10000000
     128: if_icmple     133
     131: iconst_m1
     132: ireturn
     133: iload         7
     135: iload         6
     137: iadd
     138: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: astore        5
     143: goto          86
     146: aload         5
     148: checkcast     #61                 // class java/lang/Number
     151: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     154: ireturn

  public static final int triangle(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String A
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #155                // Method kotlin/collections/ArraysKt.sorted:([I)Ljava/util/List;
      10: checkcast     #80                 // class java/lang/Iterable
      13: invokestatic  #159                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      16: checkcast     #80                 // class java/lang/Iterable
      19: iconst_3
      20: iconst_1
      21: iconst_0
      22: iconst_4
      23: aconst_null
      24: invokestatic  #163                // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
      27: astore_1
      28: aload_1
      29: checkcast     #80                 // class java/lang/Iterable
      32: astore_2
      33: iconst_0
      34: istore_3
      35: aload_2
      36: invokeinterface #164,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        4
      43: aload         4
      45: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          125
      53: aload         4
      55: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        5
      62: aload         5
      64: checkcast     #49                 // class java/util/List
      67: astore        6
      69: iconst_0
      70: istore        7
      72: aload         6
      74: iconst_0
      75: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      80: checkcast     #61                 // class java/lang/Number
      83: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      86: aload         6
      88: iconst_1
      89: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #61                 // class java/lang/Number
      97: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     100: aload         6
     102: iconst_2
     103: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #61                 // class java/lang/Number
     111: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     114: iadd
     115: if_icmpge     120
     118: iconst_1
     119: ireturn
     120: nop
     121: nop
     122: goto          43
     125: nop
     126: iconst_0
     127: ireturn

  private static final int numberOfDiscIntersections$lambda$3(java.util.List, int[], int, kotlin.collections.IndexedValue);
    Code:
       0: aload_3
       1: ldc           #172                // String sortedValue
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: invokevirtual #175                // Method kotlin/collections/IndexedValue.getIndex:()I
      10: aload_3
      11: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      14: checkcast     #61                 // class java/lang/Number
      17: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      20: iadd
      21: ldc           #176                // int 2147483647
      23: if_icmplt     31
      26: ldc           #176                // int 2147483647
      28: goto          46
      31: aload_3
      32: invokevirtual #175                // Method kotlin/collections/IndexedValue.getIndex:()I
      35: aload_3
      36: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      39: checkcast     #61                 // class java/lang/Number
      42: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      45: iadd
      46: istore        4
      48: aload_0
      49: iload_2
      50: iconst_1
      51: iadd
      52: aload_1
      53: arraylength
      54: invokeinterface #180,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      59: checkcast     #80                 // class java/lang/Iterable
      62: astore        5
      64: iconst_0
      65: istore        6
      67: aload         5
      69: instanceof    #182                // class java/util/Collection
      72: ifeq          92
      75: aload         5
      77: checkcast     #182                // class java/util/Collection
      80: invokeinterface #185,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      85: ifeq          92
      88: iconst_0
      89: goto          179
      92: iconst_0
      93: istore        7
      95: aload         5
      97: invokeinterface #164,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     102: astore        8
     104: aload         8
     106: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     111: ifeq          177
     114: aload         8
     116: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     121: astore        9
     123: aload         9
     125: checkcast     #55                 // class kotlin/collections/IndexedValue
     128: astore        10
     130: iconst_0
     131: istore        11
     133: iload         4
     135: aload         10
     137: invokevirtual #175                // Method kotlin/collections/IndexedValue.getIndex:()I
     140: aload         10
     142: invokevirtual #59                 // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     145: checkcast     #61                 // class java/lang/Number
     148: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     151: isub
     152: if_icmplt     159
     155: iconst_1
     156: goto          160
     159: iconst_0
     160: ifeq          104
     163: iinc          7, 1
     166: iload         7
     168: ifge          104
     171: invokestatic  #188                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     174: goto          104
     177: iload         7
     179: ireturn
}


// https://app.codility.com/programmers/lessons/5-prefix_sums/count_div
fun countDiv(A: Int, B: Int, K: Int): Int {
  val startNumber = (A..B).firstOrNull {
    it % K ==0
  } ?: return 0

  return (B - startNumber) / K + 1
}

// https://app.codility.com/programmers/lessons/5-prefix_sums/genomic_range_query
/*
// O(N * M)
fun solution(S: String, P: IntArray, Q: IntArray): IntArray {
  fun String.findMinValue(): Int {
    if (this.contains('A')) return 1
    if (this.contains('C')) return 2
    if (this.contains('G')) return 3
    return 4
  }

  return P.indices.map {
    S.substring(P[it], Q[it] + 1).findMinValue()
  }.toIntArray()
}
*/

// O(N + M)
fun genomicRangeQuery(S: String, P: IntArray, Q: IntArray): IntArray {

  fun generateDeltaList(char: Char): IntArray {
    val deltaArray = IntArray(S.length + 1)
    (0..S.length).fold(0) { acc, index ->
      deltaArray[index] = acc
      if (index == S.length) {
        return@fold 0
      }
      acc + if (S[index] == char) 1 else 0
    }
    return deltaArray
  }

  val deltaA = generateDeltaList('A')
  val deltaC = generateDeltaList('C')
  val deltaG = generateDeltaList('G')

  fun String.findMinValue(start: Int, end: Int): Int {
    if (start == end) {
      return when (S[start]) {
        'A' -> 1
        'C' -> 2
        'G' -> 3
        else -> 4
      }
    }
    if (deltaA[start] != deltaA[end]) return 1
    if (deltaC[start] != deltaC[end]) return 2
    if (deltaG[start] != deltaG[end]) return 3
    return 4
  }

  return P.indices.map {
    S.substring(P[it], Q[it] + 1).findMinValue(P[it], Q[it] + 1)
  }.toIntArray()
}

// TODO: https://app.codility.com/programmers/lessons/5-prefix_sums/min_avg_two_slice

// https://app.codility.com/programmers/lessons/5-prefix_sums/passing_cars
fun passingCars(A: IntArray): Int {
  val accumulateCount = IntArray(A.size)
  A.foldIndexed(0) { index, acc, number ->
    accumulateCount[index] = acc + number
    acc + number
  }
  val totalCount = accumulateCount[A.size - 1]
  var count = 0

  accumulateCount.forEachIndexed { index, number ->
    if (A[index] == 1) return@forEachIndexed
    if (count + totalCount - number > 1000000000) return -1

    count += totalCount - number
  }
  return count
}

Compiled from "PrefixSums.kt"
public final class PrefixSumsKt {
  public static final int countDiv(int, int, int);
    Code:
       0: new           #8                  // class kotlin/ranges/IntRange
       3: dup
       4: iload_0
       5: iload_1
       6: invokespecial #12                 // Method kotlin/ranges/IntRange."<init>":(II)V
       9: checkcast     #14                 // class java/lang/Iterable
      12: astore        4
      14: iconst_0
      15: istore        5
      17: aload         4
      19: invokeinterface #18,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      24: astore        6
      26: aload         6
      28: invokeinterface #24,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      33: ifeq          78
      36: aload         6
      38: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      43: astore        7
      45: aload         7
      47: checkcast     #30                 // class java/lang/Number
      50: invokevirtual #34                 // Method java/lang/Number.intValue:()I
      53: istore        8
      55: iconst_0
      56: istore        9
      58: iload         8
      60: iload_2
      61: irem
      62: ifne          69
      65: iconst_1
      66: goto          70
      69: iconst_0
      70: ifeq          26
      73: aload         7
      75: goto          79
      78: aconst_null
      79: checkcast     #36                 // class java/lang/Integer
      82: dup
      83: ifnull        92
      86: invokevirtual #37                 // Method java/lang/Integer.intValue:()I
      89: goto          95
      92: pop
      93: iconst_0
      94: ireturn
      95: istore_3
      96: iload_1
      97: iload_3
      98: isub
      99: iload_2
     100: idiv
     101: iconst_1
     102: iadd
     103: ireturn

  public static final int[] genomicRangeQuery(java.lang.String, int[], int[]);
    Code:
       0: aload_0
       1: ldc           #54                 // String S
       3: invokestatic  #60                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #62                 // String P
       9: invokestatic  #60                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #64                 // String Q
      15: invokestatic  #60                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: bipush        65
      21: invokestatic  #68                 // Method genomicRangeQuery$generateDeltaList:(Ljava/lang/String;C)[I
      24: astore_3
      25: aload_0
      26: bipush        67
      28: invokestatic  #68                 // Method genomicRangeQuery$generateDeltaList:(Ljava/lang/String;C)[I
      31: astore        4
      33: aload_0
      34: bipush        71
      36: invokestatic  #68                 // Method genomicRangeQuery$generateDeltaList:(Ljava/lang/String;C)[I
      39: astore        5
      41: aload_1
      42: invokestatic  #74                 // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
      45: checkcast     #14                 // class java/lang/Iterable
      48: astore        6
      50: iconst_0
      51: istore        7
      53: aload         6
      55: astore        8
      57: new           #76                 // class java/util/ArrayList
      60: dup
      61: aload         6
      63: bipush        10
      65: invokestatic  #82                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      68: invokespecial #85                 // Method java/util/ArrayList."<init>":(I)V
      71: checkcast     #87                 // class java/util/Collection
      74: astore        9
      76: iconst_0
      77: istore        10
      79: aload         8
      81: invokeinterface #18,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      86: astore        11
      88: aload         11
      90: invokeinterface #24,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      95: ifeq          173
      98: aload         11
     100: checkcast     #89                 // class kotlin/collections/IntIterator
     103: invokevirtual #92                 // Method kotlin/collections/IntIterator.nextInt:()I
     106: istore        12
     108: aload         9
     110: iload         12
     112: istore        13
     114: astore        15
     116: iconst_0
     117: istore        14
     119: aload_0
     120: aload_1
     121: iload         13
     123: iaload
     124: aload_2
     125: iload         13
     127: iaload
     128: iconst_1
     129: iadd
     130: invokevirtual #98                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     133: dup
     134: ldc           #100                // String substring(...)
     136: invokestatic  #103                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     139: aload_0
     140: aload_3
     141: aload         4
     143: aload         5
     145: aload_1
     146: iload         13
     148: iaload
     149: aload_2
     150: iload         13
     152: iaload
     153: iconst_1
     154: iadd
     155: invokestatic  #107                // Method genomicRangeQuery$findMinValue:(Ljava/lang/String;Ljava/lang/String;[I[I[III)I
     158: invokestatic  #111                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     161: aload         15
     163: swap
     164: invokeinterface #115,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     169: pop
     170: goto          88
     173: aload         9
     175: checkcast     #117                // class java/util/List
     178: nop
     179: checkcast     #87                 // class java/util/Collection
     182: invokestatic  #121                // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     185: areturn

  public static final int passingCars(int[]);
    Code:
       0: aload_0
       1: ldc           #138                // String A
       3: invokestatic  #60                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: arraylength
       8: newarray       int
      10: astore_1
      11: aload_0
      12: astore_2
      13: iconst_0
      14: istore_3
      15: iconst_0
      16: istore        4
      18: iconst_0
      19: istore        5
      21: iload_3
      22: istore        6
      24: iconst_0
      25: istore        7
      27: aload_2
      28: arraylength
      29: istore        8
      31: iload         7
      33: iload         8
      35: if_icmpge     84
      38: aload_2
      39: iload         7
      41: iaload
      42: istore        9
      44: iload         5
      46: iinc          5, 1
      49: iload         6
      51: iload         9
      53: istore        10
      55: istore        11
      57: istore        12
      59: iconst_0
      60: istore        13
      62: aload_1
      63: iload         12
      65: iload         11
      67: iload         10
      69: iadd
      70: iastore
      71: iload         11
      73: iload         10
      75: iadd
      76: istore        6
      78: iinc          7, 1
      81: goto          31
      84: nop
      85: aload_1
      86: aload_0
      87: arraylength
      88: iconst_1
      89: isub
      90: iaload
      91: istore_2
      92: iconst_0
      93: istore_3
      94: aload_1
      95: astore        4
      97: iconst_0
      98: istore        5
     100: iconst_0
     101: istore        6
     103: iconst_0
     104: istore        7
     106: aload         4
     108: arraylength
     109: istore        8
     111: iload         7
     113: iload         8
     115: if_icmpge     175
     118: aload         4
     120: iload         7
     122: iaload
     123: istore        9
     125: iload         6
     127: iinc          6, 1
     130: iload         9
     132: istore        10
     134: istore        11
     136: iconst_0
     137: istore        12
     139: aload_0
     140: iload         11
     142: iaload
     143: iconst_1
     144: if_icmpeq     168
     147: iload_3
     148: iload_2
     149: iadd
     150: iload         10
     152: isub
     153: ldc           #139                // int 1000000000
     155: if_icmple     160
     158: iconst_m1
     159: ireturn
     160: iload_3
     161: iload_2
     162: iload         10
     164: isub
     165: iadd
     166: istore_3
     167: nop
     168: nop
     169: iinc          7, 1
     172: goto          111
     175: nop
     176: iload_3
     177: ireturn

  private static final int[] genomicRangeQuery$generateDeltaList(java.lang.String, char);
    Code:
       0: aload_0
       1: invokevirtual #158                // Method java/lang/String.length:()I
       4: iconst_1
       5: iadd
       6: newarray       int
       8: astore_2
       9: new           #8                  // class kotlin/ranges/IntRange
      12: dup
      13: iconst_0
      14: aload_0
      15: invokevirtual #158                // Method java/lang/String.length:()I
      18: invokespecial #12                 // Method kotlin/ranges/IntRange."<init>":(II)V
      21: checkcast     #14                 // class java/lang/Iterable
      24: astore_3
      25: iconst_0
      26: istore        4
      28: iconst_0
      29: istore        5
      31: iload         4
      33: istore        6
      35: aload_3
      36: invokeinterface #18,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #24,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          116
      53: aload         7
      55: checkcast     #89                 // class kotlin/collections/IntIterator
      58: invokevirtual #92                 // Method kotlin/collections/IntIterator.nextInt:()I
      61: istore        8
      63: iload         6
      65: iload         8
      67: istore        9
      69: istore        10
      71: iconst_0
      72: istore        11
      74: aload_2
      75: iload         9
      77: iload         10
      79: iastore
      80: iload         9
      82: aload_0
      83: invokevirtual #158                // Method java/lang/String.length:()I
      86: if_icmpne     93
      89: iconst_0
      90: goto          111
      93: iload         10
      95: aload_0
      96: iload         9
      98: invokevirtual #162                // Method java/lang/String.charAt:(I)C
     101: iload_1
     102: if_icmpne     109
     105: iconst_1
     106: goto          110
     109: iconst_0
     110: iadd
     111: istore        6
     113: goto          43
     116: nop
     117: aload_2
     118: areturn

  private static final int genomicRangeQuery$findMinValue(java.lang.String, java.lang.String, int[], int[], int[], int, int);
    Code:
       0: iload         5
       2: iload         6
       4: if_icmpne     62
       7: aload_1
       8: iload         5
      10: invokevirtual #162                // Method java/lang/String.charAt:(I)C
      13: lookupswitch  { // 3
                    65: 48
                    67: 52
                    71: 56
               default: 60
          }
      48: iconst_1
      49: goto          61
      52: iconst_2
      53: goto          61
      56: iconst_3
      57: goto          61
      60: iconst_4
      61: ireturn
      62: aload_2
      63: iload         5
      65: iaload
      66: aload_2
      67: iload         6
      69: iaload
      70: if_icmpeq     75
      73: iconst_1
      74: ireturn
      75: aload_3
      76: iload         5
      78: iaload
      79: aload_3
      80: iload         6
      82: iaload
      83: if_icmpeq     88
      86: iconst_2
      87: ireturn
      88: aload         4
      90: iload         5
      92: iaload
      93: aload         4
      95: iload         6
      97: iaload
      98: if_icmpeq     103
     101: iconst_3
     102: ireturn
     103: iconst_4
     104: ireturn
}


//usr/bin/env [ $0 -nt $0.jar ] && kotlinc -d $0.jar $0; [ $0.jar -nt $0 ] && kotlin -cp $0.jar VimcashKt $@; exit 0

import java.io.File

fun String.parseAmount(account: String): Double {
    return substring(22, 34).toDouble() * if (indexOf(" $account ") > 34) -1 else 1
}

fun File.calculateBalance(account: String, currency: String): Double {
    val filterRegex = Regex(".{15}\\|  $currency [0-9. ]+[^ ]* $account .*")
    return readLines()
        .filter { it.matches(filterRegex) }
        .map { it.parseAmount(account) }
        .sum()
}

fun File.calculateBalances(account: String): Map<String, Double> {
    val filterRegex = Regex(".{15}\\|  ... [0-9. ]+[^ ]* $account .*")
    val results = mutableMapOf<String, Double>()
    readLines()
        .filter { it.matches(filterRegex) }
        .forEach {
            val currency = it.slice(18..20)
            val amount = it.parseAmount(account)
            results.put(currency, results.get(currency)?.plus(amount) ?: amount)
        }
    return results
}

fun File.collectAccounts(): Set<String> {
    return readLines()
        .flatMap { it.substring(34, 52).split(' ') }
        .toSortedSet()
}

fun File.reportBalances() {
     collectAccounts()
         .filter { it.matches(allCapsRegex) }
         .associate { Pair(it, calculateBalances(it).filter { it.value.abs() > 0.005 }) }
         .filter { it.value.size > 0 }
         .forEach { println(it) }
}
val allCapsRegex = Regex("[0-9A-Z]+")

fun Double.abs(): Double = kotlin.math.abs(this)

Compiled from "vimcash.kt"
public final class VimcashKt {
  private static final kotlin.text.Regex allCapsRegex;

  public static final double parseAmount(java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String account
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: bipush        22
      15: bipush        34
      17: invokevirtual #23                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      20: dup
      21: ldc           #25                 // String substring(...)
      23: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      26: invokestatic  #34                 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      29: aload_0
      30: checkcast     #36                 // class java/lang/CharSequence
      33: new           #38                 // class java/lang/StringBuilder
      36: dup
      37: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      40: bipush        32
      42: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      45: aload_1
      46: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      49: bipush        32
      51: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      54: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: iconst_0
      58: iconst_0
      59: bipush        6
      61: aconst_null
      62: invokestatic  #59                 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I
      65: bipush        34
      67: if_icmple     74
      70: iconst_m1
      71: goto          75
      74: iconst_1
      75: i2d
      76: dmul
      77: dreturn

  public static final double calculateBalance(java.io.File, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String account
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #65                 // String currency
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: new           #67                 // class kotlin/text/Regex
      21: dup
      22: new           #38                 // class java/lang/StringBuilder
      25: dup
      26: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      29: ldc           #69                 // String .{15}\\|
      31: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      34: aload_2
      35: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: ldc           #71                 // String  [0-9. ]+[^ ]*
      40: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      43: aload_1
      44: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      47: ldc           #73                 // String  .*
      49: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      55: invokespecial #76                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      58: astore_3
      59: aload_0
      60: aconst_null
      61: iconst_1
      62: aconst_null
      63: invokestatic  #82                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      66: checkcast     #84                 // class java/lang/Iterable
      69: astore        4
      71: nop
      72: iconst_0
      73: istore        5
      75: aload         4
      77: astore        6
      79: new           #86                 // class java/util/ArrayList
      82: dup
      83: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      86: checkcast     #89                 // class java/util/Collection
      89: astore        7
      91: iconst_0
      92: istore        8
      94: aload         6
      96: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     101: astore        9
     103: aload         9
     105: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     110: ifeq          159
     113: aload         9
     115: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     120: astore        10
     122: aload         10
     124: checkcast     #19                 // class java/lang/String
     127: astore        11
     129: iconst_0
     130: istore        12
     132: aload         11
     134: checkcast     #36                 // class java/lang/CharSequence
     137: aload_3
     138: swap
     139: invokevirtual #107                // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
     142: nop
     143: ifeq          103
     146: aload         7
     148: aload         10
     150: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     155: pop
     156: goto          103
     159: aload         7
     161: checkcast     #113                // class java/util/List
     164: nop
     165: checkcast     #84                 // class java/lang/Iterable
     168: astore        4
     170: nop
     171: iconst_0
     172: istore        5
     174: aload         4
     176: astore        6
     178: new           #86                 // class java/util/ArrayList
     181: dup
     182: aload         4
     184: bipush        10
     186: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     189: invokespecial #122                // Method java/util/ArrayList."<init>":(I)V
     192: checkcast     #89                 // class java/util/Collection
     195: astore        7
     197: iconst_0
     198: istore        8
     200: aload         6
     202: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     207: astore        9
     209: aload         9
     211: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     216: ifeq          263
     219: aload         9
     221: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     226: astore        10
     228: aload         7
     230: aload         10
     232: checkcast     #19                 // class java/lang/String
     235: astore        11
     237: astore        13
     239: iconst_0
     240: istore        12
     242: aload         11
     244: aload_1
     245: invokestatic  #124                // Method parseAmount:(Ljava/lang/String;Ljava/lang/String;)D
     248: invokestatic  #128                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     251: aload         13
     253: swap
     254: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     259: pop
     260: goto          209
     263: aload         7
     265: checkcast     #113                // class java/util/List
     268: nop
     269: checkcast     #84                 // class java/lang/Iterable
     272: invokestatic  #132                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
     275: dreturn

  public static final java.util.Map<java.lang.String, java.lang.Double> calculateBalances(java.io.File, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String account
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #67                 // class kotlin/text/Regex
      15: dup
      16: new           #38                 // class java/lang/StringBuilder
      19: dup
      20: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      23: ldc           #161                // String .{15}\\|  ... [0-9. ]+[^ ]*
      25: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      28: aload_1
      29: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      32: ldc           #73                 // String  .*
      34: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      37: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      40: invokespecial #76                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      43: astore_2
      44: new           #163                // class java/util/LinkedHashMap
      47: dup
      48: invokespecial #164                // Method java/util/LinkedHashMap."<init>":()V
      51: checkcast     #166                // class java/util/Map
      54: astore_3
      55: aload_0
      56: aconst_null
      57: iconst_1
      58: aconst_null
      59: invokestatic  #82                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      62: checkcast     #84                 // class java/lang/Iterable
      65: astore        4
      67: nop
      68: iconst_0
      69: istore        5
      71: aload         4
      73: astore        6
      75: new           #86                 // class java/util/ArrayList
      78: dup
      79: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      82: checkcast     #89                 // class java/util/Collection
      85: astore        7
      87: iconst_0
      88: istore        8
      90: aload         6
      92: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      97: astore        9
      99: aload         9
     101: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     106: ifeq          155
     109: aload         9
     111: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     116: astore        10
     118: aload         10
     120: checkcast     #19                 // class java/lang/String
     123: astore        11
     125: iconst_0
     126: istore        12
     128: aload         11
     130: checkcast     #36                 // class java/lang/CharSequence
     133: aload_2
     134: swap
     135: invokevirtual #107                // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
     138: nop
     139: ifeq          99
     142: aload         7
     144: aload         10
     146: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     151: pop
     152: goto          99
     155: aload         7
     157: checkcast     #113                // class java/util/List
     160: nop
     161: checkcast     #84                 // class java/lang/Iterable
     164: astore        4
     166: nop
     167: iconst_0
     168: istore        5
     170: aload         4
     172: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     177: astore        6
     179: aload         6
     181: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     186: ifeq          278
     189: aload         6
     191: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     196: astore        7
     198: aload         7
     200: checkcast     #19                 // class java/lang/String
     203: astore        8
     205: iconst_0
     206: istore        9
     208: aload         8
     210: new           #168                // class kotlin/ranges/IntRange
     213: dup
     214: bipush        18
     216: bipush        20
     218: invokespecial #171                // Method kotlin/ranges/IntRange."<init>":(II)V
     221: invokestatic  #175                // Method kotlin/text/StringsKt.slice:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;
     224: astore        10
     226: aload         8
     228: aload_1
     229: invokestatic  #124                // Method parseAmount:(Ljava/lang/String;Ljava/lang/String;)D
     232: dstore        11
     234: aload_3
     235: aload         10
     237: aload_3
     238: aload         10
     240: invokeinterface #179,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     245: checkcast     #30                 // class java/lang/Double
     248: dup
     249: ifnull        261
     252: invokevirtual #183                // Method java/lang/Double.doubleValue:()D
     255: dload         11
     257: dadd
     258: goto          264
     261: pop
     262: dload         11
     264: invokestatic  #128                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     267: invokeinterface #187,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     272: pop
     273: nop
     274: nop
     275: goto          179
     278: nop
     279: aload_3
     280: areturn

  public static final java.util.Set<java.lang.String> collectAccounts(java.io.File);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aconst_null
       8: iconst_1
       9: aconst_null
      10: invokestatic  #82                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      13: checkcast     #84                 // class java/lang/Iterable
      16: astore_1
      17: nop
      18: iconst_0
      19: istore_2
      20: aload_1
      21: astore_3
      22: new           #86                 // class java/util/ArrayList
      25: dup
      26: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      29: checkcast     #89                 // class java/util/Collection
      32: astore        4
      34: iconst_0
      35: istore        5
      37: aload_3
      38: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        6
      45: aload         6
      47: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          129
      55: aload         6
      57: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        7
      64: aload         7
      66: checkcast     #19                 // class java/lang/String
      69: astore        8
      71: iconst_0
      72: istore        9
      74: aload         8
      76: bipush        34
      78: bipush        52
      80: invokevirtual #23                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      83: dup
      84: ldc           #25                 // String substring(...)
      86: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      89: checkcast     #36                 // class java/lang/CharSequence
      92: iconst_1
      93: newarray       char
      95: astore        10
      97: aload         10
      99: iconst_0
     100: bipush        32
     102: castore
     103: aload         10
     105: iconst_0
     106: iconst_0
     107: bipush        6
     109: aconst_null
     110: invokestatic  #204                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     113: checkcast     #84                 // class java/lang/Iterable
     116: astore        8
     118: aload         4
     120: aload         8
     122: invokestatic  #208                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     125: pop
     126: goto          45
     129: aload         4
     131: checkcast     #113                // class java/util/List
     134: nop
     135: checkcast     #84                 // class java/lang/Iterable
     138: invokestatic  #212                // Method kotlin/collections/CollectionsKt.toSortedSet:(Ljava/lang/Iterable;)Ljava/util/SortedSet;
     141: checkcast     #214                // class java/util/Set
     144: areturn

  public static final void reportBalances(java.io.File);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #225                // Method collectAccounts:(Ljava/io/File;)Ljava/util/Set;
      10: checkcast     #84                 // class java/lang/Iterable
      13: astore_1
      14: nop
      15: iconst_0
      16: istore_2
      17: aload_1
      18: astore_3
      19: new           #86                 // class java/util/ArrayList
      22: dup
      23: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      26: checkcast     #89                 // class java/util/Collection
      29: astore        4
      31: iconst_0
      32: istore        5
      34: aload_3
      35: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        6
      42: aload         6
      44: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          100
      52: aload         6
      54: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        7
      61: aload         7
      63: checkcast     #19                 // class java/lang/String
      66: astore        8
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #36                 // class java/lang/CharSequence
      76: getstatic     #228                // Field allCapsRegex:Lkotlin/text/Regex;
      79: swap
      80: invokevirtual #107                // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
      83: nop
      84: ifeq          42
      87: aload         4
      89: aload         7
      91: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          42
     100: aload         4
     102: checkcast     #113                // class java/util/List
     105: nop
     106: checkcast     #84                 // class java/lang/Iterable
     109: astore_1
     110: nop
     111: iconst_0
     112: istore_2
     113: aload_1
     114: bipush        10
     116: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     119: invokestatic  #234                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     122: bipush        16
     124: invokestatic  #240                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     127: istore_3
     128: aload_1
     129: astore        4
     131: new           #163                // class java/util/LinkedHashMap
     134: dup
     135: iload_3
     136: invokespecial #241                // Method java/util/LinkedHashMap."<init>":(I)V
     139: checkcast     #166                // class java/util/Map
     142: astore        5
     144: iconst_0
     145: istore        6
     147: aload         4
     149: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        7
     156: aload         7
     158: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          366
     166: aload         7
     168: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: astore        8
     175: aload         5
     177: astore        9
     179: aload         8
     181: checkcast     #19                 // class java/lang/String
     184: astore        10
     186: iconst_0
     187: istore        11
     189: aload         10
     191: aload_0
     192: aload         10
     194: invokestatic  #243                // Method calculateBalances:(Ljava/io/File;Ljava/lang/String;)Ljava/util/Map;
     197: astore        12
     199: astore        13
     201: iconst_0
     202: istore        14
     204: aload         12
     206: astore        15
     208: new           #163                // class java/util/LinkedHashMap
     211: dup
     212: invokespecial #164                // Method java/util/LinkedHashMap."<init>":()V
     215: checkcast     #166                // class java/util/Map
     218: astore        16
     220: iconst_0
     221: istore        17
     223: aload         15
     225: invokeinterface #247,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     230: invokeinterface #248,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     235: astore        18
     237: aload         18
     239: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     244: ifeq          322
     247: aload         18
     249: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     254: checkcast     #250                // class java/util/Map$Entry
     257: astore        19
     259: aload         19
     261: astore        20
     263: iconst_0
     264: istore        21
     266: aload         20
     268: invokeinterface #253,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     273: checkcast     #255                // class java/lang/Number
     276: invokevirtual #256                // Method java/lang/Number.doubleValue:()D
     279: invokestatic  #260                // Method abs:(D)D
     282: ldc2_w        #261                // double 0.005d
     285: dcmpl
     286: ifle          293
     289: iconst_1
     290: goto          294
     293: iconst_0
     294: ifeq          237
     297: aload         16
     299: aload         19
     301: invokeinterface #265,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     306: aload         19
     308: invokeinterface #253,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     313: invokeinterface #187,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     318: pop
     319: goto          237
     322: aload         16
     324: nop
     325: aload         13
     327: swap
     328: astore        22
     330: astore        23
     332: new           #267                // class kotlin/Pair
     335: dup
     336: aload         23
     338: aload         22
     340: invokespecial #270                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     343: astore        10
     345: aload         9
     347: aload         10
     349: invokevirtual #273                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     352: aload         10
     354: invokevirtual #276                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     357: invokeinterface #187,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     362: pop
     363: goto          156
     366: aload         5
     368: nop
     369: astore_1
     370: nop
     371: iconst_0
     372: istore_2
     373: aload_1
     374: astore_3
     375: new           #163                // class java/util/LinkedHashMap
     378: dup
     379: invokespecial #164                // Method java/util/LinkedHashMap."<init>":()V
     382: checkcast     #166                // class java/util/Map
     385: astore        4
     387: iconst_0
     388: istore        5
     390: aload_3
     391: invokeinterface #247,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     396: invokeinterface #248,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     401: astore        6
     403: aload         6
     405: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     410: ifeq          483
     413: aload         6
     415: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     420: checkcast     #250                // class java/util/Map$Entry
     423: astore        7
     425: aload         7
     427: astore        8
     429: iconst_0
     430: istore        9
     432: aload         8
     434: invokeinterface #253,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     439: checkcast     #166                // class java/util/Map
     442: invokeinterface #280,  1          // InterfaceMethod java/util/Map.size:()I
     447: ifle          454
     450: iconst_1
     451: goto          455
     454: iconst_0
     455: ifeq          403
     458: aload         4
     460: aload         7
     462: invokeinterface #265,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     467: aload         7
     469: invokeinterface #253,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     474: invokeinterface #187,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     479: pop
     480: goto          403
     483: aload         4
     485: nop
     486: astore_1
     487: nop
     488: iconst_0
     489: istore_2
     490: aload_1
     491: invokeinterface #247,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     496: invokeinterface #248,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     501: astore_3
     502: aload_3
     503: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     508: ifeq          542
     511: aload_3
     512: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     517: checkcast     #250                // class java/util/Map$Entry
     520: astore        4
     522: aload         4
     524: astore        5
     526: iconst_0
     527: istore        6
     529: getstatic     #286                // Field java/lang/System.out:Ljava/io/PrintStream;
     532: aload         5
     534: invokevirtual #292                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     537: nop
     538: nop
     539: goto          502
     542: nop
     543: return

  public static final kotlin.text.Regex getAllCapsRegex();
    Code:
       0: getstatic     #228                // Field allCapsRegex:Lkotlin/text/Regex;
       3: areturn

  public static final double abs(double);
    Code:
       0: dload_0
       1: invokestatic  #309                // Method java/lang/Math.abs:(D)D
       4: dreturn

  static {};
    Code:
       0: new           #67                 // class kotlin/text/Regex
       3: dup
       4: ldc_w         #313                // String [0-9A-Z]+
       7: invokespecial #76                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      10: putstatic     #228                // Field allCapsRegex:Lkotlin/text/Regex;
      13: return
}