import java.util.regex.Matcher import java.util.regex.Pattern fun main(args: Array) { fun readLineLongArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toLong() } return ret } fun readLineLong(): Long { val str = readLine() as String return str.toLong() } fun readLineInt(): Int { val str = readLine() as String return str.toInt() } fun readLineIntArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toInt() } return ret } fun readLineDoubleArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toDouble() } return ret } fun readLineDouble() : Double { val str = readLine() as String return str.toDouble() } fun readLineString() : String { return readLine() as String } // fun readLineStringArray(): List { // val str = readLine() as String // val arrStr = str.split(" ") // return arrStr // } val str = readLineString() var index = 0 var count = 0 var maxN = 0 val p : Pattern = Pattern.compile("w+") val m : Matcher = p.matcher(str) var list = arrayListOf() var lenList = arrayListOf() while (m.find()) { // println(m.group()) count = m.group().length if (maxN <= count) { list.add(str.substring(index,m.start())) lenList.add(count) maxN = count } index = m.end() } for ((i,item) in lenList.withIndex()) { if (item == maxN) { println(list[i]) } } }