package day14

import java.nio.file.Files
import java.nio.file.Paths

fun main() {
  fun part1(input: Input): Int {
    fun iterate(template: String, rules: Map<String, String>) = buildString {
      append(template[0])
      for (i in 1 until template.length) {
        rules[template.substring(i - 1, i + 1)]?.let {
          append(it)
        }
        append(template[i])
      }
    }
    val rules = input.second.toMap()
    var template = input.first
    repeat(10) {
      template = iterate(template, rules)
    }
    return template
      .groupBy { it }
      .values
      .map { it.size }
      .let { it.maxOrNull()!! - it.minOrNull()!! }
  }

  fun part2(input: Input): Long {
    val rules = input.second.toMap()
    val mem = Array(41) {
      mutableMapOf<String, Map<Char, Long>>()
    }

    fun combine(
      lhs: Map<Char, Long>,
      rhs: Map<Char, Long>,
    ): Map<Char, Long> {
      val sum = (lhs.keys + rhs.keys).associateWith {
        lhs.getOrDefault(it, 0) + rhs.getOrDefault(it, 0)
      }
      return sum
    }

    fun rec(pair: String, depth: Int): Map<Char, Long> {
      mem[depth][pair]?.let { return it }
      if (depth == 0 || !rules.containsKey(pair)) {
        return mapOf(pair.first() to 1L).also { mem[depth][pair] = it }
      }
      val between = rules[pair]!!
      return combine(
        rec(pair[0] + between, depth - 1),
        rec(between + pair[1], depth - 1)
      ).also { mem[depth][pair] = it }
    }

    val origin = input.first + "$"
    var answer = emptyMap<Char, Long>()
    for (i in 0 until origin.lastIndex) {
      answer = combine(answer, rec(origin.substring(i, i + 2), 40))
    }
    return answer.values.let {
      it.maxOrNull()!! - it.minOrNull()!!
    }
  }

  check(part1(readInput("test-input.txt")) == 1588)
  check(part2(readInput("test-input.txt")) == 2188189693529L)

  println(part1(readInput("input.txt")))
  println(part2(readInput("input.txt")))
}

private fun readInput(s: String): Input {
  return Files.newBufferedReader(Paths.get("src/day14/$s")).readLines().let { lines ->
    val origin = lines.first()
    val rules = lines.drop(2).map {
      val (a, b) = it.split(" -> ")
      a to b
    }
    origin to rules
  }
}

private typealias Input = Pair<String, List<Pair<String, String>>>

