import kotlin.streams.toList

fun main() = Tetris.solve()

private object Tetris {
    private const val width = 7
    private val winds = mutableListOf<Int>()
    private var fallingRock: FallingRock? = null
    private val cells = mutableListOf(
        // Floor
        MutableList(width) { i -> Cell.StableRock }
    )
    private var rocks = 0
    private var turn = 0
    private var highestRock = 0

    fun solve() {
        winds.clear()
        winds.addAll(readInput())

        val cache = mutableMapOf<Int, Triple<Int, Int, List<Int>>>()
        var cycleSize = Int.MAX_VALUE
        var cycleHeight = 0
        val target = 1_000_000_000_000
        var cycles = 0L
        var currentTarget = target
        while (rocks < currentTarget) {
            if (cycleSize == Int.MAX_VALUE) {
                if (fallingRock == null && rocks > 0 && rocks % 5 == 0) {
//                    println("Rock cycle, round $turn, ${turn % winds.size}")
                    val heights = heights()
                    val minHeight = heights().min()
                    val dHeights = heights.map { it - minHeight }
                    val (cachedRocks, cachedMinHeight, cachedDh) = cache.getOrDefault(
                        turn % winds.size,
                        Triple(0, 0, listOf<Int>())
                    )
                    if (dHeights == cachedDh) {
                        cycleSize = rocks - cachedRocks
                        cycleHeight = minHeight - cachedMinHeight
                        println("Cycle rocks=${cycleSize} height=$cycleHeight $dHeights")
                        currentTarget = rocks + ((target - rocks) % cycleSize)
                        cycles = (target - rocks) / cycleSize
                        println("Setting new target $currentTarget")
                    } else {
                        cache.put(turn % winds.size, Triple(rocks, minHeight, dHeights))
                    }
                    //println("$dHeights ${turn % winds.size}")
                }
            }
            tick()
        }

        println("Total height: shortcut=$highestRock ${highestRock + cycleHeight * cycles}")

    }

    fun heights(): List<Int> {
        return (0 until width).map { x -> (highestRock downTo 0).first { y -> cells[y][x] == Cell.StableRock } }
    }

    private fun tick() {
        addRockOrFall()
        blowAtFallingRock()
        maybeStabilizeFallenRock()
        turn += 1
    }

    private fun addRockOrFall() {
        if (fallingRock == null) {
            val pos = Pos(2, highestRock + 4)
            fallingRock = FallingRock(rockTypes[rocks % rockTypes.size], pos)
            extendCells(fallingRock!!.cells().maxOf { it.y })
        } else {
            moveFalling(0, -1)
        }
    }

    private fun moveFalling(dx: Int, dy: Int): Boolean {
        val initialPos = fallingRock!!.pos
        val nextRock = FallingRock(fallingRock!!.type, Pos(initialPos.x + dx, initialPos.y + dy))
        val moved = !nextRock.cells().any {
            it.x !in 0 until width || cells[it.y][it.x] == Cell.StableRock
        }
        if (moved) {
            fallingRock = nextRock
        }
        return moved
    }

    private fun maybeStabilizeFallenRock() {
        val rockCells = fallingRock!!.cells()
        val isStable = rockCells.any {
            cells[it.y - 1][it.x] == Cell.StableRock
        }
        if (isStable) {
            rockCells.forEach { cells[it.y][it.x] = Cell.StableRock }
            highestRock = maxOf(highestRock, rockCells.maxOf { it.y })
            rocks += 1
            fallingRock = null
        }
    }

    private fun extendCells(maxY: Int) {
        while (maxY >= cells.size) {
            cells.add(MutableList(width) { i -> Cell.Empty })
        }
    }

    private fun blowAtFallingRock() {
        moveFalling(winds[turn % winds.size], 0)
    }

    private fun visualize() {
        println("turn $turn")
        val rockCells = fallingRock?.cells()?.toSet() ?: setOf()
        for (y in cells.indices.reversed()) {
            print('|')
            for (x in cells[y].indices) {
                if (Pos(x, y) in rockCells) {
                    print('@')
                } else if (cells[y][x] == Cell.StableRock) {
                    print(if (y > 0) '#' else '-')
                } else {
                    print('.')
                }
            }
            println('|')
        }
    }

    private fun readInput(): List<Int> = readLine()!!.chars().map {
        when (it) {
            '<'.code -> -1
            '>'.code -> 1
            else -> throw Error("Invalid char $it")
        }
    }.toList()

    private data class Pos(val x: Int, val y: Int)

    private enum class Cell {
        Empty,
        StableRock,
    }

    private enum class RockType(val cells: List<Pos>) {
        HLine(listOf(Pos(0, 0), Pos(1, 0), Pos(2, 0), Pos(3, 0))),
        Cross(listOf(Pos(1, 0), Pos(0, 1), Pos(1, 1), Pos(2, 1), Pos(1, 2))),
        RightAngle(listOf(Pos(0, 0), Pos(1, 0), Pos(2, 0), Pos(2, 1), Pos(2, 2))),
        VLine(listOf(Pos(0, 0), Pos(0, 1), Pos(0, 2), Pos(0, 3))),
        Square(listOf(Pos(0, 0), Pos(1, 0), Pos(0, 1), Pos(1, 1)))
    }

    private data class FallingRock(val type: RockType, val pos: Pos) {
        fun cells() = type.cells.map { Pos(pos.x + it.x, pos.y + it.y) }
    }

    private val rockTypes = listOf(RockType.HLine, RockType.Cross, RockType.RightAngle, RockType.VLine, RockType.Square)
}

Compiled from "Tetris.kt"
final class Tetris$Pos {
  private final int x;

  private final int y;

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

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

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

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

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

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

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

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

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

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

Compiled from "Tetris.kt"
final class Tetris$Cell extends java.lang.Enum<Tetris$Cell> {
  public static final Tetris$Cell Empty;

  public static final Tetris$Cell StableRock;

  private static final Tetris$Cell[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Tetris$Cell();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #10                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: return

  public static Tetris$Cell[] values();
    Code:
       0: getstatic     #22                 // Field $VALUES:[LTetris$Cell;
       3: invokevirtual #28                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #29                 // class "[LTetris$Cell;"
       9: areturn

  public static Tetris$Cell valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Tetris$Cell
       2: aload_0
       3: invokestatic  #34                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Tetris$Cell
       9: areturn

  public static kotlin.enums.EnumEntries<Tetris$Cell> getEntries();
    Code:
       0: getstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Tetris$Cell[] $values();
    Code:
       0: iconst_2
       1: anewarray     #2                  // class Tetris$Cell
       4: astore_0
       5: aload_0
       6: iconst_0
       7: getstatic     #47                 // Field Empty:LTetris$Cell;
      10: aastore
      11: aload_0
      12: iconst_1
      13: getstatic     #50                 // Field StableRock:LTetris$Cell;
      16: aastore
      17: aload_0
      18: areturn

  static {};
    Code:
       0: new           #2                  // class Tetris$Cell
       3: dup
       4: ldc           #52                 // String Empty
       6: iconst_0
       7: invokespecial #53                 // Method "<init>":(Ljava/lang/String;I)V
      10: putstatic     #47                 // Field Empty:LTetris$Cell;
      13: new           #2                  // class Tetris$Cell
      16: dup
      17: ldc           #54                 // String StableRock
      19: iconst_1
      20: invokespecial #53                 // Method "<init>":(Ljava/lang/String;I)V
      23: putstatic     #50                 // Field StableRock:LTetris$Cell;
      26: invokestatic  #56                 // Method $values:()[LTetris$Cell;
      29: putstatic     #22                 // Field $VALUES:[LTetris$Cell;
      32: getstatic     #22                 // Field $VALUES:[LTetris$Cell;
      35: checkcast     #58                 // class "[Ljava/lang/Enum;"
      38: invokestatic  #64                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
      41: putstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
      44: return
}

Compiled from "Tetris.kt"
final class Tetris$RockType extends java.lang.Enum<Tetris$RockType> {
  private final java.util.List<Tetris$Pos> cells;

