package net.ipipip0129.kotlin.yukicoder fun main(args: Array) { val line = readLine()!! val kusaList = getKusaList(line) if(kusaList.size != 0) { val maxCount = kusaList.maxBy { it.count }!!.count kusaList.forEach { if (it.count == maxCount) { println(it.str) } } } } private fun getKusaList(str: String): ArrayList { var left = 0 var right = 0 var count = 0 val kusaString = str + "終" val kusaList = ArrayList() kusaString.forEachIndexed { index, c -> run { when (c) { 'w' -> { if (right != 0) { count += 1 } } else -> { if (count != 0) { kusaList.add(Kusa(count, str.substring(left, right).replace("w", ""))) left = index count = 0 } right = index + 1 } } } } return kusaList } private class Kusa(val count: Int, val str: String)