Compiled from "Solution.kt"
public final class day14.SolutionKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String test-input.txt
       2: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
       5: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
       8: sipush        1588
      11: if_icmpne     18
      14: iconst_1
      15: goto          19
      18: iconst_0
      19: ifne          32
      22: new           #18                 // class java/lang/IllegalStateException
      25: dup
      26: ldc           #20                 // String Check failed.
      28: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      31: athrow
      32: ldc           #8                  // String test-input.txt
      34: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      37: invokestatic  #28                 // Method main$part2:(Lkotlin/Pair;)J
      40: ldc2_w        #29                 // long 2188189693529l
      43: lcmp
      44: ifne          51
      47: iconst_1
      48: goto          52
      51: iconst_0
      52: ifne          65
      55: new           #18                 // class java/lang/IllegalStateException
      58: dup
      59: ldc           #20                 // String Check failed.
      61: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      64: athrow
      65: ldc           #32                 // String input.txt
      67: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      70: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
      73: istore_0
      74: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: iload_0
      78: invokevirtual #44                 // Method java/io/PrintStream.println:(I)V
      81: ldc           #32                 // String input.txt
      83: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      86: invokestatic  #28                 // Method main$part2:(Lkotlin/Pair;)J
      89: lstore_0
      90: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      93: lload_0
      94: invokevirtual #47                 // Method java/io/PrintStream.println:(J)V
      97: return

  private static final kotlin.Pair<java.lang.String, java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>> readInput(java.lang.String);
    Code:
       0: new           #50                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #52                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #54                 // String src/day14/
       9: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: invokevirtual #62                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: iconst_0
      20: anewarray     #64                 // class java/lang/String
      23: invokestatic  #70                 // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      26: invokestatic  #76                 // Method java/nio/file/Files.newBufferedReader:(Ljava/nio/file/Path;)Ljava/io/BufferedReader;
      29: dup
      30: ldc           #78                 // String newBufferedReader(...)
      32: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      35: checkcast     #86                 // class java/io/Reader
      38: invokestatic  #92                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      41: astore_1
      42: iconst_0
      43: istore_2
      44: aload_1
      45: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      48: checkcast     #64                 // class java/lang/String
      51: astore_3
      52: aload_1
      53: checkcast     #100                // class java/lang/Iterable
      56: iconst_2
      57: invokestatic  #104                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      60: checkcast     #100                // class java/lang/Iterable
      63: astore        4
      65: iconst_0
      66: istore        5
      68: aload         4
      70: astore        6
      72: new           #106                // class java/util/ArrayList
      75: dup
      76: aload         4
      78: bipush        10
      80: invokestatic  #110                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      83: invokespecial #112                // Method java/util/ArrayList."<init>":(I)V
      86: checkcast     #114                // class java/util/Collection
      89: astore        7
      91: iconst_0
      92: istore        8
      94: aload         6
      96: invokeinterface #118,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     101: astore        9
     103: aload         9
     105: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     110: ifeq          210
     113: aload         9
     115: invokeinterface #128,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     120: astore        10
     122: aload         7
     124: aload         10
     126: checkcast     #64                 // class java/lang/String
     129: astore        11
     131: astore        12
     133: iconst_0
     134: istore        13
     136: aload         11
     138: checkcast     #130                // class java/lang/CharSequence
     141: iconst_1
     142: anewarray     #64                 // class java/lang/String
     145: astore        14
     147: aload         14
     149: iconst_0
     150: ldc           #132                // String  ->
     152: aastore
     153: aload         14
     155: iconst_0
     156: iconst_0
     157: bipush        6
     159: aconst_null
     160: invokestatic  #138                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     163: astore        15
     165: aload         15
     167: iconst_0
     168: invokeinterface #143,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     173: checkcast     #64                 // class java/lang/String
     176: astore        14
     178: aload         15
     180: iconst_1
     181: invokeinterface #143,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     186: checkcast     #64                 // class java/lang/String
     189: astore        16
     191: aload         14
     193: aload         16
     195: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     198: aload         12
     200: swap
     201: invokeinterface #153,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     206: pop
     207: goto          103
     210: aload         7
     212: checkcast     #140                // class java/util/List
     215: nop
     216: astore        17
     218: aload_3
     219: aload         17
     221: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     224: nop
     225: areturn

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

  private static final java.lang.String main$part1$iterate(java.lang.String, java.util.Map<java.lang.String, java.lang.String>);
    Code:
       0: new           #50                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #52                 // Method java/lang/StringBuilder."<init>":()V
       7: astore_2
       8: aload_2
       9: astore_3
      10: iconst_0
      11: istore        4
      13: aload_3
      14: aload_0
      15: iconst_0
      16: invokevirtual #186                // Method java/lang/String.charAt:(I)C
      19: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      22: pop
      23: iconst_1
      24: istore        5
      26: aload_0
      27: invokevirtual #193                // Method java/lang/String.length:()I
      30: istore        6
      32: iload         5
      34: iload         6
      36: if_icmpge     104
      39: aload_1
      40: aload_0
      41: iload         5
      43: iconst_1
      44: isub
      45: iload         5
      47: iconst_1
      48: iadd
      49: invokevirtual #197                // Method java/lang/String.substring:(II)Ljava/lang/String;
      52: dup
      53: ldc           #199                // String substring(...)
      55: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      58: invokeinterface #204,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      63: checkcast     #64                 // class java/lang/String
      66: dup
      67: ifnull        85
      70: astore        7
      72: iconst_0
      73: istore        8
      75: aload_3
      76: aload         7
      78: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      81: pop
      82: goto          87
      85: pop
      86: nop
      87: aload_3
      88: aload_0
      89: iload         5
      91: invokevirtual #186                // Method java/lang/String.charAt:(I)C
      94: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      97: pop
      98: iinc          5, 1
     101: goto          32
     104: nop
     105: aload_2
     106: invokevirtual #62                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     109: areturn

  private static final int main$part1(kotlin.Pair<java.lang.String, ? extends java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>>);
    Code:
       0: aload_0
       1: invokevirtual #217                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #100                // class java/lang/Iterable
       7: invokestatic  #223                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
      10: astore_1
      11: aconst_null
      12: astore_2
      13: aload_0
      14: invokevirtual #226                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: astore_2
      18: bipush        10
      20: istore_3
      21: iconst_0
      22: istore        4
      24: iload         4
      26: iload_3
      27: if_icmpge     53
      30: iload         4
      32: istore        5
      34: iconst_0
      35: istore        6
      37: aload_2
      38: checkcast     #64                 // class java/lang/String
      41: aload_1
      42: invokestatic  #228                // Method main$part1$iterate:(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/String;
      45: astore_2
      46: nop
      47: iinc          4, 1
      50: goto          24
      53: aload_2
      54: checkcast     #130                // class java/lang/CharSequence
      57: astore_3
      58: nop
      59: iconst_0
      60: istore        4
      62: aload_3
      63: astore        5
      65: new           #230                // class java/util/LinkedHashMap
      68: dup
      69: invokespecial #231                // Method java/util/LinkedHashMap."<init>":()V
      72: checkcast     #201                // class java/util/Map
      75: astore        6
      77: iconst_0
      78: istore        7
      80: iconst_0
      81: istore        8
      83: iload         8
      85: aload         5
      87: invokeinterface #232,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      92: if_icmpge     202
      95: aload         5
      97: iload         8
      99: invokeinterface #233,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     104: istore        9
     106: iload         9
     108: istore        10
     110: iconst_0
     111: istore        11
     113: iload         10
     115: invokestatic  #239                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     118: astore        12
     120: aload         6
     122: astore        13
     124: iconst_0
     125: istore        14
     127: aload         13
     129: aload         12
     131: invokeinterface #204,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     136: astore        15
     138: aload         15
     140: ifnonnull     175
     143: iconst_0
     144: istore        16
     146: new           #106                // class java/util/ArrayList
     149: dup
     150: invokespecial #240                // Method java/util/ArrayList."<init>":()V
     153: checkcast     #140                // class java/util/List
     156: astore        16
     158: aload         13
     160: aload         12
     162: aload         16
     164: invokeinterface #244,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     169: pop
     170: aload         16
     172: goto          177
     175: aload         15
     177: nop
     178: checkcast     #140                // class java/util/List
     181: astore        10
     183: aload         10
     185: iload         9
     187: invokestatic  #239                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     190: invokeinterface #245,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     195: pop
     196: iinc          8, 1
     199: goto          83
     202: aload         6
     204: nop
     205: invokeinterface #249,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     210: checkcast     #100                // class java/lang/Iterable
     213: astore_3
     214: nop
     215: iconst_0
     216: istore        4
     218: aload_3
     219: astore        5
     221: new           #106                // class java/util/ArrayList
     224: dup
     225: aload_3
     226: bipush        10
     228: invokestatic  #110                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     231: invokespecial #112                // Method java/util/ArrayList."<init>":(I)V
     234: checkcast     #114                // class java/util/Collection
     237: astore        6
     239: iconst_0
     240: istore        7
     242: aload         5
     244: invokeinterface #118,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     249: astore        8
     251: aload         8
     253: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     258: ifeq          306
     261: aload         8
     263: invokeinterface #128,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     268: astore        9
     270: aload         6
     272: aload         9
     274: checkcast     #140                // class java/util/List
     277: astore        10
     279: astore        17
     281: iconst_0
     282: istore        11
     284: aload         10
     286: invokeinterface #252,  1          // InterfaceMethod java/util/List.size:()I
     291: invokestatic  #257                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     294: aload         17
     296: swap
     297: invokeinterface #153,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     302: pop
     303: goto          251
     306: aload         6
     308: checkcast     #140                // class java/util/List
     311: nop
     312: astore        4
     314: iconst_0
     315: istore        5
     317: aload         4
     319: checkcast     #100                // class java/lang/Iterable
     322: invokestatic  #261                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     325: dup
     326: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     329: checkcast     #267                // class java/lang/Number
     332: invokevirtual #270                // Method java/lang/Number.intValue:()I
     335: aload         4
     337: checkcast     #100                // class java/lang/Iterable
     340: invokestatic  #273                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     343: dup
     344: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     347: checkcast     #267                // class java/lang/Number
     350: invokevirtual #270                // Method java/lang/Number.intValue:()I
     353: isub
     354: nop
     355: ireturn

  private static final java.util.Map<java.lang.Character, java.lang.Long> main$part2$combine(java.util.Map<java.lang.Character, java.lang.Long>, java.util.Map<java.lang.Character, java.lang.Long>);
    Code:
       0: aload_0
       1: invokeinterface #300,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
       6: aload_1
       7: invokeinterface #300,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
      12: checkcast     #100                // class java/lang/Iterable
      15: invokestatic  #306                // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;
      18: checkcast     #100                // class java/lang/Iterable
      21: astore_3
      22: iconst_0
      23: istore        4
      25: new           #230                // class java/util/LinkedHashMap
      28: dup
      29: aload_3
      30: bipush        10
      32: invokestatic  #110                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      35: invokestatic  #310                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      38: bipush        16
      40: invokestatic  #316                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
      43: invokespecial #317                // Method java/util/LinkedHashMap."<init>":(I)V
      46: astore        5
      48: aload_3
      49: astore        6
      51: iconst_0
      52: istore        7
      54: aload         6
      56: invokeinterface #118,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        8
      63: aload         8
      65: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          169
      73: aload         8
      75: invokeinterface #128,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        9
      82: aload         5
      84: checkcast     #201                // class java/util/Map
      87: aload         9
      89: aload         9
      91: checkcast     #235                // class java/lang/Character
      94: invokevirtual #321                // Method java/lang/Character.charValue:()C
      97: istore        10
      99: astore        13
     101: astore        12
     103: iconst_0
     104: istore        11
     106: aload_0
     107: iload         10
     109: invokestatic  #239                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     112: lconst_0
     113: invokestatic  #326                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     116: invokeinterface #329,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     121: checkcast     #267                // class java/lang/Number
     124: invokevirtual #333                // Method java/lang/Number.longValue:()J
     127: aload_1
     128: iload         10
     130: invokestatic  #239                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     133: lconst_0
     134: invokestatic  #326                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     137: invokeinterface #329,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     142: checkcast     #267                // class java/lang/Number
     145: invokevirtual #333                // Method java/lang/Number.longValue:()J
     148: ladd
     149: invokestatic  #326                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     152: astore        14
     154: aload         12
     156: aload         13
     158: aload         14
     160: invokeinterface #244,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     165: pop
     166: goto          63
     169: aload         5
     171: checkcast     #201                // class java/util/Map
     174: nop
     175: astore_2
     176: aload_2
     177: areturn

  private static final java.util.Map<java.lang.Character, java.lang.Long> main$part2$rec(java.util.Map<java.lang.String, java.util.Map<java.lang.Character, java.lang.Long>>[], java.util.Map<java.lang.String, java.lang.String>, java.lang.String, int);
    Code:
       0: aload_0
       1: iload_3
       2: aaload
       3: aload_2
       4: invokeinterface #204,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       9: checkcast     #201                // class java/util/Map
      12: astore        4
      14: aload         4
      16: ifnull        29
      19: aload         4
      21: astore        6
      23: iconst_0
      24: istore        7
      26: aload         6
      28: areturn
      29: iload_3
      30: ifeq          43
      33: aload_1
      34: aload_2
      35: invokeinterface #349,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      40: ifne          88
      43: aload_2
      44: checkcast     #130                // class java/lang/CharSequence
      47: invokestatic  #352                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
      50: invokestatic  #239                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      53: lconst_1
      54: invokestatic  #326                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      57: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      60: invokestatic  #356                // Method kotlin/collections/MapsKt.mapOf:(Lkotlin/Pair;)Ljava/util/Map;
      63: astore        4
      65: aload         4
      67: astore        5
      69: iconst_0
      70: istore        6
      72: aload_0
      73: iload_3
      74: aaload
      75: aload_2
      76: aload         5
      78: invokeinterface #244,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      83: pop
      84: nop
      85: aload         4
      87: areturn
      88: aload_1
      89: aload_2
      90: invokeinterface #204,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      95: dup
      96: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      99: checkcast     #64                 // class java/lang/String
     102: astore        4
     104: aload_0
     105: aload_1
     106: aload_2
     107: iconst_0
     108: invokevirtual #186                // Method java/lang/String.charAt:(I)C
     111: istore        5
     113: new           #50                 // class java/lang/StringBuilder
     116: dup
     117: invokespecial #52                 // Method java/lang/StringBuilder."<init>":()V
     120: iload         5
     122: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     125: aload         4
     127: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     130: invokevirtual #62                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     133: iload_3
     134: iconst_1
     135: isub
     136: invokestatic  #358                // Method main$part2$rec:([Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;I)Ljava/util/Map;
     139: aload_0
     140: aload_1
     141: new           #50                 // class java/lang/StringBuilder
     144: dup
     145: invokespecial #52                 // Method java/lang/StringBuilder."<init>":()V
     148: aload         4
     150: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     153: aload_2
     154: iconst_1
     155: invokevirtual #186                // Method java/lang/String.charAt:(I)C
     158: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     161: invokevirtual #62                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     164: iload_3
     165: iconst_1
     166: isub
     167: invokestatic  #358                // Method main$part2$rec:([Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;I)Ljava/util/Map;
     170: invokestatic  #360                // Method main$part2$combine:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
     173: astore        5
     175: aload         5
     177: astore        6
     179: iconst_0
     180: istore        7
     182: aload_0
     183: iload_3
     184: aaload
     185: aload_2
     186: aload         6
     188: invokeinterface #244,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     193: pop
     194: nop
     195: aload         5
     197: areturn

  private static final long main$part2(kotlin.Pair<java.lang.String, ? extends java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>>);
    Code:
       0: aload_0
       1: invokevirtual #217                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #100                // class java/lang/Iterable
       7: invokestatic  #223                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
      10: astore_1
      11: iconst_0
      12: istore_3
      13: bipush        41
      15: anewarray     #201                // class java/util/Map
      18: astore        4
      20: iload_3
      21: bipush        41
      23: if_icmpge     50
      26: iload_3
      27: istore        5
      29: aload         4
      31: iload         5
      33: new           #230                // class java/util/LinkedHashMap
      36: dup
      37: invokespecial #231                // Method java/util/LinkedHashMap."<init>":()V
      40: checkcast     #201                // class java/util/Map
      43: aastore
      44: iinc          3, 1
      47: goto          20
      50: aload         4
      52: astore_2
      53: new           #50                 // class java/lang/StringBuilder
      56: dup
      57: invokespecial #52                 // Method java/lang/StringBuilder."<init>":()V
      60: aload_0
      61: invokevirtual #226                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      64: checkcast     #64                 // class java/lang/String
      67: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      70: bipush        36
      72: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      75: invokevirtual #62                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      78: astore_3
      79: invokestatic  #373                // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;
      82: astore        4
      84: iconst_0
      85: istore        5
      87: aload_3
      88: checkcast     #130                // class java/lang/CharSequence
      91: invokestatic  #377                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      94: istore        6
      96: iload         5
      98: iload         6
     100: if_icmpge     139
     103: aload         4
     105: aload_2
     106: aload_1
     107: aload_3
     108: iload         5
     110: iload         5
     112: iconst_2
     113: iadd
     114: invokevirtual #197                // Method java/lang/String.substring:(II)Ljava/lang/String;
     117: dup
     118: ldc           #199                // String substring(...)
     120: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     123: bipush        40
     125: invokestatic  #358                // Method main$part2$rec:([Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;I)Ljava/util/Map;
     128: invokestatic  #360                // Method main$part2$combine:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
     131: astore        4
     133: iinc          5, 1
     136: goto          96
     139: aload         4
     141: invokeinterface #249,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     146: astore        6
     148: iconst_0
     149: istore        7
     151: aload         6
     153: checkcast     #100                // class java/lang/Iterable
     156: invokestatic  #261                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     159: dup
     160: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     163: checkcast     #267                // class java/lang/Number
     166: invokevirtual #333                // Method java/lang/Number.longValue:()J
     169: aload         6
     171: checkcast     #100                // class java/lang/Iterable
     174: invokestatic  #273                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     177: dup
     178: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     181: checkcast     #267                // class java/lang/Number
     184: invokevirtual #333                // Method java/lang/Number.longValue:()J
     187: lsub
     188: nop
     189: lreturn
}