  public static final Tetris$RockType HLine;

  public static final Tetris$RockType Cross;

  public static final Tetris$RockType RightAngle;

  public static final Tetris$RockType VLine;

  public static final Tetris$RockType Square;

  private static final Tetris$RockType[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Tetris$RockType(java.util.List<Tetris$Pos>);
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #11                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: aload_0
       7: aload_3
       8: putfield      #15                 // Field cells:Ljava/util/List;
      11: return

  public final java.util.List<Tetris$Pos> getCells();
    Code:
       0: aload_0
       1: getfield      #15                 // Field cells:Ljava/util/List;
       4: areturn

  public static Tetris$RockType[] values();
    Code:
       0: getstatic     #31                 // Field $VALUES:[LTetris$RockType;
       3: invokevirtual #37                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #38                 // class "[LTetris$RockType;"
       9: areturn

  public static Tetris$RockType valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Tetris$RockType
       2: aload_0
       3: invokestatic  #43                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Tetris$RockType
       9: areturn

  public static kotlin.enums.EnumEntries<Tetris$RockType> getEntries();
    Code:
       0: getstatic     #51                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Tetris$RockType[] $values();
    Code:
       0: iconst_5
       1: anewarray     #2                  // class Tetris$RockType
       4: astore_0
       5: aload_0
       6: iconst_0
       7: getstatic     #55                 // Field HLine:LTetris$RockType;
      10: aastore
      11: aload_0
      12: iconst_1
      13: getstatic     #58                 // Field Cross:LTetris$RockType;
      16: aastore
      17: aload_0
      18: iconst_2
      19: getstatic     #61                 // Field RightAngle:LTetris$RockType;
      22: aastore
      23: aload_0
      24: iconst_3
      25: getstatic     #64                 // Field VLine:LTetris$RockType;
      28: aastore
      29: aload_0
      30: iconst_4
      31: getstatic     #67                 // Field Square:LTetris$RockType;
      34: aastore
      35: aload_0
      36: areturn

  static {};
    Code:
       0: new           #2                  // class Tetris$RockType
       3: dup
       4: ldc           #70                 // String HLine
       6: iconst_0
       7: iconst_4
       8: anewarray     #72                 // class Tetris$Pos
      11: astore_0
      12: aload_0
      13: iconst_0
      14: new           #72                 // class Tetris$Pos
      17: dup
      18: iconst_0
      19: iconst_0
      20: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
      23: aastore
      24: aload_0
      25: iconst_1
      26: new           #72                 // class Tetris$Pos
      29: dup
      30: iconst_1
      31: iconst_0
      32: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
      35: aastore
      36: aload_0
      37: iconst_2
      38: new           #72                 // class Tetris$Pos
      41: dup
      42: iconst_2
      43: iconst_0
      44: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
      47: aastore
      48: aload_0
      49: iconst_3
      50: new           #72                 // class Tetris$Pos
      53: dup
      54: iconst_3
      55: iconst_0
      56: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
      59: aastore
      60: aload_0
      61: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      64: invokespecial #83                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
      67: putstatic     #55                 // Field HLine:LTetris$RockType;
      70: new           #2                  // class Tetris$RockType
      73: dup
      74: ldc           #84                 // String Cross
      76: iconst_1
      77: iconst_5
      78: anewarray     #72                 // class Tetris$Pos
      81: astore_0
      82: aload_0
      83: iconst_0
      84: new           #72                 // class Tetris$Pos
      87: dup
      88: iconst_1
      89: iconst_0
      90: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
      93: aastore
      94: aload_0
      95: iconst_1
      96: new           #72                 // class Tetris$Pos
      99: dup
     100: iconst_0
     101: iconst_1
     102: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     105: aastore
     106: aload_0
     107: iconst_2
     108: new           #72                 // class Tetris$Pos
     111: dup
     112: iconst_1
     113: iconst_1
     114: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     117: aastore
     118: aload_0
     119: iconst_3
     120: new           #72                 // class Tetris$Pos
     123: dup
     124: iconst_2
     125: iconst_1
     126: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     129: aastore
     130: aload_0
     131: iconst_4
     132: new           #72                 // class Tetris$Pos
     135: dup
     136: iconst_1
     137: iconst_2
     138: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     141: aastore
     142: aload_0
     143: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     146: invokespecial #83                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
     149: putstatic     #58                 // Field Cross:LTetris$RockType;
     152: new           #2                  // class Tetris$RockType
     155: dup
     156: ldc           #85                 // String RightAngle
     158: iconst_2
     159: iconst_5
     160: anewarray     #72                 // class Tetris$Pos
     163: astore_0
     164: aload_0
     165: iconst_0
     166: new           #72                 // class Tetris$Pos
     169: dup
     170: iconst_0
     171: iconst_0
     172: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     175: aastore
     176: aload_0
     177: iconst_1
     178: new           #72                 // class Tetris$Pos
     181: dup
     182: iconst_1
     183: iconst_0
     184: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     187: aastore
     188: aload_0
     189: iconst_2
     190: new           #72                 // class Tetris$Pos
     193: dup
     194: iconst_2
     195: iconst_0
     196: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     199: aastore
     200: aload_0
     201: iconst_3
     202: new           #72                 // class Tetris$Pos
     205: dup
     206: iconst_2
     207: iconst_1
     208: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     211: aastore
     212: aload_0
     213: iconst_4
     214: new           #72                 // class Tetris$Pos
     217: dup
     218: iconst_2
     219: iconst_2
     220: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     223: aastore
     224: aload_0
     225: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     228: invokespecial #83                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
     231: putstatic     #61                 // Field RightAngle:LTetris$RockType;
     234: new           #2                  // class Tetris$RockType
     237: dup
     238: ldc           #86                 // String VLine
     240: iconst_3
     241: iconst_4
     242: anewarray     #72                 // class Tetris$Pos
     245: astore_0
     246: aload_0
     247: iconst_0
     248: new           #72                 // class Tetris$Pos
     251: dup
     252: iconst_0
     253: iconst_0
     254: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     257: aastore
     258: aload_0
     259: iconst_1
     260: new           #72                 // class Tetris$Pos
     263: dup
     264: iconst_0
     265: iconst_1
     266: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     269: aastore
     270: aload_0
     271: iconst_2
     272: new           #72                 // class Tetris$Pos
     275: dup
     276: iconst_0
     277: iconst_2
     278: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     281: aastore
     282: aload_0
     283: iconst_3
     284: new           #72                 // class Tetris$Pos
     287: dup
     288: iconst_0
     289: iconst_3
     290: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     293: aastore
     294: aload_0
     295: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     298: invokespecial #83                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
     301: putstatic     #64                 // Field VLine:LTetris$RockType;
     304: new           #2                  // class Tetris$RockType
     307: dup
     308: ldc           #87                 // String Square
     310: iconst_4
     311: iconst_4
     312: anewarray     #72                 // class Tetris$Pos
     315: astore_0
     316: aload_0
     317: iconst_0
     318: new           #72                 // class Tetris$Pos
     321: dup
     322: iconst_0
     323: iconst_0
     324: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     327: aastore
     328: aload_0
     329: iconst_1
     330: new           #72                 // class Tetris$Pos
     333: dup
     334: iconst_1
     335: iconst_0
     336: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     339: aastore
     340: aload_0
     341: iconst_2
     342: new           #72                 // class Tetris$Pos
     345: dup
     346: iconst_0
     347: iconst_1
     348: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     351: aastore
     352: aload_0
     353: iconst_3
     354: new           #72                 // class Tetris$Pos
     357: dup
     358: iconst_1
     359: iconst_1
     360: invokespecial #75                 // Method Tetris$Pos."<init>":(II)V
     363: aastore
     364: aload_0
     365: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     368: invokespecial #83                 // Method "<init>":(Ljava/lang/String;ILjava/util/List;)V
     371: putstatic     #67                 // Field Square:LTetris$RockType;
     374: invokestatic  #89                 // Method $values:()[LTetris$RockType;
     377: putstatic     #31                 // Field $VALUES:[LTetris$RockType;
     380: getstatic     #31                 // Field $VALUES:[LTetris$RockType;
     383: checkcast     #91                 // class "[Ljava/lang/Enum;"
     386: invokestatic  #97                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
     389: putstatic     #51                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
     392: return
}

Compiled from "Tetris.kt"
public final class TetrisKt {
  public static final void main();
    Code:
       0: getstatic     #12                 // Field Tetris.INSTANCE:LTetris;
       3: invokevirtual #15                 // Method Tetris.solve:()V
       6: return

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

Compiled from "Tetris.kt"
final class Tetris$FallingRock {
  private final Tetris$RockType type;

