package com.adventofcode

import com.adventofcode.Forest.addTrees
import com.adventofcode.Forest.crosswalks

class Crosswalk(
  private val tree: Int,
  private val left: List<Int>,
  private val right: List<Int>,
  private val top: List<Int>,
  private val bottom: List<Int>
) {

  fun scenicScore(): Int {
    val leftScore = countVisibleTreesOn(left)
    val rightScore = countVisibleTreesOn(right)
    val topScore = countVisibleTreesOn(top)
    val bottomScore = countVisibleTreesOn(bottom)
    return leftScore * rightScore * topScore * bottomScore
  }

  private fun countVisibleTreesOn(side: List<Int>): Int {
    return when (val visibleTrees = side.takeWhile { it < tree }.size) {
      side.size -> visibleTrees
      else -> visibleTrees + 1
    }
  }
}

object Forest {

  private val forest = mutableListOf<List<Int>>()

  private val columns get() = forest.first().size

  private val rows get() = forest.size

  private fun tree(row: Int, column: Int): Int {
    return forest[row][column]
  }

  private fun column(n: Int): List<Int> {
    return (0 until rows).map { tree(it, n) }
  }

  private fun row(n: Int): List<Int> {
    return forest[n]
  }

  private fun crosswalk(row: Int, column: Int): Crosswalk {
    val me = tree(row, column)
    val leftAndRight = row(row)
    val left = leftAndRight.slice(0 until column).asReversed()
    val right = leftAndRight.slice(column + 1 until columns)
    val topAndBottom = column(column)
    val top = topAndBottom.slice(0 until row).asReversed()
    val bottom = topAndBottom.slice(row + 1 until rows)
    return Crosswalk(me, left, right, top, bottom)
  }

  fun addTrees(encodedRow: String) {
    val row = encodedRow.map { it.toString().toInt() }
    forest.add(row)
  }

  fun crosswalks() = sequence {
    for (r in 0 until rows) {
      for (c in 0 until columns) {
        yield(crosswalk(r, c))
      }
    }
  }
}

fun solution(): Int {
  return crosswalks().maxOf(Crosswalk::scenicScore)
}

fun main() {
  ::main.javaClass
    .getResourceAsStream("/input")!!
    .bufferedReader()
    .forEachLine(::addTrees)
  println(solution())
}

Compiled from "Forest.kt"
public final class com.adventofcode.Forest {
  public static final com.adventofcode.Forest INSTANCE;

  private static final java.util.List<java.util.List<java.lang.Integer>> forest;

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

  private final int getColumns();
    Code:
       0: getstatic     #16                 // Field forest:Ljava/util/List;
       3: invokestatic  #22                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       6: checkcast     #24                 // class java/util/List
       9: invokeinterface #27,  1           // InterfaceMethod java/util/List.size:()I
      14: ireturn

  private final int getRows();
    Code:
       0: getstatic     #16                 // Field forest:Ljava/util/List;
       3: invokeinterface #27,  1           // InterfaceMethod java/util/List.size:()I
       8: ireturn

  private final int tree(int, int);
    Code:
       0: getstatic     #16                 // Field forest:Ljava/util/List;
       3: iload_1
       4: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       9: checkcast     #24                 // class java/util/List
      12: iload_2
      13: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      18: checkcast     #36                 // class java/lang/Number
      21: invokevirtual #39                 // Method java/lang/Number.intValue:()I
      24: ireturn

  private final java.util.List<java.lang.Integer> column(int);
    Code:
       0: iconst_0
       1: aload_0
       2: invokespecial #46                 // Method getRows:()I
       5: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
       8: checkcast     #54                 // class java/lang/Iterable
      11: astore_2
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: new           #56                 // class java/util/ArrayList
      20: dup
      21: aload_2
      22: bipush        10
      24: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #63                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #65                 // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #69,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #75,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          102
      57: aload         7
      59: checkcast     #77                 // class kotlin/collections/IntIterator
      62: invokevirtual #80                 // Method kotlin/collections/IntIterator.nextInt:()I
      65: istore        8
      67: aload         5
      69: iload         8
      71: istore        9
      73: astore        11
      75: iconst_0
      76: istore        10
      78: getstatic     #83                 // Field INSTANCE:Lcom/adventofcode/Forest;
      81: iload         9
      83: iload_1
      84: invokespecial #85                 // Method tree:(II)I
      87: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: aload         11
      92: swap
      93: invokeinterface #95,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      98: pop
      99: goto          47
     102: aload         5
     104: checkcast     #24                 // class java/util/List
     107: nop
     108: areturn

  private final java.util.List<java.lang.Integer> row(int);
    Code:
       0: getstatic     #16                 // Field forest:Ljava/util/List;
       3: iload_1
       4: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       9: checkcast     #24                 // class java/util/List
      12: areturn

  private final com.adventofcode.Crosswalk crosswalk(int, int);
    Code:
       0: aload_0
       1: iload_1
       2: iload_2
       3: invokespecial #85                 // Method tree:(II)I
       6: istore_3
       7: aload_0
       8: iload_1
       9: invokespecial #110                // Method row:(I)Ljava/util/List;
      12: astore        4
      14: aload         4
      16: iconst_0
      17: iload_2
      18: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      21: invokestatic  #114                // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
      24: invokestatic  #118                // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;
      27: astore        5
      29: aload         4
      31: iload_2
      32: iconst_1
      33: iadd
      34: aload_0
      35: invokespecial #120                // Method getColumns:()I
      38: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      41: invokestatic  #114                // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
      44: astore        6
      46: aload_0
      47: iload_2
      48: invokespecial #122                // Method column:(I)Ljava/util/List;
      51: astore        7
      53: aload         7
      55: iconst_0
      56: iload_1
      57: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      60: invokestatic  #114                // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
      63: invokestatic  #118                // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;
      66: astore        8
      68: aload         7
      70: iload_1
      71: iconst_1
      72: iadd
      73: aload_0
      74: invokespecial #46                 // Method getRows:()I
      77: invokestatic  #52                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      80: invokestatic  #114                // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
      83: astore        9
      85: new           #124                // class com/adventofcode/Crosswalk
      88: dup
      89: iload_3
      90: aload         5
      92: aload         6
      94: aload         8
      96: aload         9
      98: invokespecial #127                // Method com/adventofcode/Crosswalk."<init>":(ILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V
     101: areturn