package day13

import java.nio.file.Files
import java.nio.file.Paths

fun main() {
  fun log(field: Array<BooleanArray>) = buildString {
    for (y in field[0].indices) {
      for (x in field.indices) {
        append(if (field[x][y]) '#' else '.')
      }
      append('\n')
    }
  }.let { System.err.println(it) }

  fun fold(field: Array<BooleanArray>, fold: Pair<Boolean, Int>): Array<BooleanArray> =
    if (fold.first) {
      val foldX = fold.second
      check(field[foldX].none { it })
      val maxX = maxOf(foldX, field.size - 1 - foldX)
      Array(maxX) { xx ->
        BooleanArray(field[xx].size) { yy ->
          val x1 = foldX - (maxX - xx)
          val x2 = foldX + (maxX - xx)
          (x1 >= 0 && field[x1][yy]) || (x2 < field.size && field[x2][yy])
        }
      }
    } else {
      val foldY = fold.second
      val maxY = maxOf(foldY, field[0].size - foldY - 1)
      check(field.none { it[foldY] })
      Array(field.size) { xx ->
        BooleanArray(maxY) { yy ->
          val y1 = foldY - (maxY - yy)
          val y2 = foldY + (maxY - yy)
          (y1 >= 0 && field[xx][y1]) || (y2 < field[xx].size && field[xx][y2])
        }
      }
    }

  fun part1(input: Input): Int {
    val maxX = input.first.maxOf { it.first }
    val maxY = input.first.maxOf { it.second }
    val field = Array(maxX + 1) {
      BooleanArray(maxY + 1)
    }
    for ((x, y) in input.first) {
      field[x][y] = true
    }

    return fold(field, input.second.first()).sumOf { it.count { it } }
  }

  fun part2(input: Input): Int {
    val maxX = input.first.maxOf { it.first }
    val maxY = input.first.maxOf { it.second }
    var field = Array(maxX + 1) {
      BooleanArray(maxY + 1)
    }
    for ((x, y) in input.first) {
      field[x][y] = true
    }

    for (fold in input.second) {
      field = fold(field, fold)
    }
    log(field)
    return 42
  }

  check(part1(readInput("test-input.txt")) == 17)
  check(part2(readInput("test-input.txt")) == 42)

  println(part1(readInput("input.txt")))
  println(part2(readInput("input.txt")))
}