  private final Tetris$Pos pos;

  public Tetris$FallingRock(Tetris$RockType, Tetris$Pos);
    Code:
       0: aload_1
       1: ldc           #9                  // String type
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String pos
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokespecial #20                 // Method java/lang/Object."<init>":()V
      16: aload_0
      17: aload_1
      18: putfield      #23                 // Field type:LTetris$RockType;
      21: aload_0
      22: aload_2
      23: putfield      #26                 // Field pos:LTetris$Pos;
      26: return

  public final Tetris$RockType getType();
    Code:
       0: aload_0
       1: getfield      #23                 // Field type:LTetris$RockType;
       4: areturn

  public final Tetris$Pos getPos();
    Code:
       0: aload_0
       1: getfield      #26                 // Field pos:LTetris$Pos;
       4: areturn

  public final java.util.List<Tetris$Pos> cells();
    Code:
       0: aload_0
       1: getfield      #23                 // Field type:LTetris$RockType;
       4: invokevirtual #40                 // Method Tetris$RockType.getCells:()Ljava/util/List;
       7: checkcast     #42                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #44                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #55                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          122
      54: aload         6
      56: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #71                 // class Tetris$Pos
      70: astore        8
      72: astore        10
      74: iconst_0
      75: istore        9
      77: new           #71                 // class Tetris$Pos
      80: dup
      81: aload_0
      82: getfield      #26                 // Field pos:LTetris$Pos;
      85: invokevirtual #75                 // Method Tetris$Pos.getX:()I
      88: aload         8
      90: invokevirtual #75                 // Method Tetris$Pos.getX:()I
      93: iadd
      94: aload_0
      95: getfield      #26                 // Field pos:LTetris$Pos;
      98: invokevirtual #78                 // Method Tetris$Pos.getY:()I
     101: aload         8
     103: invokevirtual #78                 // Method Tetris$Pos.getY:()I
     106: iadd
     107: invokespecial #81                 // Method Tetris$Pos."<init>":(II)V
     110: aload         10
     112: swap
     113: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     118: pop
     119: goto          44
     122: aload         4
     124: checkcast     #87                 // class java/util/List
     127: nop
     128: areturn

  public final Tetris$RockType component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field type:LTetris$RockType;
       4: areturn

  public final Tetris$Pos component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field pos:LTetris$Pos;
       4: areturn

  public final Tetris$FallingRock copy(Tetris$RockType, Tetris$Pos);
    Code:
       0: aload_1
       1: ldc           #9                  // String type
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String pos
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class Tetris$FallingRock
      15: dup
      16: aload_1
      17: aload_2
      18: invokespecial #105                // Method "<init>":(LTetris$RockType;LTetris$Pos;)V
      21: areturn

  public static Tetris$FallingRock copy$default(Tetris$FallingRock, Tetris$RockType, Tetris$Pos, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #23                 // Field type:LTetris$RockType;
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #26                 // Field pos:LTetris$Pos;
      21: astore_2
      22: aload_0
      23: aload_1
      24: aload_2
      25: invokevirtual #109                // Method copy:(LTetris$RockType;LTetris$Pos;)LTetris$FallingRock;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #113                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #114                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #116                // String FallingRock(type=
       9: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field type:LTetris$RockType;
      16: invokevirtual #123                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #125                // String , pos=
      21: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field pos:LTetris$Pos;
      28: invokevirtual #123                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #128                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #130                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #23                 // Field type:LTetris$RockType;
       4: invokevirtual #133                // Method Tetris$RockType.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #26                 // Field pos:LTetris$Pos;
      16: invokevirtual #134                // Method Tetris$Pos.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Tetris$FallingRock
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Tetris$FallingRock
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field type:LTetris$RockType;
      25: aload_2
      26: getfield      #23                 // Field type:LTetris$RockType;
      29: if_acmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #26                 // Field pos:LTetris$Pos;
      38: aload_2
      39: getfield      #26                 // Field pos:LTetris$Pos;
      42: invokestatic  #141                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn
}

Compiled from "Tetris.kt"
final class Tetris {
  public static final Tetris INSTANCE;

  private static final int width;

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

  private static Tetris$FallingRock fallingRock;

  private static final java.util.List<java.util.List<Tetris$Cell>> cells;

  private static int rocks;

  private static int turn;

  private static int highestRock;

  private static final java.util.List<Tetris$RockType> rockTypes;

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