  public final void addTrees(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #139                // String encodedRow
       3: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #147                // class java/lang/CharSequence
      10: astore_3
      11: iconst_0
      12: istore        4
      14: aload_3
      15: astore        5
      17: new           #56                 // class java/util/ArrayList
      20: dup
      21: aload_3
      22: invokeinterface #150,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      27: invokespecial #63                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #65                 // class java/util/Collection
      33: astore        6
      35: iconst_0
      36: istore        7
      38: iconst_0
      39: istore        8
      41: iload         8
      43: aload         5
      45: invokeinterface #150,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      50: if_icmpge     102
      53: aload         5
      55: iload         8
      57: invokeinterface #154,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      62: istore        9
      64: aload         6
      66: iload         9
      68: istore        10
      70: astore        12
      72: iconst_0
      73: istore        11
      75: iload         10
      77: invokestatic  #159                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      80: invokestatic  #163                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      83: nop
      84: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      87: aload         12
      89: swap
      90: invokeinterface #95,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      95: pop
      96: iinc          8, 1
      99: goto          41
     102: aload         6
     104: checkcast     #24                 // class java/util/List
     107: nop
     108: astore_2
     109: getstatic     #16                 // Field forest:Ljava/util/List;
     112: aload_2
     113: invokeinterface #164,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     118: pop
     119: return

  public final kotlin.sequences.Sequence<com.adventofcode.Crosswalk> crosswalks();
    Code:
       0: new           #173                // class com/adventofcode/Forest$crosswalks$1
       3: dup
       4: aconst_null
       5: invokespecial #176                // Method com/adventofcode/Forest$crosswalks$1."<init>":(Lkotlin/coroutines/Continuation;)V
       8: checkcast     #178                // class kotlin/jvm/functions/Function2
      11: invokestatic  #184                // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      14: areturn

  public static final int access$getRows(com.adventofcode.Forest);
    Code:
       0: aload_0
       1: invokespecial #46                 // Method getRows:()I
       4: ireturn

  public static final int access$getColumns(com.adventofcode.Forest);
    Code:
       0: aload_0
       1: invokespecial #120                // Method getColumns:()I
       4: ireturn

  public static final com.adventofcode.Crosswalk access$crosswalk(com.adventofcode.Forest, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: iload_2
       3: invokespecial #192                // Method crosswalk:(II)Lcom/adventofcode/Crosswalk;
       6: areturn

  static {};
    Code:
       0: new           #2                  // class com/adventofcode/Forest
       3: dup
       4: invokespecial #194                // Method "<init>":()V
       7: putstatic     #83                 // Field INSTANCE:Lcom/adventofcode/Forest;
      10: new           #56                 // class java/util/ArrayList
      13: dup
      14: invokespecial #195                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #24                 // class java/util/List
      20: putstatic     #16                 // Field forest:Ljava/util/List;
      23: return
}

Compiled from "Forest.kt"
final class com.adventofcode.Forest$crosswalks$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super com.adventofcode.Crosswalk>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int I$0;

  int I$1;

  int I$2;

  int I$3;

  int label;

  private java.lang.Object L$0;

  com.adventofcode.Forest$crosswalks$1(kotlin.coroutines.Continuation<? super com.adventofcode.Forest$crosswalks$1>);
    Code:
       0: aload_0
       1: iconst_2
       2: aload_1
       3: invokespecial #13                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
       6: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #45                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore        7
       5: aload_0
       6: getfield      #48                 // Field label:I
       9: tableswitch   { // 0 to 1
                     0: 32
                     1: 137
               default: 190
          }
      32: aload_1
      33: invokestatic  #54                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #57                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #59                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: iconst_0
      45: istore_3
      46: getstatic     #65                 // Field com/adventofcode/Forest.INSTANCE:Lcom/adventofcode/Forest;
      49: invokestatic  #69                 // Method com/adventofcode/Forest.access$getRows:(Lcom/adventofcode/Forest;)I
      52: istore        4
      54: iload_3
      55: iload         4
      57: if_icmpge     186
      60: iconst_0
      61: istore        5
      63: getstatic     #65                 // Field com/adventofcode/Forest.INSTANCE:Lcom/adventofcode/Forest;
      66: invokestatic  #72                 // Method com/adventofcode/Forest.access$getColumns:(Lcom/adventofcode/Forest;)I
      69: istore        6
      71: iload         5
      73: iload         6
      75: if_icmpge     180
      78: aload_2
      79: getstatic     #65                 // Field com/adventofcode/Forest.INSTANCE:Lcom/adventofcode/Forest;
      82: iload_3
      83: iload         5
      85: invokestatic  #76                 // Method com/adventofcode/Forest.access$crosswalk:(Lcom/adventofcode/Forest;II)Lcom/adventofcode/Crosswalk;
      88: aload_0
      89: checkcast     #78                 // class kotlin/coroutines/Continuation
      92: aload_0
      93: aload_2
      94: putfield      #57                 // Field L$0:Ljava/lang/Object;
      97: aload_0
      98: iload_3
      99: putfield      #80                 // Field I$0:I
     102: aload_0
     103: iload         4
     105: putfield      #82                 // Field I$1:I
     108: aload_0
     109: iload         5
     111: putfield      #84                 // Field I$2:I
     114: aload_0
     115: iload         6
     117: putfield      #86                 // Field I$3:I
     120: aload_0
     121: iconst_1
     122: putfield      #48                 // Field label:I
     125: invokevirtual #90                 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     128: dup
     129: aload         7
     131: if_acmpne     173
     134: aload         7
     136: areturn
     137: aload_0
     138: getfield      #86                 // Field I$3:I
     141: istore        6
     143: aload_0
     144: getfield      #84                 // Field I$2:I
     147: istore        5
     149: aload_0
     150: getfield      #82                 // Field I$1:I
     153: istore        4
     155: aload_0
     156: getfield      #80                 // Field I$0:I
     159: istore_3
     160: aload_0
     161: getfield      #57                 // Field L$0:Ljava/lang/Object;
     164: checkcast     #59                 // class kotlin/sequences/SequenceScope
     167: astore_2
     168: aload_1
     169: invokestatic  #54                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     172: aload_1
     173: pop
     174: iinc          5, 1
     177: goto          71
     180: iinc          3, 1
     183: goto          54
     186: getstatic     #95                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     189: areturn
     190: new           #97                 // class java/lang/IllegalStateException
     193: dup
     194: ldc           #99                 // String call to \'resume\' before \'invoke\' with coroutine
     196: invokespecial #102                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     199: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class com/adventofcode/Forest$crosswalks$1
       3: dup
       4: aload_2
       5: invokespecial #111                // Method "<init>":(Lkotlin/coroutines/Continuation;)V
       8: astore_3
       9: aload_3
      10: aload_1
      11: putfield      #57                 // Field L$0:Ljava/lang/Object;
      14: aload_3
      15: checkcast     #78                 // class kotlin/coroutines/Continuation
      18: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super com.adventofcode.Crosswalk>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #117                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class com/adventofcode/Forest$crosswalks$1
       9: getstatic     #95                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #119                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #59                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #78                 // class kotlin/coroutines/Continuation
       9: invokevirtual #124                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}

Compiled from "Forest.kt"
final class com.adventofcode.ForestKt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, kotlin.Unit> {
  com.adventofcode.ForestKt$main$2(java.lang.Object);
    Code:
       0: aload_0
       1: iconst_1
       2: aload_1
       3: ldc           #11                 // class com/adventofcode/Forest
       5: ldc           #13                 // String addTrees
       7: ldc           #15                 // String addTrees(Ljava/lang/String;)V
       9: iconst_0
      10: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final void invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #26                 // String p0
       3: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #34                 // Field receiver:Ljava/lang/Object;
      10: checkcast     #11                 // class com/adventofcode/Forest
      13: aload_1
      14: invokevirtual #36                 // Method com/adventofcode/Forest.addTrees:(Ljava/lang/String;)V
      17: return

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/String
       5: invokevirtual #42                 // Method invoke:(Ljava/lang/String;)V
       8: getstatic     #48                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      11: areturn
}

Compiled from "Forest.kt"
public final class com.adventofcode.ForestKt {
  public static final int solution();
    Code:
       0: getstatic     #12                 // Field com/adventofcode/Forest.INSTANCE:Lcom/adventofcode/Forest;
       3: invokevirtual #16                 // Method com/adventofcode/Forest.crosswalks:()Lkotlin/sequences/Sequence;
       6: invokeinterface #22,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      11: astore_0
      12: aload_0
      13: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      18: ifne          29
      21: new           #30                 // class java/util/NoSuchElementException
      24: dup
      25: invokespecial #34                 // Method java/util/NoSuchElementException."<init>":()V
      28: athrow
      29: aload_0
      30: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      35: checkcast     #40                 // class com/adventofcode/Crosswalk
      38: astore_1
      39: iconst_0
      40: istore_2
      41: aload_1
      42: invokevirtual #43                 // Method com/adventofcode/Crosswalk.scenicScore:()I
      45: istore_1
      46: aload_0
      47: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          82
      55: aload_0
      56: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: checkcast     #40                 // class com/adventofcode/Crosswalk
      64: astore_2
      65: iconst_0
      66: istore_3
      67: aload_2
      68: invokevirtual #43                 // Method com/adventofcode/Crosswalk.scenicScore:()I
      71: istore_2
      72: iload_1
      73: iload_2
      74: if_icmpge     46
      77: iload_2
      78: istore_1
      79: goto          46
      82: iload_1
      83: ireturn

  public static final void main();
    Code:
       0: getstatic     #53                 // Field com/adventofcode/ForestKt$main$1.INSTANCE:Lcom/adventofcode/ForestKt$main$1;
       3: invokevirtual #57                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
       6: ldc           #59                 // String /input
       8: invokevirtual #65                 // Method java/lang/Class.getResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      11: dup
      12: invokestatic  #71                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      15: astore_0
      16: getstatic     #77                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      19: astore_1
      20: new           #79                 // class java/io/InputStreamReader
      23: dup
      24: aload_0
      25: aload_1
      26: invokespecial #82                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      29: checkcast     #84                 // class java/io/Reader
      32: astore_2
      33: sipush        8192
      36: istore_3
      37: aload_2
      38: instanceof    #86                 // class java/io/BufferedReader
      41: ifeq          51
      44: aload_2
      45: checkcast     #86                 // class java/io/BufferedReader
      48: goto          60
      51: new           #86                 // class java/io/BufferedReader
      54: dup
      55: aload_2
      56: iload_3
      57: invokespecial #89                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      60: checkcast     #84                 // class java/io/Reader
      63: new           #91                 // class com/adventofcode/ForestKt$main$2
      66: dup
      67: getstatic     #12                 // Field com/adventofcode/Forest.INSTANCE:Lcom/adventofcode/Forest;
      70: invokespecial #93                 // Method com/adventofcode/ForestKt$main$2."<init>":(Ljava/lang/Object;)V
      73: checkcast     #95                 // class kotlin/jvm/functions/Function1
      76: invokestatic  #101                // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V
      79: invokestatic  #103                // Method solution:()I
      82: istore_0
      83: getstatic     #109                // Field java/lang/System.out:Ljava/io/PrintStream;
      86: iload_0
      87: invokevirtual #115                // Method java/io/PrintStream.println:(I)V
      90: return

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

Compiled from "Forest.kt"
final class com.adventofcode.ForestKt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<kotlin.Unit> {
  public static final com.adventofcode.ForestKt$main$1 INSTANCE;

  com.adventofcode.ForestKt$main$1();
    Code:
       0: aload_0
       1: iconst_0
       2: ldc           #11                 // class com/adventofcode/ForestKt
       4: ldc           #13                 // String main
       6: ldc           #15                 // String main()V
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final void invoke();
    Code:
       0: invokestatic  #23                 // Method com/adventofcode/ForestKt.main:()V
       3: return

  public java.lang.Object invoke();
    Code:
       0: aload_0
       1: invokevirtual #26                 // Method invoke:()V
       4: getstatic     #32                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
       7: areturn

  static {};
    Code:
       0: new           #2                  // class com/adventofcode/ForestKt$main$1
       3: dup
       4: invokespecial #35                 // Method "<init>":()V
       7: putstatic     #37                 // Field INSTANCE:Lcom/adventofcode/ForestKt$main$1;
      10: return
}


package anatoldevelopers.by.functional

val <T> List<T>.head: T
    get() = when (this.isEmpty()) {
        true -> throw NoSuchElementException("List is empty.")
        false -> this[0]
    }

val <T> List<T>.tail: List<T>
    get() = drop(1)

val List<Int>.sum: Int
    get() = sum(this)

fun sum(xs: List<Int>): Int {

    tailrec fun sumInner(xs: List<Int>, acum: Int): Int = when (xs.size) {
        0 -> acum
        else -> sumInner(xs.tail, xs.head + acum)
    }

    return sumInner(xs, 0)
}

fun sum2(xs: List<Int>) = reduce(0, xs) { acum, current -> acum + current }

fun <T, R> List<T>.map(f: (T) -> R): List<R> = when (this.size) {
    0 -> listOf()
    else -> f(head) + tail.map(f)
}

fun <T, R> List<T>.map2(f: (T) -> R): List<R> = reduce(listOf(), this)
{ xs, s -> xs + f(s) }

fun <T> List<T>.filter(f: (T) -> Boolean): List<T> = when (this.size) {
    0 -> listOf()
    else -> if (f(head)) head + tail.filter(f) else tail.filter(f)
}

fun <T> List<T>.filter2(f: (T) -> Boolean): List<T> = reduce(listOf(), this)
{ ys, s ->
    if (f(s))
        return@reduce ys + s
    else
        ys
}

fun <T, R> reduce(s: T, xs: List<R>, f: (T, R) -> T): T = when (xs.size) {
    0 -> s
    else -> reduce(f(s, xs.head), xs.tail, f)
}

operator fun <T> List<T>.plus(x: T): List<T> = ArrayList(this).also { it.add(x) }

operator fun <T> List<T>.plus(xs: List<T>): List<T> = when (xs.size) {
    0 -> ArrayList(this)
    else -> (this + xs.head) + xs.tail
}

operator fun <T> T.plus(xs: List<T>): List<T> = listOf(this) + xs

fun <T, R> zip(xs: List<T>, ys: List<R>): List<Pair<T, R>> = when (xs.isEmpty() || ys.isEmpty()) {
    true -> listOf()
    false -> Pair(xs.head, ys.head) + zip(xs.tail, ys.tail)
}

fun <T, R, C> zipWith(xs: List<T>, ys: List<R>, f: (T, R) -> C): List<C> =
        zip(xs, ys).map { f(it.first, it.second) }

fun maxSum(xs: List<Int>) = zipWith(xs, xs.tail) { a, b -> a + b }.max()

fun <T> reverse(xs: List<T>) = reduce(listOf<T>(), xs)
{ ys, s -> s + ys }

fun sumWithEvenIndexes(xs: List<Int>) =
        zip(xs, generateSequence(0) { it + 1 }.take(xs.size).toList())
                .filter { it.second % 2 == 0 }
                .map { it.first }
                .sum

fun <T> reduceSame(xs: List<T>) = reduce(listOf<T>(), xs) { list, elem -> list + elem }

Compiled from "Extensions.kt"
public final class anatoldevelopers.by.functional.ExtensionsKt {
  public static final <T> T getHead(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #22,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      12: istore_1
      13: iload_1
      14: iconst_1
      15: if_icmpne     28
      18: new           #24                 // class java/util/NoSuchElementException
      21: dup
      22: ldc           #26                 // String List is empty.
      24: invokespecial #30                 // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
      27: athrow
      28: iload_1
      29: ifne          42
      32: aload_0
      33: iconst_0
      34: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      39: goto          50
      42: new           #36                 // class kotlin/NoWhenBranchMatchedException
      45: dup
      46: invokespecial #39                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      49: athrow
      50: areturn

  public static final <T> java.util.List<T> getTail(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #46                 // class java/lang/Iterable
      10: iconst_1
      11: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      14: areturn

  public static final int getSum(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #59                 // Method sum:(Ljava/util/List;)I
      10: ireturn

  public static final int sum(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokestatic  #66                 // Method sum$sumInner:(Ljava/util/List;I)I
      11: ireturn

  public static final int sum2(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      10: aload_0
      11: invokedynamic #93,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
      16: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      19: checkcast     #99                 // class java/lang/Number
      22: invokevirtual #103                // Method java/lang/Number.intValue:()I
      25: ireturn

  public static final <T, R> java.util.List<R> map(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, ? extends R>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #108                // String f
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
      18: ifne          27
      21: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      24: goto          48
      27: aload_1
      28: aload_0
      29: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      32: invokeinterface #122,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      37: aload_0
      38: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      41: aload_1
      42: invokestatic  #126                // Method map:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      45: invokestatic  #130                // Method plus:(Ljava/lang/Object;Ljava/util/List;)Ljava/util/List;
      48: areturn

  public static final <T, R> java.util.List<R> map2(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, ? extends R>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #108                // String f
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      15: aload_0
      16: aload_1
      17: invokedynamic #143,  0            // InvokeDynamic #1:invoke:(Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function2;
      22: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      25: checkcast     #18                 // class java/util/List
      28: areturn

  public static final <T> java.util.List<T> filter(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #108                // String f
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
      18: ifne          27
      21: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      24: goto          72
      27: aload_1
      28: aload_0
      29: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      32: invokeinterface #122,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      37: checkcast     #148                // class java/lang/Boolean
      40: invokevirtual #151                // Method java/lang/Boolean.booleanValue:()Z
      43: ifeq          64
      46: aload_0
      47: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      50: aload_0
      51: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      54: aload_1
      55: invokestatic  #153                // Method filter:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      58: invokestatic  #130                // Method plus:(Ljava/lang/Object;Ljava/util/List;)Ljava/util/List;
      61: goto          72
      64: aload_0
      65: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      68: aload_1
      69: invokestatic  #153                // Method filter:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      72: areturn

  public static final <T> java.util.List<T> filter2(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #108                // String f
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      15: aload_0
      16: aload_1
      17: invokedynamic #160,  0            // InvokeDynamic #2:invoke:(Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function2;
      22: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      25: checkcast     #18                 // class java/util/List
      28: areturn

  public static final <T, R> T reduce(T, java.util.List<? extends R>, kotlin.jvm.functions.Function2<? super T, ? super R, ? extends T>);
    Code:
       0: aload_1
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #108                // String f
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
      18: ifne          25
      21: aload_0
      22: goto          44
      25: aload_2
      26: aload_0
      27: aload_1
      28: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      31: invokeinterface #166,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      36: aload_1
      37: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      40: aload_2
      41: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      44: areturn

  public static final <T> java.util.List<T> plus(java.util.List<? extends T>, T);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #172                // class java/util/ArrayList
       9: dup
      10: aload_0
      11: checkcast     #174                // class java/util/Collection
      14: invokespecial #177                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
      17: astore_2
      18: aload_2
      19: astore_3
      20: iconst_0
      21: istore        4
      23: aload_3
      24: aload_1
      25: invokevirtual #181                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      28: pop
      29: aload_2
      30: checkcast     #18                 // class java/util/List
      33: areturn

  public static final <T> java.util.List<T> plus(java.util.List<? extends T>, java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #62                 // String xs
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
      18: ifne          38
      21: new           #172                // class java/util/ArrayList
      24: dup
      25: aload_0
      26: checkcast     #174                // class java/util/Collection
      29: invokespecial #177                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
      32: checkcast     #18                 // class java/util/List
      35: goto          53
      38: aload_0
      39: aload_1
      40: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      43: invokestatic  #191                // Method plus:(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
      46: aload_1
      47: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      50: invokestatic  #193                // Method plus:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      53: areturn

  public static final <T> java.util.List<T> plus(T, java.util.List<? extends T>);
    Code:
       0: aload_1
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #198                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      10: aload_1
      11: invokestatic  #193                // Method plus:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      14: areturn

  public static final <T, R> java.util.List<kotlin.Pair<T, R>> zip(java.util.List<? extends T>, java.util.List<? extends R>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #202                // String ys
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokeinterface #22,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      18: ifne          30
      21: aload_1
      22: invokeinterface #22,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      27: ifeq          34
      30: iconst_1
      31: goto          35
      34: iconst_0
      35: istore_2
      36: iload_2
      37: iconst_1
      38: if_icmpne     47
      41: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      44: goto          91
      47: iload_2
      48: ifne          83
      51: new           #204                // class kotlin/Pair
      54: dup
      55: aload_0
      56: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      59: aload_1
      60: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      63: invokespecial #207                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      66: aload_0
      67: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      70: aload_1
      71: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      74: invokestatic  #209                // Method zip:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      77: invokestatic  #130                // Method plus:(Ljava/lang/Object;Ljava/util/List;)Ljava/util/List;
      80: goto          91
      83: new           #36                 // class kotlin/NoWhenBranchMatchedException
      86: dup
      87: invokespecial #39                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      90: athrow
      91: areturn

  public static final <T, R, C> java.util.List<C> zipWith(java.util.List<? extends T>, java.util.List<? extends R>, kotlin.jvm.functions.Function2<? super T, ? super R, ? extends C>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #202                // String ys
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #108                // String f
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: aload_1
      20: invokestatic  #209                // Method zip:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      23: aload_2
      24: invokedynamic #223,  0            // InvokeDynamic #3:invoke:(Lkotlin/jvm/functions/Function2;)Lkotlin/jvm/functions/Function1;
      29: invokestatic  #126                // Method map:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      32: areturn

  public static final int maxSum(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_0
       8: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      11: invokedynamic #229,  0            // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function2;
      16: invokestatic  #231                // Method zipWith:(Ljava/util/List;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
      19: checkcast     #46                 // class java/lang/Iterable
      22: invokestatic  #235                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      25: checkcast     #99                 // class java/lang/Number
      28: invokevirtual #103                // Method java/lang/Number.intValue:()I
      31: ireturn

  public static final <T> java.util.List<T> reverse(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
       9: aload_0
      10: invokedynamic #241,  0            // InvokeDynamic #5:invoke:()Lkotlin/jvm/functions/Function2;
      15: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      18: checkcast     #18                 // class java/util/List
      21: areturn

  public static final int sumWithEvenIndexes(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      11: invokedynamic #251,  0            // InvokeDynamic #6:invoke:()Lkotlin/jvm/functions/Function1;
      16: invokestatic  #257                // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      19: aload_0
      20: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
      25: invokestatic  #261                // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      28: invokestatic  #265                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      31: invokestatic  #209                // Method zip:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      34: invokedynamic #273,  0            // InvokeDynamic #7:invoke:()Lkotlin/jvm/functions/Function1;
      39: invokestatic  #153                // Method filter:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      42: invokedynamic #281,  0            // InvokeDynamic #8:invoke:()Lkotlin/jvm/functions/Function1;
      47: invokestatic  #126                // Method map:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      50: invokestatic  #283                // Method getSum:(Ljava/util/List;)I
      53: ireturn

  public static final <T> java.util.List<T> reduceSame(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #115                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
       9: aload_0
      10: invokedynamic #289,  0            // InvokeDynamic #9:invoke:()Lkotlin/jvm/functions/Function2;
      15: invokestatic  #97                 // Method reduce:(Ljava/lang/Object;Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
      18: checkcast     #18                 // class java/util/List
      21: areturn

  private static final int sum$sumInner(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: invokeinterface #111,  1          // InterfaceMethod java/util/List.size:()I
       6: ifne          13
       9: iload_1
      10: goto          38
      13: aload_0
      14: invokestatic  #124                // Method getTail:(Ljava/util/List;)Ljava/util/List;
      17: astore_2
      18: aload_0
      19: invokestatic  #117                // Method getHead:(Ljava/util/List;)Ljava/lang/Object;
      22: checkcast     #99                 // class java/lang/Number
      25: invokevirtual #103                // Method java/lang/Number.intValue:()I
      28: iload_1
      29: iadd
      30: istore_3
      31: aload_2
      32: astore_0
      33: iload_3
      34: istore_1
      35: goto          0
      38: ireturn

  private static final int sum2$lambda$0(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: iadd
       3: ireturn

  private static final java.util.List map2$lambda$1(kotlin.jvm.functions.Function1, java.util.List, java.lang.Object);
    Code:
       0: aload_1
       1: ldc           #62                 // String xs
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: aload_0
       8: aload_2
       9: invokeinterface #122,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      14: invokestatic  #191                // Method plus:(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
      17: areturn

  private static final java.util.List filter2$lambda$2(kotlin.jvm.functions.Function1, java.util.List, java.lang.Object);
    Code:
       0: aload_1
       1: ldc           #202                // String ys
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_2
       8: invokeinterface #122,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      13: checkcast     #148                // class java/lang/Boolean
      16: invokevirtual #151                // Method java/lang/Boolean.booleanValue:()Z
      19: ifeq          28
      22: aload_1
      23: aload_2
      24: invokestatic  #191                // Method plus:(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
      27: areturn
      28: aload_1
      29: areturn

  private static final java.lang.Object zipWith$lambda$4(kotlin.jvm.functions.Function2, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_1
       9: invokevirtual #298                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      12: aload_1
      13: invokevirtual #301                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      16: invokeinterface #166,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      21: areturn

  private static final int maxSum$lambda$5(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: iadd
       3: ireturn

  private static final java.util.List reverse$lambda$6(java.util.List, java.lang.Object);
    Code:
       0: aload_0
       1: ldc           #202                // String ys
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: aload_0
       8: invokestatic  #130                // Method plus:(Ljava/lang/Object;Ljava/util/List;)Ljava/util/List;
      11: areturn

  private static final java.lang.Integer sumWithEvenIndexes$lambda$7(int);
    Code:
       0: iload_0
       1: iconst_1
       2: iadd
       3: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       6: areturn

  private static final boolean sumWithEvenIndexes$lambda$8(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #301                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      11: checkcast     #99                 // class java/lang/Number
      14: invokevirtual #103                // Method java/lang/Number.intValue:()I
      17: iconst_2
      18: irem
      19: ifne          26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ireturn

  private static final int sumWithEvenIndexes$lambda$9(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #298                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      11: checkcast     #99                 // class java/lang/Number
      14: invokevirtual #103                // Method java/lang/Number.intValue:()I
      17: ireturn

  private static final java.util.List reduceSame$lambda$10(java.util.List, java.lang.Object);
    Code:
       0: aload_0
       1: ldc_w         #306                // String list
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_1
       9: invokestatic  #191                // Method plus:(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
      12: areturn
}


package org.jetbrains.research.ml.ast.util

import java.io.File

enum class Extension(val value: String) {
    Py(".py"), Xml(".xml")
}

enum class Type {
    Input, Output
}

class TestFileFormat(private val prefix: String, private val extension: Extension, val type: Type) {
    data class TestFile(val file: File, val type: Type, val number: Number)

    fun check(file: File): TestFile? {
        val number = "(?<=${prefix}_)\\d+(?=(_.*)?${extension.value})".toRegex().find(file.name)?.value?.toInt()
        return number?.let { TestFile(file, type, number) }
    }

    fun match(testFile: TestFile): Boolean {
        return testFile.type == type
    }
}

object FileTestUtil {

    val File.content: String
        get() = this.readText().removeSuffix("\n")

    /**
     * We assume the format of the test files will be:
     *
     * inPrefix_i_anySuffix.inExtension
     * outPrefix_i_anySuffix.outExtension,
     *
     * where:
     * inPrefix and outPrefix are set in [inFormat] and [outFormat] together with extensions,
     * i is a number; two corresponding input and output files should have the same number,
     * suffixes can by any symbols not necessary the same for the corresponding files.
     */
    fun getInAndOutFilesMap(
        folder: String,
        inFormat: TestFileFormat = TestFileFormat("in", Extension.Py, Type.Input),
        outFormat: TestFileFormat? = null
    ): Map<File, File?> {
        val (files, folders) = File(folder).listFiles().orEmpty().partition { it.isFile }

        // Process files in the given folder
        val inAndOutFilesGrouped = files.mapNotNull { inFormat.check(it) ?: outFormat?.check(it) }.groupBy { it.number }
        val inAndOutFilesMap = inAndOutFilesGrouped.map { (number, fileInfoList) ->
            val (f1, f2) = if (outFormat == null) {
                require(fileInfoList.size == 1) { "There are less or more than 1 test files with number $number" }
                Pair(fileInfoList.first(), null)
            } else {
                require(fileInfoList.size == 2) { "There are less or more than 2 test files with number $number" }
                fileInfoList.sortedBy { it.type }.zipWithNext().first()
            }
            require(inFormat.match(f1)) { "The input file does not match the input format" }
            outFormat?.let {
                require(f2 != null && outFormat.match(f2)) { "The output file does not match the output format" }
            }
            f1.file to f2?.file
        }.sortedBy { it.first.name }.toMap()

        outFormat?.let {
            require(inAndOutFilesMap.values.mapNotNull { it }.size == inAndOutFilesMap.values.size) { "Output tests" }
        }

        // Process all other nested files
        return folders.sortedBy { it.name }.map { getInAndOutFilesMap(it.absolutePath, inFormat, outFormat) }
            .fold(inAndOutFilesMap, { a, e -> a.plus(e) })
    }
}

Compiled from "Comparisons.kt"
public final class org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$lambda$9$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$lambda$9$$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 org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile.getType:()Lorg/jetbrains/research/ml/ast/util/Type;
      12: checkcast     #29                 // class java/lang/Comparable
      15: aload_2
      16: checkcast     #23                 // class org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile
      19: astore_3
      20: astore        5
      22: iconst_0
      23: istore        4
      25: aload_3
      26: invokevirtual #27                 // Method org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile.getType:()Lorg/jetbrains/research/ml/ast/util/Type;
      29: aload         5
      31: swap
      32: checkcast     #29                 // class java/lang/Comparable
      35: invokestatic  #35                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      38: ireturn
}

Compiled from "Comparisons.kt"
public final class org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$$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/Pair
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/io/File
      15: invokevirtual #33                 // Method java/io/File.getName:()Ljava/lang/String;
      18: checkcast     #35                 // class java/lang/Comparable
      21: aload_2
      22: checkcast     #23                 // class kotlin/Pair
      25: astore_3
      26: astore        5
      28: iconst_0
      29: istore        4
      31: aload_3
      32: invokevirtual #27                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      35: checkcast     #29                 // class java/io/File
      38: invokevirtual #33                 // Method java/io/File.getName:()Ljava/lang/String;
      41: aload         5
      43: swap
      44: checkcast     #35                 // class java/lang/Comparable
      47: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      50: ireturn
}

Compiled from "Comparisons.kt"
public final class org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$2<T> implements java.util.Comparator {
  public org.jetbrains.research.ml.ast.util.FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$2();
    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 java/io/File
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method java/io/File.getName:()Ljava/lang/String;
      12: checkcast     #29                 // class java/lang/Comparable
      15: aload_2
      16: checkcast     #23                 // class java/io/File
      19: astore_3
      20: astore        5
      22: iconst_0
      23: istore        4
      25: aload_3
      26: invokevirtual #27                 // Method java/io/File.getName:()Ljava/lang/String;
      29: aload         5
      31: swap
      32: checkcast     #29                 // class java/lang/Comparable
      35: invokestatic  #35                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      38: ireturn
}

Compiled from "FileTestUtil.kt"
public final class org.jetbrains.research.ml.ast.util.FileTestUtil {
  public static final org.jetbrains.research.ml.ast.util.FileTestUtil INSTANCE;

  private org.jetbrains.research.ml.ast.util.FileTestUtil();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.lang.String getContent(java.io.File);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: aconst_null
       8: iconst_1
       9: aconst_null
      10: invokestatic  #27                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      13: ldc           #29                 // String \n
      15: checkcast     #31                 // class java/lang/CharSequence
      18: invokestatic  #37                 // Method kotlin/text/StringsKt.removeSuffix:(Ljava/lang/String;Ljava/lang/CharSequence;)Ljava/lang/String;
      21: areturn

  public final java.util.Map<java.io.File, java.io.File> getInAndOutFilesMap(java.lang.String, org.jetbrains.research.ml.ast.util.TestFileFormat, org.jetbrains.research.ml.ast.util.TestFileFormat);
    Code:
       0: aload_1
       1: ldc           #45                 // String folder
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #47                 // String inFormat
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #49                 // class java/io/File
      15: dup
      16: aload_1
      17: invokespecial #52                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      20: invokevirtual #56                 // Method java/io/File.listFiles:()[Ljava/io/File;
      23: astore        5
      25: iconst_0
      26: istore        6
      28: aload         5
      30: dup
      31: ifnonnull     39
      34: pop
      35: iconst_0
      36: anewarray     #49                 // class java/io/File
      39: astore        5
      41: nop
      42: iconst_0
      43: istore        6
      45: new           #58                 // class java/util/ArrayList
      48: dup
      49: invokespecial #59                 // Method java/util/ArrayList."<init>":()V
      52: astore        7
      54: new           #58                 // class java/util/ArrayList
      57: dup
      58: invokespecial #59                 // Method java/util/ArrayList."<init>":()V
      61: astore        8
      63: iconst_0
      64: istore        9
      66: aload         5
      68: arraylength
      69: istore        10
      71: iload         9
      73: iload         10
      75: if_icmpge     124
      78: aload         5
      80: iload         9
      82: aaload
      83: astore        11
      85: aload         11
      87: astore        12
      89: iconst_0
      90: istore        13
      92: aload         12
      94: invokevirtual #63                 // Method java/io/File.isFile:()Z
      97: ifeq          110
     100: aload         7
     102: aload         11
     104: invokevirtual #67                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     107: goto          117
     110: aload         8
     112: aload         11
     114: invokevirtual #67                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     117: pop
     118: iinc          9, 1
     121: goto          71
     124: new           #69                 // class kotlin/Pair
     127: dup
     128: aload         7
     130: aload         8
     132: invokespecial #72                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     135: astore        4
     137: aload         4
     139: invokevirtual #76                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     142: checkcast     #78                 // class java/util/List
     145: astore        5
     147: aload         4
     149: invokevirtual #81                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     152: checkcast     #78                 // class java/util/List
     155: astore        6
     157: aload         5
     159: checkcast     #83                 // class java/lang/Iterable
     162: astore        8
     164: iconst_0
     165: istore        9
     167: aload         8
     169: astore        10
     171: new           #58                 // class java/util/ArrayList
     174: dup
     175: invokespecial #59                 // Method java/util/ArrayList."<init>":()V
     178: checkcast     #85                 // class java/util/Collection
     181: astore        11
     183: iconst_0
     184: istore        12
     186: aload         10
     188: astore        13
     190: iconst_0
     191: istore        14
     193: aload         13
     195: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     200: astore        15
     202: aload         15
     204: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     209: ifeq          296
     212: aload         15
     214: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     219: astore        16
     221: aload         16
     223: astore        17
     225: iconst_0
     226: istore        18
     228: aload         17
     230: checkcast     #49                 // class java/io/File
     233: astore        19
     235: iconst_0
     236: istore        20
     238: aload_2
     239: aload         19
     241: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     244: aload         19
     246: invokevirtual #107                // Method org/jetbrains/research/ml/ast/util/TestFileFormat.check:(Ljava/io/File;)Lorg/jetbrains/research/ml/ast/util/TestFileFormat$TestFile;
     249: dup
     250: ifnonnull     269
     253: pop
     254: aload_3
     255: dup
     256: ifnull        267
     259: aload         19
     261: invokevirtual #107                // Method org/jetbrains/research/ml/ast/util/TestFileFormat.check:(Ljava/io/File;)Lorg/jetbrains/research/ml/ast/util/TestFileFormat$TestFile;
     264: goto          269
     267: pop
     268: aconst_null
     269: dup
     270: ifnull        291
     273: astore        21
     275: iconst_0
     276: istore        22
     278: aload         11
     280: aload         21
     282: invokeinterface #108,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     287: pop
     288: goto          292
     291: pop
     292: nop
     293: goto          202
     296: nop
     297: aload         11
     299: checkcast     #78                 // class java/util/List
     302: nop
     303: checkcast     #83                 // class java/lang/Iterable
     306: astore        8
     308: nop
     309: iconst_0
     310: istore        9
     312: aload         8
     314: astore        10
     316: new           #110                // class java/util/LinkedHashMap
     319: dup
     320: invokespecial #111                // Method java/util/LinkedHashMap."<init>":()V
     323: checkcast     #113                // class java/util/Map
     326: astore        11
     328: iconst_0
     329: istore        12
     331: aload         10
     333: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     338: astore        13
     340: aload         13
     342: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     347: ifeq          452
     350: aload         13
     352: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     357: astore        14
     359: aload         14
     361: checkcast     #115                // class org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile
     364: astore        15
     366: iconst_0
     367: istore        16
     369: aload         15
     371: invokevirtual #119                // Method org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile.getNumber:()Ljava/lang/Number;
     374: astore        17
     376: aload         11
     378: astore        18
     380: iconst_0
     381: istore        19
     383: aload         18
     385: aload         17
     387: invokeinterface #123,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     392: astore        20
     394: aload         20
     396: ifnonnull     431
     399: iconst_0
     400: istore        21
     402: new           #58                 // class java/util/ArrayList
     405: dup
     406: invokespecial #59                 // Method java/util/ArrayList."<init>":()V
     409: checkcast     #78                 // class java/util/List
     412: astore        21
     414: aload         18
     416: aload         17
     418: aload         21
     420: invokeinterface #127,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     425: pop
     426: aload         21
     428: goto          433
     431: aload         20
     433: nop
     434: checkcast     #78                 // class java/util/List
     437: astore        15
     439: aload         15
     441: aload         14
     443: invokeinterface #128,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     448: pop
     449: goto          340
     452: aload         11
     454: nop
     455: astore        7
     457: aload         7
     459: astore        9
     461: iconst_0
     462: istore        10
     464: aload         9
     466: astore        11
     468: new           #58                 // class java/util/ArrayList
     471: dup
     472: aload         9
     474: invokeinterface #132,  1          // InterfaceMethod java/util/Map.size:()I
     479: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
     482: checkcast     #85                 // class java/util/Collection
     485: astore        12
     487: iconst_0
     488: istore        13
     490: aload         11
     492: invokeinterface #139,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     497: invokeinterface #142,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     502: astore        14
     504: aload         14
     506: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     511: ifeq          875
     514: aload         14
     516: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     521: checkcast     #144                // class java/util/Map$Entry
     524: astore        15
     526: aload         12
     528: aload         15
     530: astore        16
     532: astore        27
     534: iconst_0
     535: istore        17
     537: aload         16
     539: invokeinterface #147,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     544: checkcast     #149                // class java/lang/Number
     547: astore        18
     549: aload         16
     551: invokeinterface #152,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     556: checkcast     #78                 // class java/util/List
     559: astore        19
     561: aload_3
     562: ifnonnull     638
     565: aload         19
     567: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     572: iconst_1
     573: if_icmpne     580
     576: iconst_1
     577: goto          581
     580: iconst_0
     581: ifne          622
     584: iconst_0
     585: istore        20
     587: new           #155                // class java/lang/StringBuilder
     590: dup
     591: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
     594: ldc           #158                // String There are less or more than 1 test files with number
     596: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     599: aload         18
     601: invokevirtual #165                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     604: invokevirtual #169                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     607: astore        20
     609: new           #171                // class java/lang/IllegalArgumentException
     612: dup
     613: aload         20
     615: invokevirtual #172                // Method java/lang/Object.toString:()Ljava/lang/String;
     618: invokespecial #173                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     621: athrow
     622: new           #69                 // class kotlin/Pair
     625: dup
     626: aload         19
     628: invokestatic  #179                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     631: aconst_null
     632: invokespecial #72                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     635: goto          732
     638: aload         19
     640: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     645: iconst_2
     646: if_icmpne     653
     649: iconst_1
     650: goto          654
     653: iconst_0
     654: ifne          695
     657: iconst_0
     658: istore        20
     660: new           #155                // class java/lang/StringBuilder
     663: dup
     664: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
     667: ldc           #181                // String There are less or more than 2 test files with number
     669: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     672: aload         18
     674: invokevirtual #165                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     677: invokevirtual #169                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     680: astore        20
     682: new           #171                // class java/lang/IllegalArgumentException
     685: dup
     686: aload         20
     688: invokevirtual #172                // Method java/lang/Object.toString:()Ljava/lang/String;
     691: invokespecial #173                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     694: athrow
     695: aload         19
     697: checkcast     #83                 // class java/lang/Iterable
     700: astore        21
     702: iconst_0
     703: istore        20
     705: aload         21
     707: new           #183                // class org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$lambda$9$$inlined$sortedBy$1
     710: dup
     711: invokespecial #184                // Method org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$lambda$9$$inlined$sortedBy$1."<init>":()V
     714: checkcast     #186                // class java/util/Comparator
     717: invokestatic  #190                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     720: checkcast     #83                 // class java/lang/Iterable
     723: invokestatic  #194                // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
     726: invokestatic  #179                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     729: checkcast     #69                 // class kotlin/Pair
     732: astore        22
     734: aload         22
     736: invokevirtual #76                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     739: checkcast     #115                // class org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile
     742: astore        21
     744: aload         22
     746: invokevirtual #81                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     749: checkcast     #115                // class org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile
     752: astore        20
     754: aload_2
     755: aload         21
     757: invokevirtual #198                // Method org/jetbrains/research/ml/ast/util/TestFileFormat.match:(Lorg/jetbrains/research/ml/ast/util/TestFileFormat$TestFile;)Z
     760: ifne          783
     763: iconst_0
     764: istore        23
     766: ldc           #200                // String The input file does not match the input format
     768: astore        23
     770: new           #171                // class java/lang/IllegalArgumentException
     773: dup
     774: aload         23
     776: invokevirtual #172                // Method java/lang/Object.toString:()Ljava/lang/String;
     779: invokespecial #173                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     782: athrow
     783: aload_3
     784: dup
     785: ifnull        839
     788: astore        23
     790: iconst_0
     791: istore        24
     793: aload         20
     795: ifnull        811
     798: aload_3
     799: aload         20
     801: invokevirtual #198                // Method org/jetbrains/research/ml/ast/util/TestFileFormat.match:(Lorg/jetbrains/research/ml/ast/util/TestFileFormat$TestFile;)Z
     804: ifeq          811
     807: iconst_1
     808: goto          812
     811: iconst_0
     812: ifne          835
     815: iconst_0
     816: istore        25
     818: ldc           #202                // String The output file does not match the output format
     820: astore        25
     822: new           #171                // class java/lang/IllegalArgumentException
     825: dup
     826: aload         25
     828: invokevirtual #172                // Method java/lang/Object.toString:()Ljava/lang/String;
     831: invokespecial #173                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     834: athrow
     835: nop
     836: goto          841
     839: pop
     840: nop
     841: aload         21
     843: invokevirtual #206                // Method org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile.getFile:()Ljava/io/File;
     846: aload         20
     848: dup
     849: ifnull        858
     852: invokevirtual #206                // Method org/jetbrains/research/ml/ast/util/TestFileFormat$TestFile.getFile:()Ljava/io/File;
     855: goto          860
     858: pop
     859: aconst_null
     860: invokestatic  #212                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     863: aload         27
     865: swap
     866: invokeinterface #108,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     871: pop
     872: goto          504
     875: aload         12
     877: checkcast     #78                 // class java/util/List
     880: nop
     881: checkcast     #83                 // class java/lang/Iterable
     884: astore        9
     886: nop
     887: iconst_0
     888: istore        10
     890: aload         9
     892: new           #214                // class org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$1
     895: dup
     896: invokespecial #215                // Method org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$1."<init>":()V
     899: checkcast     #186                // class java/util/Comparator
     902: invokestatic  #190                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     905: checkcast     #83                 // class java/lang/Iterable
     908: invokestatic  #221                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     911: astore        8
     913: aload_3
     914: dup
     915: ifnull        1097
     918: astore        10
     920: iconst_0
     921: istore        11
     923: aload         8
     925: invokeinterface #225,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     930: checkcast     #83                 // class java/lang/Iterable
     933: astore        12
     935: iconst_0
     936: istore        13
     938: aload         12
     940: astore        14
     942: new           #58                 // class java/util/ArrayList
     945: dup
     946: invokespecial #59                 // Method java/util/ArrayList."<init>":()V
     949: checkcast     #85                 // class java/util/Collection
     952: astore        15
     954: iconst_0
     955: istore        16
     957: aload         14
     959: astore        17
     961: iconst_0
     962: istore        18
     964: aload         17
     966: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     971: astore        19
     973: aload         19
     975: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     980: ifeq          1038
     983: aload         19
     985: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     990: astore        20
     992: aload         20
     994: astore        21
     996: iconst_0
     997: istore        22
     999: aload         21
    1001: checkcast     #49                 // class java/io/File
    1004: astore        23
    1006: iconst_0
    1007: istore        24
    1009: aload         23
    1011: dup
    1012: ifnull        1033
    1015: astore        25
    1017: iconst_0
    1018: istore        26
    1020: aload         15
    1022: aload         25
    1024: invokeinterface #108,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1029: pop
    1030: goto          1034
    1033: pop
    1034: nop
    1035: goto          973
    1038: nop
    1039: aload         15
    1041: checkcast     #78                 // class java/util/List
    1044: nop
    1045: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
    1050: aload         8
    1052: invokeinterface #225,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
    1057: invokeinterface #226,  1          // InterfaceMethod java/util/Collection.size:()I
    1062: if_icmpne     1069
    1065: iconst_1
    1066: goto          1070
    1069: iconst_0
    1070: ifne          1093
    1073: iconst_0
    1074: istore        13
    1076: ldc           #228                // String Output tests
    1078: astore        13
    1080: new           #171                // class java/lang/IllegalArgumentException
    1083: dup
    1084: aload         13
    1086: invokevirtual #172                // Method java/lang/Object.toString:()Ljava/lang/String;
    1089: invokespecial #173                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
    1092: athrow
    1093: nop
    1094: goto          1099
    1097: pop
    1098: nop
    1099: aload         6
    1101: checkcast     #83                 // class java/lang/Iterable
    1104: astore        9
    1106: iconst_0
    1107: istore        10
    1109: aload         9
    1111: new           #230                // class org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$2
    1114: dup
    1115: invokespecial #231                // Method org/jetbrains/research/ml/ast/util/FileTestUtil$getInAndOutFilesMap$$inlined$sortedBy$2."<init>":()V
    1118: checkcast     #186                // class java/util/Comparator
    1121: invokestatic  #190                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
    1124: checkcast     #83                 // class java/lang/Iterable
    1127: astore        9
    1129: nop
    1130: iconst_0
    1131: istore        10
    1133: aload         9
    1135: astore        11
    1137: new           #58                 // class java/util/ArrayList
    1140: dup
    1141: aload         9
    1143: bipush        10
    1145: invokestatic  #235                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
    1148: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
    1151: checkcast     #85                 // class java/util/Collection
    1154: astore        12
    1156: iconst_0
    1157: istore        13
    1159: aload         11
    1161: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1166: astore        14
    1168: aload         14
    1170: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1175: ifeq          1232
    1178: aload         14
    1180: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1185: astore        15
    1187: aload         12
    1189: aload         15
    1191: checkcast     #49                 // class java/io/File
    1194: astore        16
    1196: astore        27
    1198: iconst_0
    1199: istore        17
    1201: getstatic     #238                // Field INSTANCE:Lorg/jetbrains/research/ml/ast/util/FileTestUtil;
    1204: aload         16
    1206: invokevirtual #241                // Method java/io/File.getAbsolutePath:()Ljava/lang/String;
    1209: dup
    1210: ldc           #243                // String getAbsolutePath(...)
    1212: invokestatic  #246                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
    1215: aload_2
    1216: aload_3
    1217: invokevirtual #248                // Method getInAndOutFilesMap:(Ljava/lang/String;Lorg/jetbrains/research/ml/ast/util/TestFileFormat;Lorg/jetbrains/research/ml/ast/util/TestFileFormat;)Ljava/util/Map;
    1220: aload         27
    1222: swap
    1223: invokeinterface #108,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1228: pop
    1229: goto          1168
    1232: aload         12
    1234: checkcast     #78                 // class java/util/List
    1237: nop
    1238: checkcast     #83                 // class java/lang/Iterable
    1241: astore        9
    1243: nop
    1244: iconst_0
    1245: istore        10
    1247: aload         8
    1249: astore        11
    1251: aload         9
    1253: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1258: astore        12
    1260: aload         12
    1262: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1267: ifeq          1305
    1270: aload         12
    1272: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1277: astore        13
    1279: aload         11
    1281: aload         13
    1283: checkcast     #113                // class java/util/Map
    1286: astore        14
    1288: astore        15
    1290: iconst_0
    1291: istore        16
    1293: aload         15
    1295: aload         14
    1297: invokestatic  #252                // Method kotlin/collections/MapsKt.plus:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
    1300: astore        11
    1302: goto          1260
    1305: aload         11
    1307: areturn

  public static java.util.Map getInAndOutFilesMap$default(org.jetbrains.research.ml.ast.util.FileTestUtil, java.lang.String, org.jetbrains.research.ml.ast.util.TestFileFormat, org.jetbrains.research.ml.ast.util.TestFileFormat, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          24
       7: new           #103                // class org/jetbrains/research/ml/ast/util/TestFileFormat
      10: dup
      11: ldc_w         #339                // String in
      14: getstatic     #345                // Field org/jetbrains/research/ml/ast/util/Extension.Py:Lorg/jetbrains/research/ml/ast/util/Extension;
      17: getstatic     #351                // Field org/jetbrains/research/ml/ast/util/Type.Input:Lorg/jetbrains/research/ml/ast/util/Type;
      20: invokespecial #354                // Method org/jetbrains/research/ml/ast/util/TestFileFormat."<init>":(Ljava/lang/String;Lorg/jetbrains/research/ml/ast/util/Extension;Lorg/jetbrains/research/ml/ast/util/Type;)V
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          33
      31: aconst_null
      32: astore_3
      33: aload_0
      34: aload_1
      35: aload_2
      36: aload_3
      37: invokevirtual #248                // Method getInAndOutFilesMap:(Ljava/lang/String;Lorg/jetbrains/research/ml/ast/util/TestFileFormat;Lorg/jetbrains/research/ml/ast/util/TestFileFormat;)Ljava/util/Map;
      40: areturn

  static {};
    Code:
       0: new           #2                  // class org/jetbrains/research/ml/ast/util/FileTestUtil
       3: dup
       4: invokespecial #356                // Method "<init>":()V
       7: putstatic     #238                // Field INSTANCE:Lorg/jetbrains/research/ml/ast/util/FileTestUtil;
      10: return
}