private fun readInput(s: String): Input {
  return Files.newBufferedReader(Paths.get("src/day13/$s")).readLines().let { lines ->
    val coordinates = lines
      .filter { !it.startsWith("fold along ") }
      .filter { it.isNotBlank() }
      .map {
        val (x, y) = it.split(",").map { it.toInt() }
        Pair(x, y)
      }
    val folds = lines
      .filter { it.startsWith("fold along ") }
      .map {
        val (axis, coordinate) = it.substring("fold along ".length).split("=")
        val axisRes = when(axis) {
          "x" -> true
          "y" -> false
          else -> error("unknown axis: $axis")
        }
        Pair(axisRes, coordinate.toInt())
      }
    Pair(coordinates, folds)
  }
}

private typealias Input = Pair<List<Pair<Int, Int>>, List<Pair<Boolean, Int>>>

Compiled from "Solution.kt"
public final class day13.SolutionKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String test-input.txt
       2: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
       5: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
       8: bipush        17
      10: if_icmpne     17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ifne          31
      21: new           #18                 // class java/lang/IllegalStateException
      24: dup
      25: ldc           #20                 // String Check failed.
      27: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      30: athrow
      31: ldc           #8                  // String test-input.txt
      33: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      36: invokestatic  #27                 // Method main$part2:(Lkotlin/Pair;)I
      39: bipush        42
      41: if_icmpne     48
      44: iconst_1
      45: goto          49
      48: iconst_0
      49: ifne          62
      52: new           #18                 // class java/lang/IllegalStateException
      55: dup
      56: ldc           #20                 // String Check failed.
      58: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      61: athrow
      62: ldc           #29                 // String input.txt
      64: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      67: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
      70: istore_0
      71: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_0
      75: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      78: ldc           #29                 // String input.txt
      80: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      83: invokestatic  #27                 // Method main$part2:(Lkotlin/Pair;)I
      86: istore_0
      87: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
      90: iload_0
      91: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      94: return

  private static final kotlin.Pair<java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, java.util.List<kotlin.Pair<java.lang.Boolean, java.lang.Integer>>> readInput(java.lang.String);
    Code:
       0: new           #44                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #48                 // String src/day13/
       9: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: invokevirtual #56                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: iconst_0
      20: anewarray     #58                 // class java/lang/String
      23: invokestatic  #64                 // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      26: invokestatic  #70                 // Method java/nio/file/Files.newBufferedReader:(Ljava/nio/file/Path;)Ljava/io/BufferedReader;
      29: dup
      30: ldc           #72                 // String newBufferedReader(...)
      32: invokestatic  #78                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      35: checkcast     #80                 // class java/io/Reader
      38: invokestatic  #86                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      41: astore_1
      42: iconst_0
      43: istore_2
      44: aload_1
      45: checkcast     #88                 // class java/lang/Iterable
      48: astore_3
      49: nop
      50: iconst_0
      51: istore        4
      53: aload_3
      54: astore        5
      56: new           #90                 // class java/util/ArrayList
      59: dup
      60: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
      63: checkcast     #93                 // class java/util/Collection
      66: astore        6
      68: iconst_0
      69: istore        7
      71: aload         5
      73: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      78: astore        8
      80: aload         8
      82: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          143
      90: aload         8
      92: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      97: astore        9
      99: aload         9
     101: checkcast     #58                 // class java/lang/String
     104: astore        10
     106: iconst_0
     107: istore        11
     109: aload         10
     111: ldc           #109                // String fold along
     113: iconst_0
     114: iconst_2
     115: aconst_null
     116: invokestatic  #115                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     119: ifne          126
     122: iconst_1
     123: goto          127
     126: iconst_0
     127: ifeq          80
     130: aload         6
     132: aload         9
     134: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     139: pop
     140: goto          80
     143: aload         6
     145: checkcast     #121                // class java/util/List
     148: nop
     149: checkcast     #88                 // class java/lang/Iterable
     152: astore_3
     153: nop
     154: iconst_0
     155: istore        4
     157: aload_3
     158: astore        5
     160: new           #90                 // class java/util/ArrayList
     163: dup
     164: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
     167: checkcast     #93                 // class java/util/Collection
     170: astore        6
     172: iconst_0
     173: istore        7
     175: aload         5
     177: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     182: astore        8
     184: aload         8
     186: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     191: ifeq          246
     194: aload         8
     196: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        9
     203: aload         9
     205: checkcast     #58                 // class java/lang/String
     208: astore        10
     210: iconst_0
     211: istore        11
     213: aload         10
     215: checkcast     #123                // class java/lang/CharSequence
     218: invokestatic  #127                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
     221: ifne          228
     224: iconst_1
     225: goto          229
     228: iconst_0
     229: nop
     230: ifeq          184
     233: aload         6
     235: aload         9
     237: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     242: pop
     243: goto          184
     246: aload         6
     248: checkcast     #121                // class java/util/List
     251: nop
     252: checkcast     #88                 // class java/lang/Iterable
     255: astore_3
     256: nop
     257: iconst_0
     258: istore        4
     260: aload_3
     261: astore        5
     263: new           #90                 // class java/util/ArrayList
     266: dup
     267: aload_3
     268: bipush        10
     270: invokestatic  #133                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     273: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
     276: checkcast     #93                 // class java/util/Collection
     279: astore        6
     281: iconst_0
     282: istore        7
     284: aload         5
     286: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     291: astore        8
     293: aload         8
     295: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     300: ifeq          519
     303: aload         8
     305: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     310: astore        9
     312: aload         6
     314: aload         9
     316: checkcast     #58                 // class java/lang/String
     319: astore        10
     321: astore        12
     323: iconst_0
     324: istore        11
     326: aload         10
     328: checkcast     #123                // class java/lang/CharSequence
     331: iconst_1
     332: anewarray     #58                 // class java/lang/String
     335: astore        13
     337: aload         13
     339: iconst_0
     340: ldc           #137                // String ,
     342: aastore
     343: aload         13
     345: iconst_0
     346: iconst_0
     347: bipush        6
     349: aconst_null
     350: invokestatic  #141                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     353: checkcast     #88                 // class java/lang/Iterable
     356: astore        13
     358: iconst_0
     359: istore        14
     361: aload         13
     363: astore        15
     365: new           #90                 // class java/util/ArrayList
     368: dup
     369: aload         13
     371: bipush        10
     373: invokestatic  #133                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     376: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
     379: checkcast     #93                 // class java/util/Collection
     382: astore        16
     384: iconst_0
     385: istore        17
     387: aload         15
     389: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     394: astore        18
     396: aload         18
     398: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     403: ifeq          450
     406: aload         18
     408: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     413: astore        19
     415: aload         16
     417: aload         19
     419: checkcast     #58                 // class java/lang/String
     422: astore        20
     424: astore        21
     426: iconst_0
     427: istore        22
     429: aload         20
     431: invokestatic  #147                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     434: nop
     435: invokestatic  #151                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     438: aload         21
     440: swap
     441: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     446: pop
     447: goto          396
     450: aload         16
     452: checkcast     #121                // class java/util/List
     455: nop
     456: astore        23
     458: aload         23
     460: iconst_0
     461: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     466: checkcast     #156                // class java/lang/Number
     469: invokevirtual #160                // Method java/lang/Number.intValue:()I
     472: istore        13
     474: aload         23
     476: iconst_1
     477: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     482: checkcast     #156                // class java/lang/Number
     485: invokevirtual #160                // Method java/lang/Number.intValue:()I
     488: istore        14
     490: new           #162                // class kotlin/Pair
     493: dup
     494: iload         13
     496: invokestatic  #151                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     499: iload         14
     501: invokestatic  #151                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     504: invokespecial #165                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     507: aload         12
     509: swap
     510: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     515: pop
     516: goto          293
     519: aload         6
     521: checkcast     #121                // class java/util/List
     524: nop
     525: astore        24
     527: aload_1
     528: checkcast     #88                 // class java/lang/Iterable
     531: astore        4
     533: nop
     534: iconst_0
     535: istore        5
     537: aload         4
     539: astore        6
     541: new           #90                 // class java/util/ArrayList
     544: dup
     545: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
     548: checkcast     #93                 // class java/util/Collection
     551: astore        7
     553: iconst_0
     554: istore        8
     556: aload         6
     558: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     563: astore        9
     565: aload         9
     567: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     572: ifeq          620
     575: aload         9
     577: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     582: astore        10
     584: aload         10
     586: checkcast     #58                 // class java/lang/String
     589: astore        11
     591: iconst_0
     592: istore        13
     594: aload         11
     596: ldc           #109                // String fold along
     598: iconst_0
     599: iconst_2
     600: aconst_null
     601: invokestatic  #115                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     604: ifeq          565
     607: aload         7
     609: aload         10
     611: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     616: pop
     617: goto          565
     620: aload         7
     622: checkcast     #121                // class java/util/List
     625: nop
     626: checkcast     #88                 // class java/lang/Iterable
     629: astore        4
     631: nop
     632: iconst_0
     633: istore        5
     635: aload         4
     637: astore        6
     639: new           #90                 // class java/util/ArrayList
     642: dup
     643: aload         4
     645: bipush        10
     647: invokestatic  #133                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     650: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
     653: checkcast     #93                 // class java/util/Collection
     656: astore        7
     658: iconst_0
     659: istore        8
     661: aload         6
     663: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     668: astore        9
     670: aload         9
     672: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     677: ifeq          866
     680: aload         9
     682: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     687: astore        10
     689: aload         7
     691: aload         10
     693: checkcast     #58                 // class java/lang/String
     696: astore        11
     698: astore        12
     700: iconst_0
     701: istore        13
     703: aload         11
     705: bipush        11
     707: invokevirtual #169                // Method java/lang/String.substring:(I)Ljava/lang/String;
     710: dup
     711: ldc           #171                // String substring(...)
     713: invokestatic  #78                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     716: checkcast     #123                // class java/lang/CharSequence
     719: iconst_1
     720: anewarray     #58                 // class java/lang/String
     723: astore        14
     725: aload         14
     727: iconst_0
     728: ldc           #173                // String =
     730: aastore
     731: aload         14
     733: iconst_0
     734: iconst_0
     735: bipush        6
     737: aconst_null
     738: invokestatic  #141                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     741: astore        15
     743: aload         15
     745: iconst_0
     746: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     751: checkcast     #58                 // class java/lang/String
     754: astore        14
     756: aload         15
     758: iconst_1
     759: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     764: checkcast     #58                 // class java/lang/String
     767: astore        16
     769: aload         14
     771: astore        17
     773: aload         17
     775: ldc           #175                // String x
     777: invokestatic  #179                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     780: ifeq          787
     783: iconst_1
     784: goto          832
     787: aload         17
     789: ldc           #181                // String y
     791: invokestatic  #179                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     794: ifeq          801
     797: iconst_0
     798: goto          832
     801: new           #18                 // class java/lang/IllegalStateException
     804: dup
     805: new           #44                 // class java/lang/StringBuilder
     808: dup
     809: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
     812: ldc           #183                // String unknown axis:
     814: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     817: aload         14
     819: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     822: invokevirtual #56                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     825: invokevirtual #184                // Method java/lang/Object.toString:()Ljava/lang/String;
     828: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     831: athrow
     832: istore        18
     834: new           #162                // class kotlin/Pair
     837: dup
     838: iload         18
     840: invokestatic  #189                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     843: aload         16
     845: invokestatic  #147                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     848: invokestatic  #151                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     851: invokespecial #165                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     854: aload         12
     856: swap
     857: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     862: pop
     863: goto          670
     866: aload         7
     868: checkcast     #121                // class java/util/List
     871: nop
     872: astore_3
     873: new           #162                // class kotlin/Pair
     876: dup
     877: aload         24
     879: aload_3
     880: invokespecial #165                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     883: nop
     884: areturn

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

  private static final void main$log(boolean[][]);
    Code:
       0: new           #44                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
       7: astore_1
       8: aload_1
       9: astore_2
      10: iconst_0
      11: istore_3
      12: iconst_0
      13: istore        4
      15: aload_0
      16: iconst_0
      17: aaload
      18: arraylength
      19: istore        5
      21: iload         4
      23: iload         5
      25: if_icmpge     86
      28: iconst_0
      29: istore        6
      31: aload_0
      32: checkcast     #231                // class "[Ljava/lang/Object;"
      35: arraylength
      36: istore        7
      38: iload         6
      40: iload         7
      42: if_icmpge     73
      45: aload_2
      46: aload_0
      47: iload         6
      49: aaload
      50: iload         4
      52: baload
      53: ifeq          61
      56: bipush        35
      58: goto          63
      61: bipush        46
      63: invokevirtual #234                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      66: pop
      67: iinc          6, 1
      70: goto          38
      73: aload_2
      74: bipush        10
      76: invokevirtual #234                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      79: pop
      80: iinc          4, 1
      83: goto          21
      86: nop
      87: aload_1
      88: invokevirtual #56                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      91: astore_2
      92: iconst_0
      93: istore_3
      94: getstatic     #237                // Field java/lang/System.err:Ljava/io/PrintStream;
      97: aload_2
      98: invokevirtual #239                // Method java/io/PrintStream.println:(Ljava/lang/String;)V
     101: nop
     102: return

  private static final boolean[][] main$fold(boolean[][], kotlin.Pair<java.lang.Boolean, java.lang.Integer>);
    Code:
       0: aload_1
       1: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #186                // class java/lang/Boolean
       7: invokevirtual #255                // Method java/lang/Boolean.booleanValue:()Z
      10: ifeq          240
      13: aload_1
      14: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      17: checkcast     #156                // class java/lang/Number
      20: invokevirtual #160                // Method java/lang/Number.intValue:()I
      23: istore_2
      24: aload_0
      25: iload_2
      26: aaload
      27: astore_3
      28: iconst_0
      29: istore        4
      31: iconst_0
      32: istore        5
      34: aload_3
      35: arraylength
      36: istore        6
      38: iload         5
      40: iload         6
      42: if_icmpge     73
      45: aload_3
      46: iload         5
      48: baload
      49: istore        7
      51: iload         7
      53: istore        8
      55: iconst_0
      56: istore        9
      58: iload         8
      60: ifeq          67
      63: iconst_0
      64: goto          74
      67: iinc          5, 1
      70: goto          38
      73: iconst_1
      74: ifne          87
      77: new           #18                 // class java/lang/IllegalStateException
      80: dup
      81: ldc           #20                 // String Check failed.
      83: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      86: athrow
      87: iload_2
      88: aload_0
      89: checkcast     #231                // class "[Ljava/lang/Object;"
      92: arraylength
      93: iconst_1
      94: isub
      95: iload_2
      96: isub
      97: invokestatic  #264                // Method java/lang/Math.max:(II)I
     100: istore_3
     101: iconst_0
     102: istore        4
     104: iload_3
     105: anewarray     #266                // class "[Z"
     108: astore        5
     110: iload         4
     112: iload_3
     113: if_icmpge     235
     116: iload         4
     118: istore        6
     120: aload         5
     122: iload         6
     124: iconst_0
     125: istore        7
     127: aload_0
     128: iload         6
     130: aaload
     131: arraylength
     132: istore        8
     134: iload         8
     136: newarray       boolean
     138: astore        9
     140: istore        14
     142: astore        13
     144: iload         7
     146: iload         8
     148: if_icmpge     222
     151: iload         7
     153: istore        10
     155: aload         9
     157: iload         10
     159: iload_2
     160: iload_3
     161: iload         6
     163: isub
     164: isub
     165: istore        11
     167: iload_2
     168: iload_3
     169: iload         6
     171: isub
     172: iadd
     173: istore        12
     175: iload         11
     177: iflt          190
     180: aload_0
     181: iload         11
     183: aaload
     184: iload         10
     186: baload
     187: ifne          210
     190: iload         12
     192: aload_0
     193: checkcast     #231                // class "[Ljava/lang/Object;"
     196: arraylength
     197: if_icmpge     214
     200: aload_0
     201: iload         12
     203: aaload
     204: iload         10
     206: baload
     207: ifeq          214
     210: iconst_1
     211: goto          215
     214: iconst_0
     215: bastore
     216: iinc          7, 1
     219: goto          144
     222: aload         13
     224: iload         14
     226: aload         9
     228: aastore
     229: iinc          4, 1
     232: goto          110
     235: aload         5
     237: goto          472
     240: aload_1
     241: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     244: checkcast     #156                // class java/lang/Number
     247: invokevirtual #160                // Method java/lang/Number.intValue:()I
     250: istore_2
     251: iload_2
     252: aload_0
     253: iconst_0
     254: aaload
     255: arraylength
     256: iload_2
     257: isub
     258: iconst_1
     259: isub
     260: invokestatic  #264                // Method java/lang/Math.max:(II)I
     263: istore_3
     264: aload_0
     265: checkcast     #231                // class "[Ljava/lang/Object;"
     268: astore        4
     270: iconst_0
     271: istore        5
     273: iconst_0
     274: istore        6
     276: aload         4
     278: arraylength
     279: istore        7
     281: iload         6
     283: iload         7
     285: if_icmpge     322
     288: aload         4
     290: iload         6
     292: aaload
     293: astore        8
     295: aload         8
     297: checkcast     #266                // class "[Z"
     300: astore        9
     302: iconst_0
     303: istore        10
     305: aload         9
     307: iload_2
     308: baload
     309: ifeq          316
     312: iconst_0
     313: goto          323
     316: iinc          6, 1
     319: goto          281
     322: iconst_1
     323: ifne          336
     326: new           #18                 // class java/lang/IllegalStateException
     329: dup
     330: ldc           #20                 // String Check failed.
     332: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     335: athrow
     336: iconst_0
     337: istore        4
     339: aload_0
     340: checkcast     #231                // class "[Ljava/lang/Object;"
     343: arraylength
     344: istore        5
     346: iload         5
     348: anewarray     #266                // class "[Z"
     351: astore        6
     353: iload         4
     355: iload         5
     357: if_icmpge     470
     360: iload         4
     362: istore        7
     364: aload         6
     366: iload         7
     368: iconst_0
     369: istore        8
     371: iload_3
     372: newarray       boolean
     374: astore        9
     376: istore        14
     378: astore        13
     380: iload         8
     382: iload_3
     383: if_icmpge     457
     386: iload         8
     388: istore        10
     390: aload         9
     392: iload         10
     394: iload_2
     395: iload_3
     396: iload         10
     398: isub
     399: isub
     400: istore        11
     402: iload_2
     403: iload_3
     404: iload         10
     406: isub
     407: iadd
     408: istore        12
     410: iload         11
     412: iflt          425
     415: aload_0
     416: iload         7
     418: aaload
     419: iload         11
     421: baload
     422: ifne          445
     425: iload         12
     427: aload_0
     428: iload         7
     430: aaload
     431: arraylength
     432: if_icmpge     449
     435: aload_0
     436: iload         7
     438: aaload
     439: iload         12
     441: baload
     442: ifeq          449
     445: iconst_1
     446: goto          450
     449: iconst_0
     450: bastore
     451: iinc          8, 1
     454: goto          380
     457: aload         13
     459: iload         14
     461: aload         9
     463: aastore
     464: iinc          4, 1
     467: goto          353
     470: aload         6
     472: areturn

  private static final int main$part1(kotlin.Pair<? extends java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, ? extends java.util.List<kotlin.Pair<java.lang.Boolean, java.lang.Integer>>>);
    Code:
       0: aload_0
       1: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #88                 // class java/lang/Iterable
       7: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      12: astore_3
      13: aload_3
      14: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      19: ifne          30
      22: new           #284                // class java/util/NoSuchElementException
      25: dup
      26: invokespecial #285                // Method java/util/NoSuchElementException."<init>":()V
      29: athrow
      30: aload_3
      31: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #162                // class kotlin/Pair
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      49: checkcast     #156                // class java/lang/Number
      52: invokevirtual #160                // Method java/lang/Number.intValue:()I
      55: istore        4
      57: aload_3
      58: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          107
      66: aload_3
      67: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: checkcast     #162                // class kotlin/Pair
      75: astore        5
      77: iconst_0
      78: istore        6
      80: aload         5
      82: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #156                // class java/lang/Number
      88: invokevirtual #160                // Method java/lang/Number.intValue:()I
      91: istore        5
      93: iload         4
      95: iload         5
      97: if_icmpge     57
     100: iload         5
     102: istore        4
     104: goto          57
     107: iload         4
     109: istore_1
     110: aload_0
     111: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     114: checkcast     #88                 // class java/lang/Iterable
     117: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     122: astore        4
     124: aload         4
     126: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     131: ifne          142
     134: new           #284                // class java/util/NoSuchElementException
     137: dup
     138: invokespecial #285                // Method java/util/NoSuchElementException."<init>":()V
     141: athrow
     142: aload         4
     144: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     149: checkcast     #162                // class kotlin/Pair
     152: astore        5
     154: iconst_0
     155: istore        6
     157: aload         5
     159: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     162: checkcast     #156                // class java/lang/Number
     165: invokevirtual #160                // Method java/lang/Number.intValue:()I
     168: istore        5
     170: aload         4
     172: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     177: ifeq          222
     180: aload         4
     182: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     187: checkcast     #162                // class kotlin/Pair
     190: astore        6
     192: iconst_0
     193: istore        7
     195: aload         6
     197: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     200: checkcast     #156                // class java/lang/Number
     203: invokevirtual #160                // Method java/lang/Number.intValue:()I
     206: istore        6
     208: iload         5
     210: iload         6
     212: if_icmpge     170
     215: iload         6
     217: istore        5
     219: goto          170
     222: iload         5
     224: istore_2
     225: iconst_0
     226: istore        4
     228: iload_1
     229: iconst_1
     230: iadd
     231: istore        5
     233: iload         5
     235: anewarray     #266                // class "[Z"
     238: astore        6
     240: iload         4
     242: iload         5
     244: if_icmpge     267
     247: iload         4
     249: istore        7
     251: aload         6
     253: iload         7
     255: iload_2
     256: iconst_1
     257: iadd
     258: newarray       boolean
     260: aastore
     261: iinc          4, 1
     264: goto          240
     267: aload         6
     269: astore_3
     270: aload_0
     271: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     274: checkcast     #121                // class java/util/List
     277: invokeinterface #286,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     282: astore        4
     284: aload         4
     286: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     291: ifeq          343
     294: aload         4
     296: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     301: checkcast     #162                // class kotlin/Pair
     304: astore        5
     306: aload         5
     308: invokevirtual #289                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     311: checkcast     #156                // class java/lang/Number
     314: invokevirtual #160                // Method java/lang/Number.intValue:()I
     317: istore        6
     319: aload         5
     321: invokevirtual #292                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     324: checkcast     #156                // class java/lang/Number
     327: invokevirtual #160                // Method java/lang/Number.intValue:()I
     330: istore        7
     332: aload_3
     333: iload         6
     335: aaload
     336: iload         7
     338: iconst_1
     339: bastore
     340: goto          284
     343: aload_3
     344: aload_0
     345: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     348: checkcast     #121                // class java/util/List
     351: invokestatic  #296                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     354: checkcast     #162                // class kotlin/Pair
     357: invokestatic  #298                // Method main$fold:([[ZLkotlin/Pair;)[[Z
     360: checkcast     #231                // class "[Ljava/lang/Object;"
     363: astore        4
     365: iconst_0
     366: istore        5
     368: iconst_0
     369: istore        6
     371: aload         4
     373: arraylength
     374: istore        7
     376: iload         6
     378: iload         7
     380: if_icmpge     475
     383: aload         4
     385: iload         6
     387: aaload
     388: astore        8
     390: iload         5
     392: aload         8
     394: checkcast     #266                // class "[Z"
     397: astore        9
     399: istore        19
     401: iconst_0
     402: istore        10
     404: aload         9
     406: astore        11
     408: iconst_0
     409: istore        12
     411: iconst_0
     412: istore        13
     414: iconst_0
     415: istore        14
     417: aload         11
     419: arraylength
     420: istore        15
     422: iload         14
     424: iload         15
     426: if_icmpge     457
     429: aload         11
     431: iload         14
     433: baload
     434: istore        16
     436: iload         16
     438: istore        17
     440: iconst_0
     441: istore        18
     443: iload         17
     445: ifeq          451
     448: iinc          13, 1
     451: iinc          14, 1
     454: goto          422
     457: iload         13
     459: nop
     460: istore        20
     462: iload         19
     464: iload         20
     466: iadd
     467: istore        5
     469: iinc          6, 1
     472: goto          376
     475: iload         5
     477: ireturn

  private static final int main$part2(kotlin.Pair<? extends java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, ? extends java.util.List<kotlin.Pair<java.lang.Boolean, java.lang.Integer>>>);
    Code:
       0: aload_0
       1: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #88                 // class java/lang/Iterable
       7: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      12: astore_3
      13: aload_3
      14: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      19: ifne          30
      22: new           #284                // class java/util/NoSuchElementException
      25: dup
      26: invokespecial #285                // Method java/util/NoSuchElementException."<init>":()V
      29: athrow
      30: aload_3
      31: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #162                // class kotlin/Pair
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      49: checkcast     #156                // class java/lang/Number
      52: invokevirtual #160                // Method java/lang/Number.intValue:()I
      55: istore        4
      57: aload_3
      58: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          107
      66: aload_3
      67: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: checkcast     #162                // class kotlin/Pair
      75: astore        5
      77: iconst_0
      78: istore        6
      80: aload         5
      82: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #156                // class java/lang/Number
      88: invokevirtual #160                // Method java/lang/Number.intValue:()I
      91: istore        5
      93: iload         4
      95: iload         5
      97: if_icmpge     57
     100: iload         5
     102: istore        4
     104: goto          57
     107: iload         4
     109: istore_1
     110: aload_0
     111: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     114: checkcast     #88                 // class java/lang/Iterable
     117: invokeinterface #97,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     122: astore        4
     124: aload         4
     126: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     131: ifne          142
     134: new           #284                // class java/util/NoSuchElementException
     137: dup
     138: invokespecial #285                // Method java/util/NoSuchElementException."<init>":()V
     141: athrow
     142: aload         4
     144: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     149: checkcast     #162                // class kotlin/Pair
     152: astore        5
     154: iconst_0
     155: istore        6
     157: aload         5
     159: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     162: checkcast     #156                // class java/lang/Number
     165: invokevirtual #160                // Method java/lang/Number.intValue:()I
     168: istore        5
     170: aload         4
     172: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     177: ifeq          222
     180: aload         4
     182: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     187: checkcast     #162                // class kotlin/Pair
     190: astore        6
     192: iconst_0
     193: istore        7
     195: aload         6
     197: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     200: checkcast     #156                // class java/lang/Number
     203: invokevirtual #160                // Method java/lang/Number.intValue:()I
     206: istore        6
     208: iload         5
     210: iload         6
     212: if_icmpge     170
     215: iload         6
     217: istore        5
     219: goto          170
     222: iload         5
     224: istore_2
     225: iconst_0
     226: istore        4
     228: iload_1
     229: iconst_1
     230: iadd
     231: istore        5
     233: iload         5
     235: anewarray     #266                // class "[Z"
     238: astore        6
     240: iload         4
     242: iload         5
     244: if_icmpge     267
     247: iload         4
     249: istore        7
     251: aload         6
     253: iload         7
     255: iload_2
     256: iconst_1
     257: iadd
     258: newarray       boolean
     260: aastore
     261: iinc          4, 1
     264: goto          240
     267: aload         6
     269: astore_3
     270: aload_0
     271: invokevirtual #252                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     274: checkcast     #121                // class java/util/List
     277: invokeinterface #286,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     282: astore        4
     284: aload         4
     286: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     291: ifeq          343
     294: aload         4
     296: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     301: checkcast     #162                // class kotlin/Pair
     304: astore        5
     306: aload         5
     308: invokevirtual #289                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     311: checkcast     #156                // class java/lang/Number
     314: invokevirtual #160                // Method java/lang/Number.intValue:()I
     317: istore        6
     319: aload         5
     321: invokevirtual #292                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     324: checkcast     #156                // class java/lang/Number
     327: invokevirtual #160                // Method java/lang/Number.intValue:()I
     330: istore        7
     332: aload_3
     333: iload         6
     335: aaload
     336: iload         7
     338: iconst_1
     339: bastore
     340: goto          284
     343: aload_0
     344: invokevirtual #258                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     347: checkcast     #121                // class java/util/List
     350: invokeinterface #286,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     355: astore        4
     357: aload         4
     359: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     364: ifeq          389
     367: aload         4
     369: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     374: checkcast     #162                // class kotlin/Pair
     377: astore        5
     379: aload_3
     380: aload         5
     382: invokestatic  #298                // Method main$fold:([[ZLkotlin/Pair;)[[Z
     385: astore_3
     386: goto          357
     389: aload_3
     390: invokestatic  #308                // Method main$log:([[Z)V
     393: bipush        42
     395: ireturn
}