  public final void solve();
    Code:
       0: getstatic     #15                 // Field winds:Ljava/util/List;
       3: invokeinterface #20,  1           // InterfaceMethod java/util/List.clear:()V
       8: getstatic     #15                 // Field winds:Ljava/util/List;
      11: aload_0
      12: invokespecial #24                 // Method readInput:()Ljava/util/List;
      15: checkcast     #26                 // class java/util/Collection
      18: invokeinterface #30,  2           // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
      23: pop
      24: new           #32                 // class java/util/LinkedHashMap
      27: dup
      28: invokespecial #33                 // Method java/util/LinkedHashMap."<init>":()V
      31: checkcast     #35                 // class java/util/Map
      34: astore_1
      35: ldc           #36                 // int 2147483647
      37: istore_2
      38: iconst_0
      39: istore_3
      40: ldc2_w        #37                 // long 1000000000000l
      43: lstore        4
      45: lconst_0
      46: lstore        6
      48: lload         4
      50: lstore        8
      52: getstatic     #42                 // Field rocks:I
      55: i2l
      56: lload         8
      58: lcmp
      59: ifge          477
      62: iload_2
      63: ldc           #36                 // int 2147483647
      65: if_icmpne     470
      68: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
      71: ifnonnull     470
      74: getstatic     #42                 // Field rocks:I
      77: ifle          470
      80: getstatic     #42                 // Field rocks:I
      83: iconst_5
      84: irem
      85: ifne          470
      88: aload_0
      89: invokevirtual #49                 // Method heights:()Ljava/util/List;
      92: astore        10
      94: aload_0
      95: invokevirtual #49                 // Method heights:()Ljava/util/List;
      98: checkcast     #51                 // class java/lang/Iterable
     101: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     104: checkcast     #59                 // class java/lang/Number
     107: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     110: istore        11
     112: aload         10
     114: checkcast     #51                 // class java/lang/Iterable
     117: astore        13
     119: iconst_0
     120: istore        14
     122: aload         13
     124: astore        15
     126: new           #65                 // class java/util/ArrayList
     129: dup
     130: aload         13
     132: bipush        10
     134: invokestatic  #69                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     137: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
     140: checkcast     #26                 // class java/util/Collection
     143: astore        16
     145: iconst_0
     146: istore        17
     148: aload         15
     150: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     155: astore        18
     157: aload         18
     159: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     164: ifeq          213
     167: aload         18
     169: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     174: astore        19
     176: aload         16
     178: aload         19
     180: checkcast     #59                 // class java/lang/Number
     183: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     186: istore        20
     188: astore        22
     190: iconst_0
     191: istore        21
     193: iload         20
     195: iload         11
     197: isub
     198: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: aload         22
     203: swap
     204: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     209: pop
     210: goto          157
     213: aload         16
     215: checkcast     #17                 // class java/util/List
     218: nop
     219: astore        12
     221: aload_1
     222: getstatic     #99                 // Field turn:I
     225: getstatic     #15                 // Field winds:Ljava/util/List;
     228: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
     233: irem
     234: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     237: new           #104                // class kotlin/Triple
     240: dup
     241: iconst_0
     242: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     245: iconst_0
     246: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     249: invokestatic  #107                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     252: invokespecial #110                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     255: invokeinterface #114,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     260: checkcast     #104                // class kotlin/Triple
     263: astore        13
     265: aload         13
     267: invokevirtual #117                // Method kotlin/Triple.component1:()Ljava/lang/Object;
     270: checkcast     #59                 // class java/lang/Number
     273: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     276: istore        14
     278: aload         13
     280: invokevirtual #120                // Method kotlin/Triple.component2:()Ljava/lang/Object;
     283: checkcast     #59                 // class java/lang/Number
     286: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     289: istore        15
     291: aload         13
     293: invokevirtual #123                // Method kotlin/Triple.component3:()Ljava/lang/Object;
     296: checkcast     #17                 // class java/util/List
     299: astore        16
     301: aload         12
     303: aload         16
     305: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     308: ifeq          428
     311: getstatic     #42                 // Field rocks:I
     314: iload         14
     316: isub
     317: istore_2
     318: iload         11
     320: iload         15
     322: isub
     323: istore_3
     324: new           #131                // class java/lang/StringBuilder
     327: dup
     328: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     331: ldc           #134                // String Cycle rocks=
     333: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     336: iload_2
     337: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     340: ldc           #143                // String  height=
     342: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     345: iload_3
     346: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     349: bipush        32
     351: invokevirtual #146                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     354: aload         12
     356: invokevirtual #149                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     359: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     362: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     365: swap
     366: invokevirtual #165                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     369: getstatic     #42                 // Field rocks:I
     372: i2l
     373: lload         4
     375: getstatic     #42                 // Field rocks:I
     378: i2l
     379: lsub
     380: iload_2
     381: i2l
     382: lrem
     383: ladd
     384: lstore        8
     386: lload         4
     388: getstatic     #42                 // Field rocks:I
     391: i2l
     392: lsub
     393: iload_2
     394: i2l
     395: ldiv
     396: lstore        6
     398: new           #131                // class java/lang/StringBuilder
     401: dup
     402: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     405: ldc           #167                // String Setting new target
     407: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     410: lload         8
     412: invokevirtual #170                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     415: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     418: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     421: swap
     422: invokevirtual #165                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     425: goto          470
     428: aload_1
     429: getstatic     #99                 // Field turn:I
     432: getstatic     #15                 // Field winds:Ljava/util/List;
     435: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
     440: irem
     441: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     444: new           #104                // class kotlin/Triple
     447: dup
     448: getstatic     #42                 // Field rocks:I
     451: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     454: iload         11
     456: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     459: aload         12
     461: invokespecial #110                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     464: invokeinterface #173,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     469: pop
     470: aload_0
     471: invokespecial #176                // Method tick:()V
     474: goto          52
     477: new           #131                // class java/lang/StringBuilder
     480: dup
     481: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     484: ldc           #178                // String Total height: shortcut=
     486: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     489: getstatic     #181                // Field highestRock:I
     492: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     495: bipush        32
     497: invokevirtual #146                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     500: getstatic     #181                // Field highestRock:I
     503: i2l
     504: iload_3
     505: i2l
     506: lload         6
     508: lmul
     509: ladd
     510: invokevirtual #170                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     513: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     516: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     519: swap
     520: invokevirtual #165                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     523: return

  public final java.util.List<java.lang.Integer> heights();
    Code:
       0: iconst_0
       1: bipush        7
       3: invokestatic  #213                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
       6: checkcast     #51                 // class java/lang/Iterable
       9: astore_1
      10: iconst_0
      11: istore_2
      12: aload_1
      13: astore_3
      14: new           #65                 // class java/util/ArrayList
      17: dup
      18: aload_1
      19: bipush        10
      21: invokestatic  #69                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #26                 // class java/util/Collection
      30: astore        4
      32: iconst_0
      33: istore        5
      35: aload_3
      36: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        6
      43: aload         6
      45: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          190
      53: aload         6
      55: checkcast     #215                // class kotlin/collections/IntIterator
      58: invokevirtual #218                // Method kotlin/collections/IntIterator.nextInt:()I
      61: istore        7
      63: aload         4
      65: iload         7
      67: istore        8
      69: astore        16
      71: iconst_0
      72: istore        9
      74: getstatic     #181                // Field highestRock:I
      77: iconst_0
      78: invokestatic  #222                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      81: checkcast     #51                 // class java/lang/Iterable
      84: astore        10
      86: iconst_0
      87: istore        11
      89: aload         10
      91: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      96: astore        12
      98: aload         12
     100: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     105: ifeq          164
     108: aload         12
     110: checkcast     #215                // class kotlin/collections/IntIterator
     113: invokevirtual #218                // Method kotlin/collections/IntIterator.nextInt:()I
     116: istore        13
     118: iload         13
     120: istore        14
     122: iconst_0
     123: istore        15
     125: getstatic     #225                // Field cells:Ljava/util/List;
     128: iload         14
     130: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #17                 // class java/util/List
     138: iload         8
     140: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
     148: if_acmpne     155
     151: iconst_1
     152: goto          156
     155: iconst_0
     156: ifeq          98
     159: iload         13
     161: goto          174
     164: new           #237                // class java/util/NoSuchElementException
     167: dup
     168: ldc           #239                // String Collection contains no element matching the predicate.
     170: invokespecial #242                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     173: athrow
     174: nop
     175: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     178: aload         16
     180: swap
     181: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     186: pop
     187: goto          43
     190: aload         4
     192: checkcast     #17                 // class java/util/List
     195: nop
     196: areturn

  private final void tick();
    Code:
       0: aload_0
       1: invokespecial #252                // Method addRockOrFall:()V
       4: aload_0
       5: invokespecial #255                // Method blowAtFallingRock:()V
       8: aload_0
       9: invokespecial #258                // Method maybeStabilizeFallenRock:()V
      12: getstatic     #99                 // Field turn:I
      15: iconst_1
      16: iadd
      17: putstatic     #99                 // Field turn:I
      20: return

  private final void addRockOrFall();
    Code:
       0: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
       3: ifnonnull     174
       6: new           #260                // class Tetris$Pos
       9: dup
      10: iconst_2
      11: getstatic     #181                // Field highestRock:I
      14: iconst_4
      15: iadd
      16: invokespecial #263                // Method Tetris$Pos."<init>":(II)V
      19: astore_1
      20: new           #265                // class Tetris$FallingRock
      23: dup
      24: getstatic     #268                // Field rockTypes:Ljava/util/List;
      27: getstatic     #42                 // Field rocks:I
      30: getstatic     #268                // Field rockTypes:Ljava/util/List;
      33: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
      38: irem
      39: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      44: checkcast     #270                // class Tetris$RockType
      47: aload_1
      48: invokespecial #273                // Method Tetris$FallingRock."<init>":(LTetris$RockType;LTetris$Pos;)V
      51: putstatic     #46                 // Field fallingRock:LTetris$FallingRock;
      54: aload_0
      55: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
      58: dup
      59: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      62: invokevirtual #278                // Method Tetris$FallingRock.cells:()Ljava/util/List;
      65: checkcast     #51                 // class java/lang/Iterable
      68: astore_2
      69: astore        7
      71: aload_2
      72: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      77: astore_3
      78: aload_3
      79: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifne          95
      87: new           #237                // class java/util/NoSuchElementException
      90: dup
      91: invokespecial #279                // Method java/util/NoSuchElementException."<init>":()V
      94: athrow
      95: aload_3
      96: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     101: checkcast     #260                // class Tetris$Pos
     104: astore        4
     106: iconst_0
     107: istore        5
     109: aload         4
     111: invokevirtual #282                // Method Tetris$Pos.getY:()I
     114: istore        4
     116: aload_3
     117: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     122: ifeq          160
     125: aload_3
     126: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     131: checkcast     #260                // class Tetris$Pos
     134: astore        5
     136: iconst_0
     137: istore        6
     139: aload         5
     141: invokevirtual #282                // Method Tetris$Pos.getY:()I
     144: istore        5
     146: iload         4
     148: iload         5
     150: if_icmpge     116
     153: iload         5
     155: istore        4
     157: goto          116
     160: iload         4
     162: istore        8
     164: aload         7
     166: iload         8
     168: invokespecial #285                // Method extendCells:(I)V
     171: goto          181
     174: aload_0
     175: iconst_0
     176: iconst_m1
     177: invokespecial #289                // Method moveFalling:(II)Z
     180: pop
     181: return

  private final boolean moveFalling(int, int);
    Code:
       0: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
       3: dup
       4: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: invokevirtual #296                // Method Tetris$FallingRock.getPos:()LTetris$Pos;
      10: astore_3
      11: new           #265                // class Tetris$FallingRock
      14: dup
      15: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
      18: dup
      19: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      22: invokevirtual #300                // Method Tetris$FallingRock.getType:()LTetris$RockType;
      25: new           #260                // class Tetris$Pos
      28: dup
      29: aload_3
      30: invokevirtual #303                // Method Tetris$Pos.getX:()I
      33: iload_1
      34: iadd
      35: aload_3
      36: invokevirtual #282                // Method Tetris$Pos.getY:()I
      39: iload_2
      40: iadd
      41: invokespecial #263                // Method Tetris$Pos."<init>":(II)V
      44: invokespecial #273                // Method Tetris$FallingRock."<init>":(LTetris$RockType;LTetris$Pos;)V
      47: astore        4
      49: aload         4
      51: invokevirtual #278                // Method Tetris$FallingRock.cells:()Ljava/util/List;
      54: checkcast     #51                 // class java/lang/Iterable
      57: astore        6
      59: iconst_0
      60: istore        7
      62: aload         6
      64: instanceof    #26                 // class java/util/Collection
      67: ifeq          87
      70: aload         6
      72: checkcast     #26                 // class java/util/Collection
      75: invokeinterface #306,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      80: ifeq          87
      83: iconst_0
      84: goto          202
      87: aload         6
      89: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      94: astore        8
      96: aload         8
      98: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     103: ifeq          201
     106: aload         8
     108: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     113: astore        9
     115: aload         9
     117: checkcast     #260                // class Tetris$Pos
     120: astore        10
     122: iconst_0
     123: istore        11
     125: aload         10
     127: invokevirtual #303                // Method Tetris$Pos.getX:()I
     130: istore        12
     132: iconst_0
     133: iload         12
     135: if_icmpgt     153
     138: iload         12
     140: bipush        7
     142: if_icmpge     149
     145: iconst_1
     146: goto          154
     149: iconst_0
     150: goto          154
     153: iconst_0
     154: ifeq          189
     157: getstatic     #225                // Field cells:Ljava/util/List;
     160: aload         10
     162: invokevirtual #282                // Method Tetris$Pos.getY:()I
     165: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     170: checkcast     #17                 // class java/util/List
     173: aload         10
     175: invokevirtual #303                // Method Tetris$Pos.getX:()I
     178: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
     186: if_acmpne     193
     189: iconst_1
     190: goto          194
     193: iconst_0
     194: ifeq          96
     197: iconst_1
     198: goto          202
     201: iconst_0
     202: ifne          209
     205: iconst_1
     206: goto          210
     209: iconst_0
     210: istore        5
     212: iload         5
     214: ifeq          222
     217: aload         4
     219: putstatic     #46                 // Field fallingRock:LTetris$FallingRock;
     222: iload         5
     224: ireturn

  private final void maybeStabilizeFallenRock();
    Code:
       0: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
       3: dup
       4: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: invokevirtual #278                // Method Tetris$FallingRock.cells:()Ljava/util/List;
      10: astore_1
      11: aload_1
      12: checkcast     #51                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: instanceof    #26                 // class java/util/Collection
      23: ifeq          42
      26: aload_3
      27: checkcast     #26                 // class java/util/Collection
      30: invokeinterface #306,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      35: ifeq          42
      38: iconst_0
      39: goto          126
      42: aload_3
      43: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        5
      50: aload         5
      52: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          125
      60: aload         5
      62: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        6
      69: aload         6
      71: checkcast     #260                // class Tetris$Pos
      74: astore        7
      76: iconst_0
      77: istore        8
      79: getstatic     #225                // Field cells:Ljava/util/List;
      82: aload         7
      84: invokevirtual #282                // Method Tetris$Pos.getY:()I
      87: iconst_1
      88: isub
      89: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #17                 // class java/util/List
      97: aload         7
      99: invokevirtual #303                // Method Tetris$Pos.getX:()I
     102: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     107: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
     110: if_acmpne     117
     113: iconst_1
     114: goto          118
     117: iconst_0
     118: ifeq          50
     121: iconst_1
     122: goto          126
     125: iconst_0
     126: istore_2
     127: iload_2
     128: ifeq          337
     131: aload_1
     132: checkcast     #51                 // class java/lang/Iterable
     135: astore_3
     136: iconst_0
     137: istore        4
     139: aload_3
     140: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        5
     147: aload         5
     149: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          210
     157: aload         5
     159: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        6
     166: aload         6
     168: checkcast     #260                // class Tetris$Pos
     171: astore        7
     173: iconst_0
     174: istore        8
     176: getstatic     #225                // Field cells:Ljava/util/List;
     179: aload         7
     181: invokevirtual #282                // Method Tetris$Pos.getY:()I
     184: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     189: checkcast     #17                 // class java/util/List
     192: aload         7
     194: invokevirtual #303                // Method Tetris$Pos.getX:()I
     197: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
     200: invokeinterface #319,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     205: pop
     206: nop
     207: goto          147
     210: nop
     211: getstatic     #181                // Field highestRock:I
     214: istore_3
     215: aload_1
     216: checkcast     #51                 // class java/lang/Iterable
     219: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     224: astore        5
     226: aload         5
     228: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     233: ifne          244
     236: new           #237                // class java/util/NoSuchElementException
     239: dup
     240: invokespecial #279                // Method java/util/NoSuchElementException."<init>":()V
     243: athrow
     244: aload         5
     246: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     251: checkcast     #260                // class Tetris$Pos
     254: astore        6
     256: iconst_0
     257: istore        7
     259: aload         6
     261: invokevirtual #282                // Method Tetris$Pos.getY:()I
     264: istore        6
     266: aload         5
     268: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     273: ifeq          312
     276: aload         5
     278: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     283: checkcast     #260                // class Tetris$Pos
     286: astore        7
     288: iconst_0
     289: istore        8
     291: aload         7
     293: invokevirtual #282                // Method Tetris$Pos.getY:()I
     296: istore        7
     298: iload         6
     300: iload         7
     302: if_icmpge     266
     305: iload         7
     307: istore        6
     309: goto          266
     312: iload         6
     314: istore        4
     316: iload_3
     317: iload         4
     319: invokestatic  #325                // Method java/lang/Math.max:(II)I
     322: putstatic     #181                // Field highestRock:I
     325: getstatic     #42                 // Field rocks:I
     328: iconst_1
     329: iadd
     330: putstatic     #42                 // Field rocks:I
     333: aconst_null
     334: putstatic     #46                 // Field fallingRock:LTetris$FallingRock;
     337: return

  private final void extendCells(int);
    Code:
       0: iload_1
       1: getstatic     #225                // Field cells:Ljava/util/List;
       4: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
       9: if_icmplt     84
      12: getstatic     #225                // Field cells:Ljava/util/List;
      15: bipush        7
      17: istore_2
      18: astore        8
      20: new           #65                 // class java/util/ArrayList
      23: dup
      24: iload_2
      25: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
      28: astore_3
      29: iconst_0
      30: istore        4
      32: iload         4
      34: iload_2
      35: if_icmpge     68
      38: iload         4
      40: istore        5
      42: aload_3
      43: iload         5
      45: istore        6
      47: astore        9
      49: iconst_0
      50: istore        7
      52: getstatic     #335                // Field Tetris$Cell.Empty:LTetris$Cell;
      55: aload         9
      57: swap
      58: invokevirtual #336                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      61: pop
      62: iinc          4, 1
      65: goto          32
      68: aload_3
      69: checkcast     #17                 // class java/util/List
      72: aload         8
      74: swap
      75: invokeinterface #337,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      80: pop
      81: goto          0
      84: return

  private final void blowAtFallingRock();
    Code:
       0: aload_0
       1: getstatic     #15                 // Field winds:Ljava/util/List;
       4: getstatic     #99                 // Field turn:I
       7: getstatic     #15                 // Field winds:Ljava/util/List;
      10: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
      15: irem
      16: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      21: checkcast     #59                 // class java/lang/Number
      24: invokevirtual #63                 // Method java/lang/Number.intValue:()I
      27: iconst_0
      28: invokespecial #289                // Method moveFalling:(II)Z
      31: pop
      32: return

  private final void visualize();
    Code:
       0: new           #131                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
       7: ldc_w         #343                // String turn
      10: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      13: getstatic     #99                 // Field turn:I
      16: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
      25: swap
      26: invokevirtual #165                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      29: getstatic     #46                 // Field fallingRock:LTetris$FallingRock;
      32: dup
      33: ifnull        53
      36: invokevirtual #278                // Method Tetris$FallingRock.cells:()Ljava/util/List;
      39: dup
      40: ifnull        53
      43: checkcast     #51                 // class java/lang/Iterable
      46: invokestatic  #347                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
      49: dup
      50: ifnonnull     57
      53: pop
      54: invokestatic  #353                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
      57: astore_1
      58: getstatic     #225                // Field cells:Ljava/util/List;
      61: checkcast     #26                 // class java/util/Collection
      64: invokeinterface #354,  1          // InterfaceMethod java/util/Collection.size:()I
      69: iconst_m1
      70: iadd
      71: istore_2
      72: iconst_0
      73: iload_2
      74: if_icmpgt     241
      77: iload_2
      78: istore_3
      79: iinc          2, -1
      82: bipush        124
      84: istore        4
      86: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
      89: iload         4
      91: invokevirtual #358                // Method java/io/PrintStream.print:(C)V
      94: iconst_0
      95: istore        4
      97: getstatic     #225                // Field cells:Ljava/util/List;
     100: iload_3
     101: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     106: checkcast     #26                 // class java/util/Collection
     109: invokeinterface #354,  1          // InterfaceMethod java/util/Collection.size:()I
     114: istore        5
     116: iload         4
     118: iload         5
     120: if_icmpge     224
     123: aload_1
     124: new           #260                // class Tetris$Pos
     127: dup
     128: iload         4
     130: iload_3
     131: invokespecial #263                // Method Tetris$Pos."<init>":(II)V
     134: invokeinterface #363,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     139: ifeq          157
     142: bipush        64
     144: istore        6
     146: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     149: iload         6
     151: invokevirtual #358                // Method java/io/PrintStream.print:(C)V
     154: goto          218
     157: getstatic     #225                // Field cells:Ljava/util/List;
     160: iload_3
     161: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     166: checkcast     #17                 // class java/util/List
     169: iload         4
     171: invokeinterface #229,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     176: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
     179: if_acmpne     206
     182: iload_3
     183: ifle          191
     186: bipush        35
     188: goto          193
     191: bipush        45
     193: istore        6
     195: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     198: iload         6
     200: invokevirtual #358                // Method java/io/PrintStream.print:(C)V
     203: goto          218
     206: bipush        46
     208: istore        6
     210: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     213: iload         6
     215: invokevirtual #358                // Method java/io/PrintStream.print:(C)V
     218: iinc          4, 1
     221: goto          116
     224: bipush        124
     226: istore        4
     228: getstatic     #159                // Field java/lang/System.out:Ljava/io/PrintStream;
     231: iload         4
     233: invokevirtual #365                // Method java/io/PrintStream.println:(C)V
     236: iconst_0
     237: iload_2
     238: if_icmple     77
     241: return

  private final java.util.List<java.lang.Integer> readInput();
    Code:
       0: invokestatic  #371                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: invokevirtual #377                // Method java/lang/String.chars:()Ljava/util/stream/IntStream;
      10: invokedynamic #394,  0            // InvokeDynamic #0:applyAsInt:()Ljava/util/function/IntUnaryOperator;
      15: invokeinterface #400,  2          // InterfaceMethod java/util/stream/IntStream.map:(Ljava/util/function/IntUnaryOperator;)Ljava/util/stream/IntStream;
      20: dup
      21: ldc_w         #402                // String map(...)
      24: invokestatic  #406                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      27: invokestatic  #412                // Method kotlin/streams/jdk8/StreamsKt.toList:(Ljava/util/stream/IntStream;)Ljava/util/List;
      30: areturn

  private static final int readInput$lambda$10(int);
    Code:
       0: iload_0
       1: tableswitch   { // 60 to 62
                    60: 28
                    61: 36
                    62: 32
               default: 36
          }
      28: iconst_m1
      29: goto          64
      32: iconst_1
      33: goto          64
      36: new           #414                // class java/lang/Error
      39: dup
      40: new           #131                // class java/lang/StringBuilder
      43: dup
      44: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
      47: ldc_w         #416                // String Invalid char
      50: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      53: iload_0
      54: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      57: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      60: invokespecial #417                // Method java/lang/Error."<init>":(Ljava/lang/String;)V
      63: athrow
      64: ireturn

  static {};
    Code:
       0: new           #2                  // class Tetris
       3: dup
       4: invokespecial #419                // Method "<init>":()V
       7: putstatic     #422                // Field INSTANCE:LTetris;
      10: new           #65                 // class java/util/ArrayList
      13: dup
      14: invokespecial #423                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #17                 // class java/util/List
      20: putstatic     #15                 // Field winds:Ljava/util/List;
      23: iconst_1
      24: anewarray     #17                 // class java/util/List
      27: astore_0
      28: aload_0
      29: iconst_0
      30: bipush        7
      32: istore_1
      33: istore        8
      35: astore        7
      37: new           #65                 // class java/util/ArrayList
      40: dup
      41: iload_1
      42: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
      45: astore_2
      46: iconst_0
      47: istore_3
      48: iload_3
      49: iload_1
      50: if_icmpge     82
      53: iload_3
      54: istore        4
      56: aload_2
      57: iload         4
      59: istore        5
      61: astore        9
      63: iconst_0
      64: istore        6
      66: getstatic     #235                // Field Tetris$Cell.StableRock:LTetris$Cell;
      69: aload         9
      71: swap
      72: invokevirtual #336                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      75: pop
      76: iinc          3, 1
      79: goto          48
      82: aload_2
      83: checkcast     #17                 // class java/util/List
      86: astore        9
      88: aload         7
      90: iload         8
      92: aload         9
      94: aastore
      95: aload_0
      96: invokestatic  #427                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      99: putstatic     #225                // Field cells:Ljava/util/List;
     102: iconst_5
     103: anewarray     #270                // class Tetris$RockType
     106: astore_0
     107: aload_0
     108: iconst_0
     109: getstatic     #431                // Field Tetris$RockType.HLine:LTetris$RockType;
     112: aastore
     113: aload_0
     114: iconst_1
     115: getstatic     #434                // Field Tetris$RockType.Cross:LTetris$RockType;
     118: aastore
     119: aload_0
     120: iconst_2
     121: getstatic     #437                // Field Tetris$RockType.RightAngle:LTetris$RockType;
     124: aastore
     125: aload_0
     126: iconst_3
     127: getstatic     #440                // Field Tetris$RockType.VLine:LTetris$RockType;
     130: aastore
     131: aload_0
     132: iconst_4
     133: getstatic     #443                // Field Tetris$RockType.Square:LTetris$RockType;
     136: aastore
     137: aload_0
     138: invokestatic  #446                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     141: putstatic     #268                // Field rockTypes:Ljava/util/List;
     144: return
}


import java.lang.RuntimeException

fun main() {
    var result = 0
    for (group in readRucksack()) {
        result += charScore(findGroupBadge(group))
    }
    println("Total score: $result")
}

private typealias Group = MutableList<String>

private fun readRucksack(): Iterable<Group> {
    val result = mutableListOf<Group>()
    var group: Group
    generateSequence(::readLine).forEachIndexed { i, line ->
        if (i % 3 == 0) {
            group = mutableListOf()
            result.add(group)
        } else {
            group = result.last()
        }
        group.add(line)
    }
    return result.toList()
}

private fun findGroupBadge(group: Group): Char {
    val sets = group.map {
        it.toSet()
    }
    val commonChars = sets.reduce {chars, lineChars -> chars.intersect(lineChars)}
    if (commonChars.size != 1) {
        throw Error("Expected to find exactly one unique char")
    }
    return commonChars.first()
}

private fun charScore(char: Char) = when (char) {
    in 'a'..'z' -> {
        char.code - 'a'.code + 1
    }

    in 'A'..'Z' -> {
        char.code - 'A'.code + 27
    }

    else -> throw RuntimeException("Unexpected char $char")
}

Compiled from "Rucksack.kt"
public final class RucksackKt {
  public static final void main();
    Code:
       0: iconst_0
       1: istore_0
       2: invokestatic  #10                 // Method readRucksack:()Ljava/lang/Iterable;
       5: invokeinterface #16,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      10: astore_1
      11: aload_1
      12: invokeinterface #22,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      17: ifeq          43
      20: aload_1
      21: invokeinterface #26,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      26: checkcast     #28                 // class java/util/List
      29: astore_2
      30: iload_0
      31: aload_2
      32: invokestatic  #32                 // Method findGroupBadge:(Ljava/util/List;)C
      35: invokestatic  #36                 // Method charScore:(C)I
      38: iadd
      39: istore_0
      40: goto          11
      43: new           #38                 // class java/lang/StringBuilder
      46: dup
      47: invokespecial #41                 // Method java/lang/StringBuilder."<init>":()V
      50: ldc           #43                 // String Total score:
      52: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      55: iload_0
      56: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      59: invokevirtual #54                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      62: getstatic     #60                 // Field java/lang/System.out:Ljava/io/PrintStream;
      65: swap
      66: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      69: return

  private static final java.lang.Iterable<java.util.List<java.lang.String>> readRucksack();
    Code:
       0: new           #73                 // class java/util/ArrayList
       3: dup
       4: invokespecial #74                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #28                 // class java/util/List
      10: astore_0
      11: aconst_null
      12: astore_1
      13: getstatic     #80                 // Field RucksackKt$readRucksack$1.INSTANCE:LRucksackKt$readRucksack$1;
      16: checkcast     #82                 // class kotlin/jvm/functions/Function0
      19: invokestatic  #88                 // Method kotlin/sequences/SequencesKt.generateSequence:(Lkotlin/jvm/functions/Function0;)Lkotlin/sequences/Sequence;
      22: astore_2
      23: iconst_0
      24: istore_3
      25: iconst_0
      26: istore        4
      28: aload_2
      29: invokeinterface #91,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      34: astore        5
      36: aload         5
      38: invokeinterface #22,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      43: ifeq          135
      46: aload         5
      48: invokeinterface #26,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      53: astore        6
      55: iload         4
      57: iinc          4, 1
      60: istore        7
      62: iload         7
      64: ifge          70
      67: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      70: iload         7
      72: aload         6
      74: checkcast     #98                 // class java/lang/String
      77: astore        8
      79: istore        9
      81: iconst_0
      82: istore        10
      84: iload         9
      86: iconst_3
      87: irem
      88: ifne          113
      91: new           #73                 // class java/util/ArrayList
      94: dup
      95: invokespecial #74                 // Method java/util/ArrayList."<init>":()V
      98: checkcast     #28                 // class java/util/List
     101: astore_1
     102: aload_0
     103: aload_1
     104: invokeinterface #102,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     109: pop
     110: goto          118
     113: aload_0
     114: invokestatic  #106                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     117: astore_1
     118: aload_1
     119: checkcast     #28                 // class java/util/List
     122: aload         8
     124: invokeinterface #102,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     129: pop
     130: nop
     131: nop
     132: goto          36
     135: nop
     136: aload_0
     137: checkcast     #12                 // class java/lang/Iterable
     140: invokestatic  #110                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     143: checkcast     #12                 // class java/lang/Iterable
     146: areturn

  private static final char findGroupBadge(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #12                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #73                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #125                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #128                // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #130                // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #16,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #22,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          93
      50: aload         7
      52: invokeinterface #26,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #98                 // class java/lang/String
      66: astore        9
      68: astore        11
      70: iconst_0
      71: istore        10
      73: aload         9
      75: checkcast     #132                // class java/lang/CharSequence
      78: invokestatic  #138                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      81: aload         11
      83: swap
      84: invokeinterface #139,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      89: pop
      90: goto          40
      93: aload         5
      95: checkcast     #28                 // class java/util/List
      98: nop
      99: astore_1
     100: aload_1
     101: checkcast     #12                 // class java/lang/Iterable
     104: astore_3
     105: iconst_0
     106: istore        4
     108: aload_3
     109: invokeinterface #16,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     114: astore        5
     116: aload         5
     118: invokeinterface #22,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     123: ifne          136
     126: new           #141                // class java/lang/UnsupportedOperationException
     129: dup
     130: ldc           #143                // String Empty collection can\'t be reduced.
     132: invokespecial #146                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     135: athrow
     136: aload         5
     138: invokeinterface #26,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        6
     145: aload         5
     147: invokeinterface #22,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          195
     155: aload         6
     157: aload         5
     159: invokeinterface #26,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: checkcast     #148                // class java/util/Set
     167: astore        7
     169: checkcast     #148                // class java/util/Set
     172: astore        8
     174: iconst_0
     175: istore        9
     177: aload         8
     179: checkcast     #12                 // class java/lang/Iterable
     182: aload         7
     184: checkcast     #12                 // class java/lang/Iterable
     187: invokestatic  #152                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     190: astore        6
     192: goto          145
     195: aload         6
     197: checkcast     #148                // class java/util/Set
     200: astore_2
     201: aload_2
     202: invokeinterface #156,  1          // InterfaceMethod java/util/Set.size:()I
     207: iconst_1
     208: if_icmpeq     221
     211: new           #158                // class java/lang/Error
     214: dup
     215: ldc           #160                // String Expected to find exactly one unique char
     217: invokespecial #161                // Method java/lang/Error."<init>":(Ljava/lang/String;)V
     220: athrow
     221: aload_2
     222: checkcast     #12                 // class java/lang/Iterable
     225: invokestatic  #165                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
     228: checkcast     #167                // class java/lang/Character
     231: invokevirtual #171                // Method java/lang/Character.charValue:()C
     234: ireturn

  private static final int charScore(char);
    Code:
       0: iload_0
       1: istore_1
       2: bipush        97
       4: iload_1
       5: if_icmpgt     22
       8: iload_1
       9: bipush        123
      11: if_icmpge     18
      14: iconst_1
      15: goto          23
      18: iconst_0
      19: goto          23
      22: iconst_0
      23: ifeq          35
      26: iload_0
      27: bipush        97
      29: isub
      30: iconst_1
      31: iadd
      32: goto          96
      35: bipush        65
      37: iload_1
      38: if_icmpgt     55
      41: iload_1
      42: bipush        91
      44: if_icmpge     51
      47: iconst_1
      48: goto          56
      51: iconst_0
      52: goto          56
      55: iconst_0
      56: ifeq          69
      59: iload_0
      60: bipush        65
      62: isub
      63: bipush        27
      65: iadd
      66: goto          96
      69: new           #194                // class java/lang/RuntimeException
      72: dup
      73: new           #38                 // class java/lang/StringBuilder
      76: dup
      77: invokespecial #41                 // Method java/lang/StringBuilder."<init>":()V
      80: ldc           #196                // String Unexpected char
      82: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      85: iload_0
      86: invokevirtual #199                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      89: invokevirtual #54                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      92: invokespecial #200                // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
      95: athrow
      96: ireturn

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

Compiled from "Rucksack.kt"
final class RucksackKt$readRucksack$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {
  public static final RucksackKt$readRucksack$1 INSTANCE;

  RucksackKt$readRucksack$1();
    Code:
       0: aload_0
       1: iconst_0
       2: ldc           #11                 // class kotlin/io/ConsoleKt
       4: ldc           #13                 // String readLine
       6: ldc           #15                 // String readLine()Ljava/lang/String;
       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 java.lang.String invoke();
    Code:
       0: invokestatic  #24                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: areturn

  public java.lang.Object invoke();
    Code:
       0: aload_0
       1: invokevirtual #27                 // Method invoke:()Ljava/lang/String;
       4: areturn

  static {};
    Code:
       0: new           #2                  // class RucksackKt$readRucksack$1
       3: dup
       4: invokespecial #30                 // Method "<init>":()V
       7: putstatic     #33                 // Field INSTANCE:LRucksackKt$readRucksack$1;
      10: return
}