{"lang": "Kotlin", "source_code": "package cf3\n\nimport kotlin.math.absoluteValue\n\nfun main() {\n val testcases = readLine()!!.toInt()\n repeat(testcases) {\n readLine()!!.toInt()\n val programmers = readLine()!!.split(\" \").map { it.toInt() }\n println(solve(programmers).joinToString(\" \"))\n }\n}\n\nprivate fun solve(programmers: List): List {\n val contributors = programmers.filter { it > 0 }\n val smallestContributor = contributors.min().takeIf { contributors.size > 1 }\n val smallestDistraction = programmers.filter { it < 0 }.max()\n\n val includeDistraction = smallestContributor == null || (smallestDistraction != null && smallestDistraction.absoluteValue < smallestContributor)\n\n var cut = false\n return programmers.map {\n when {\n includeDistraction && it == smallestDistraction && !cut -> 1.also { cut = true }\n it <= 0 -> 0\n !includeDistraction && it == smallestContributor && !cut -> 0.also { cut = true }\n else -> 1\n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "948550481371c78ad8010351998fad1e", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0), cout.tie(0);\n\n\n\n return 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a3a912f2050bdec368e7e2d4f4e728f6", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.Integer.max\nimport java.lang.Integer.min\nimport java.util.*\n\n\nfun main() {\n val t = readInt()\n repeat(t){\n val n = readInt()\n val a = readInts()\n val sor = a.withIndex().sortedByDescending { it.value }\n val res = Array(n){0}\n var sum = 0\n var mineg = -1\n var mimax = 0\n for(i in 0 until n){\n if(sor[i].value > 0 && ((i == n-1) || ( sor[i+1].value <= 0))) mimax = i\n if(sor[i].value < 0) {\n mineg = i\n break\n }\n }\n for(i in 0 until n){\n if(sor[i].value > 0) {\n res[sor[i].index] = 1\n sum += sor[i].value\n }\n }\n if(mineg >= 0 && (sor[mineg].value*-1 < sor[mimax].value)){\n res[mineg] = 1\n sum += sor[mineg].value\n } else {\n res[mimax] = 0\n sum -= sor[mimax].value\n }\n println(sum)\n for(i in 0 until n) if(res[i] > 0) print(\"1\") else print(\"0\")\n println()\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4619d3ae6d37812ecdf984d9fbfb123e", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "fun solve(inputReader: () -> String?, output: (String) -> Unit) {\n val testCaseCount = inputReader()!!.toInt()\n for(i in 0 until testCaseCount) {\n val developerCount = inputReader()!!.toInt()\n val developers = inputReader()!!.split(' ').map { it.toInt() }\n val maxSum = developers.filter { it > 0 }.sum()\n val greatestNegativeDeveloper = developers.filter { it < 0 }.max() ?: -Int.MAX_VALUE\n val weakestPositiveDeveloper = developers.filter { it > 0 }.min() ?: Int.MAX_VALUE\n if (Math.abs(greatestNegativeDeveloper) < weakestPositiveDeveloper) {\n var found = false;\n val answer = developers.joinToString(separator = \"\") {\n if (it > 0) {\n \"1\"\n } else {\n if (!found && greatestNegativeDeveloper == it) {\n found = true\n \"1\"\n } else {\n \"0\"\n }\n }\n }\n output((maxSum+greatestNegativeDeveloper).toString())\n output(answer)\n } else {\n var found = false;\n val answer = developers.joinToString(separator = \"\") {\n if (it > 0) {\n if (!found && weakestPositiveDeveloper == it) {\n found = true\n \"0\"\n } else {\n \"1\"\n }\n } else {\n \"0\"\n }\n }\n output((maxSum-weakestPositiveDeveloper).toString())\n output(answer)\n }\n }\n}\n\nfun main() {\n solved.solve(::readLine, ::println)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "907ace18e5848aa3b63f67b2c3c8be67", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "package Real\n\nfun main() {\n val count = readLine()!!.toLong()\n\n for (i in 0 until count) {\n val nums = readLine()!!.toLong()\n\n val dvs = readLine()!!.split(\" \").map { it.toLong() }\n val positiveList = dvs.withIndex().filter { it.value> 0 }.toMutableList()\n val max = positiveList.fold(0L) {acc,it-> acc+it.value }\n\n val minusMax = dvs.withIndex().filter { it.value < 0 }.maxBy {\n it.value\n }\n val positiveMin = positiveList.minBy { it.value }\n\n var result =max\n if(minusMax?.value ?: -9999999 < positiveMin?.value?.unaryMinus()?: -9999999){\n positiveMin?.index?.let{ positiveList.removeAt(it)}\n result += positiveMin?.value?.unaryMinus()?: -9999999\n }else{\n minusMax?.let{ positiveList.add(it)}\n result += minusMax?.value ?: -9999999\n }\n\n println(result)\n dvs.withIndex().forEach {\n if( positiveList.contains(it)) print(\"1\")\n else print(\"0\")\n }\n println()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "51811606af021bbd4535f50653fd8949", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "\n\nimport Advance.add\nimport java.util.*\nimport java.util.Collections.max\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.max\nimport kotlin.math.min\nimport kotlin.math.round\n\nfun rs() = readLine()!!\nfun ri() = rs().toInt()\nfun rsl() = rs().split(\" \")\nfun ril() = rsl().map{it.toInt()}\n\nfun main(args: Array)\n{\n var t = ri();\n while(t-->0)\n {\n val n=ri()\n val arr = ril()\n var maxneg = Int.MIN_VALUE\n var minpos = Int.MAX_VALUE\n var mpi = -1\n var mni = -1\n var sum = 0\n val brr = Array(n){0}\n for( i in 0..(n-1)){\n\n if(arr[i]<0){\n if(maxneg): List {\n val contributors = programmers.filter { it > 0 }\n val smallestContributor = contributors.min().takeIf { contributors.size > 1 }\n val smallestDistraction = programmers.filter { it < 0 }.max()\n\n val includeDistraction = smallestContributor == null || (smallestDistraction != null && smallestDistraction.absoluteValue < smallestContributor)\n\n var cut = false\n return programmers.map {\n when {\n includeDistraction && it == smallestDistraction && !cut -> 1.also { cut = true }\n it <= 0 -> 0\n !includeDistraction && it == smallestContributor && !cut -> 0.also { cut = true }\n else -> 1\n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "06b749ae03ae1e5dc9b0a903013ffa73", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "\n\nfun main() {\n val t = readLn().toInt()\n for (i in 0 until t) {\n val n = readLn().toInt()\n val ar = readIntList()\n go(ar, n)\n }\n}\n\nfun go(ar: List, n: Int) {\n var (greater, less) = ar.withIndex().partition { (i, v) -> v > 0 }\n less = less.filter { (i, v) -> v != 0 }\n var sum = greater.sumBy { (i, v) -> v }\n val maxNeg = less.maxBy { (i, v) -> v }\n val minPositive = greater.minBy { (i, v) -> v }!!\n\n\n val value = maxNeg?.value ?: 0\n val removeNeg = sum + value\n val removePosit = sum - minPositive.value\n\n val result = greater.toMutableList()\n if (maxNeg != null && removeNeg > removePosit) {\n result.add(maxNeg)\n println(removeNeg)\n } else {\n println(removePosit)\n result.remove(minPositive)\n }\n\n val toSet = result.map { (i, v) -> i }.toSet()\n for (i in 0 until n) {\n if (toSet.contains(i)) {\n print(1)\n } else {\n print(0)\n }\n }\n println()\n}\n\n\nvar debugEnabled = false\n\nfun readLn() = readLine()!!\n\nfun readIntList() = solved.readLn().split(' ').map { it.toInt() }\nfun readIntArray() = solved.readLn().split(' ').map { it.toInt() }.toIntArray()\nfun debLn(str: String) {\n if (solved.debugEnabled) {\n println(str)\n }\n}\n\nfun deb(str: String) {\n if (solved.debugEnabled) {\n print(str)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d298cf049c85964ff8596d93781c5282", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.test.assertTrue\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n val n = readInt()\n val aa = readInts()\n val aap = aa.filter { it > 0 }\n val perfect = aap.sum()\n val pmin = aap.min()!!\n val nmax = aa.filter { it < 0 }.max()\n if (nmax == null || pmin <= -nmax) {\n println(perfect - pmin)\n var removed = false\n for (a in aa) {\n if ((a > 0) && (removed || a != pmin)) {\n print(1)\n } else {\n print(0)\n }\n if (a == pmin) {\n removed = true\n }\n }\n }\n else {\n println(perfect+nmax)\n var added = false\n for (a in aa) {\n if (a > 0 || (!added && a == nmax)) {\n print(1)\n }\n else {\n print(0)\n }\n if (a == nmax) {\n added = true\n }\n }\n }\n println()\n}\n\nfun main() {\n val t = readInt()\n repeat(t) {\n solve()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "98a564d201e18a49f0b398184195d1f5", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "import solved.readLn\n\nfun main() {\n val t = readLn().toInt()\n for (i in 0 until t) {\n val n = readLn().toInt()\n val ar = readIntList()\n go(ar, n)\n }\n}\n\nfun go(ar: List, n: Int) {\n var (greater, less) = ar.withIndex().partition { (i, v) -> v > 0 }\n less = less.filter { (i, v) -> v != 0 }\n var sum = greater.sumBy { (i, v) -> v }\n val maxNeg = less.maxBy { (i, v) -> v }\n val minPositive = greater.minBy { (i, v) -> v }!!\n\n\n val value = maxNeg?.value ?: 0\n val removeNeg = sum + value\n val removePosit = sum - minPositive.value\n\n val result = greater.toMutableList()\n if (maxNeg != null && removeNeg > removePosit) {\n result.add(maxNeg)\n println(removeNeg)\n } else {\n println(removePosit)\n result.remove(minPositive)\n }\n\n val toSet = result.map { (i, v) -> i }.toSet()\n for (i in 0 until n) {\n if (toSet.contains(i)) {\n print(1)\n } else {\n print(0)\n }\n }\n println()\n}\n\n\nvar debugEnabled = false\n\nfun readLn() = readLine()!!\n\nfun readIntList() = solved.readLn().split(' ').map { it.toInt() }\nfun readIntArray() = solved.readLn().split(' ').map { it.toInt() }.toIntArray()\nfun debLn(str: String) {\n if (solved.debugEnabled) {\n println(str)\n }\n}\n\nfun deb(str: String) {\n if (solved.debugEnabled) {\n print(str)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "856b832a1295c93a49ccc953934253be", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\nval OUT = mutableListOf()\n\nfun solve() {\n var n = nextInt()\n var a = nextInts()\n var b = mutableListOf()\n var lo = 10000\n for (i in 0..n-1) {\n if (a[i] != 0) {\n lo = Math.min(lo, Math.max(a[i], -a[i]))\n }\n }\n var ans = \"0\".repeat(n)\n var tmp = StringBuilder(n)\n var fl = 0\n var sm = 0\n for (i in 0..n-1) {\n if (fl == 0 && (a[i] == lo || a[i] == -lo)) {\n if (a[i] != lo) {\n tmp[i] = \"1\"\n ans[i] = \"1\"\n sm += a[i]\n }\n fl = 1\n } else if (a[i] >= 0) {\n ans[i] = \"1\"\n sm += a[i]\n } else {\n }\n }\n OUT += \"$sm\\n$ans\"\n}\n\nfun main() {\n var T = nextInt()\n for (i in 1..T) {\n solve()\n }\n println(OUT.joinToString(\"\\n\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fe200f1de2fd10b0810ae8f7f0a82911", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.streams.asStream\n\nfun main() {\n val input = generateSequence(::readLine)\n input.asStream().skip(1).forEach { line ->\n println()\n val total = line.toInt()\n if (total % 2 != 0) print((total - 1) / 2) else print((total - 2) / 2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "80755276852a0317013b507ce5a4e24c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var t = readLine()!!.toInt() // read integer from the input\n while(t --) {\n var n = readLine()!!.toInt()\n var ans = max(0, n / 2 - 1)\n if(n > 0)\n ans += n % 2\n println(ans);\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6c52620f2a25324c87c6f8b8fe640be6", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(){\n val reader= Scanner(System.`in`)\n var t:Int\n var a:Int\n t=reader.nextInt()\n for (i in 0..t-1){\n a=reader.nextInt()\n println(\"${max(floor((a-1)/2), 0)}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a31d7bf0660357f8a9089086b27060a7", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n \nfun main() {\n val lines = readInt()\n for (line in 1..lines) {\n val number = readInts()\n println((number-1)//2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4e93d9ca490ba646ef45f2f2308d09a3", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ').map { it.toInt() }\n \nfun main() {\n val tests_cnt = readInts()\n for (i in 1..tests_cnt[0]) {\n val a = readInts()\n if(a > 2) println (a/2).toInt()\n else println 0\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aa64bb73e2f2b59f865f9a9d71314a7e", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package practice.five\n\nimport kotlin.math.roundToInt\n\nfun main() {\n val numTests = readLine()!!.toInt()\n repeat(numTests) {\n val numCandies = readLine()!!.toInt()\n println(distributeCandy(numCandies))\n }\n // listOf(7, 1, 2, 3, 2000000000, 763243547).forEach {\n // println(distributeCandy(it))\n // }\n}\n\nfun distributeCandy(count: Int): Int {\n val aliceMin = ((count.toDouble() / 2) + 0.5).roundToInt()\n return count - aliceMin\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "233671a1ae1415e58918be46cbed9549", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nval scan = Scanner(System.`in`)\nfun main() {\n\tval b = scan.nextInt()\n\tfor (i 1..b){\n\t val a = scan.nextInt()\n \tprint((a-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0f8895b421b55612290a96f0f90df111", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n \n val reader = Scanner(System.`in`)\n var t:Int = reader.nextInt()\n \n for(index in 1..t){\n \n var n:Int = reader.nextInt()\n var ans:Int\n if((n+1)/2>n/2){\n ans=n-(n+1)/2\n }else{\n ans=n-n/2-1\n }\n println(\"$sum\")\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0a94e1becdb96315003a57f28939b48b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package kotlinBasics\n\nfun main() {\n val n = readLine()!!.toInt()\n val a = IntArray(n)\n for (i in 0..a.lastIndex) {\n a[i] = readLine()!!.toInt()\n\n }\n for (i in 0..a.lastIndex) {\n var o = a[i] /2\n if (a[i] % 2 == 0) {\n println(o - 1)\n } else {\n println(o)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d4af201ffc0fd67a0e7b385be4df9952", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.AssertionError\n\nprivate fun readLn() = readLine()!! \nprivate fun readInt() = readLn().toInt() \nprivate fun readLong() = readLn().toLong() \nprivate fun readDouble() = readLn().toDouble() \nprivate fun readStrings() = readLn().split(\" \") \nprivate fun readInts() = readStrings().map { it.toInt() } \nprivate fun readLongs() = readStrings().map { it.toLong() }\nprivate fun readDoubles() = readStrings().map { it.toDouble() }\n\nprivate fun myAssert(x: Boolean) {\n if (!x) {\n throw AssertionError()\n }\n}\n\nfun main(args: Array) {\n var tt = readInt()\n for (qq in 0 until tt) {\n \n var (n) = readInt()\n var ans = 0\n if(n<=2) var=0\n else var=(n-1)/2 \n\n println(var)\n \n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0400a17d53162264d5fb5caec48969b7", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tval tests: Int = readLine()!!.toInt()\n\tif (tests in 1..10000) {\n\t\tval candies: Int = readLine()!!.toInt()\n\t\tvar noOFPossibilities: Int = 0\n\t\tif (candies >= 3 && candies <= (2 * (10.0f).pow(9))) {\n\t\t\tvar a: Int = candies - 1\n\t\t\tvar b: Int = 1\n\t\t\twhile (a + b == candies) {\n\t\t\t\tnoOFPossibilities += 1\n\t\t\t\ta -= 1\n\t\t\t\tb +=1\n\t\t\t}\n\t\t\tprintln(noOFPossibilities)\n\t\t} else {\n\t\t\tprintln(noOFPossibilities)\n\t\t}\n\t}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d8ae8690256259dbb90491e5316487f1", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.math.*\n \nfun main(args : Array) {\n val input = Scanner(System.`in`)\n val N = input.nextInt()\n for (i in 1..N) {\n val BB = input.nextInt()\n val A = BB-1\n val B = 1\n val count = 0\n while (A > B) {\n count += 1\n }\n println(count)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "16d5ac0525ea94f08b4e13555c4ac18b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ')\n \nfun main() {\n val tests_cnt = readInts().map { it.toInt() }\n for (i in 1..tests_cnt[0]) {\n val a = readInts().map { it.toBigInteger() }\n if(a > 2) println((a/2).toBigInteger())\n else println(0)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e8263b20d77f48b0d9ed01ba7aeb2128", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package dsa\n\nimport java.util.*\nimport kotlin.math.*\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\nfun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\nfun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\nfun Boolean.toInt() = if (this) 1 else 0\nval INF = 0x3f3f3f3f\nval MOD = (1e9 + 7).toLong()\n/***********************************************************************************************/\n\nfun main() {\n var t = readInt()\n for (i in 1..t) {\n var a: Int = readInt()\n var poss: Int = 0\n if (a % 2 == 0) {\n println(a / 2 - 1)\n } else {\n println(a / 2)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "39cafb3b60a780eb26d247d66a68102e", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n repeat(readLine()!!.toInt()) {\n val n = readLine()!!.toInt()\n var ans = 0\n if (n and 1) \n ans = n / 2\n else\n ans = n / 2 - 1\n if (ans < 0) ans = 0\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4003c5c291f00731a369fa6be5d379d4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n // Your code here!\n val reader = Scanner(System.`in`)\n var n:Int = reader.nextInt()\n \n while (n-- != 0) {\n var x:Int = reader.nextInt()\n if ((x.toDouble() / 2) != (x / 2)) {\n println(x / 2)\n } else {\n if (x / 2 == 0) {\n println(0)\n } else {\n println(x/2 - 1)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca93a9abcacb897d79d6b05cde366260", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n \nprivate fun min(a : Long , b : Long ) : Long\n{\n\tif(a < b)\n\t\treturn a;\n\telse \n\t\treturn b;\n}\n \nfun main(args: Array) {\n var q = readLine()!!.toLong();\n while(q --> 0)\n {\n \tn = readLine().toLong()\n \tprintln((n-1)/2)\n \n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9187d51890cc4c38bee1993fd4f5350b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n var t = read.nextInt()\n for (i in t) {\n var n = read.nextInt()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a2e2475ef713d9df10dd7e8ca9bad6b7", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var t = readLine()!!.toInt() // read integer from the input\n for(i in 0 until t) {\n var n = readLine()!!.toInt()\n var ans = max(0, n / 2 - 1)\n if(n > 0)\n ans += n % 2\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1e833a8f44be84b1158e9acf537b0d37", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var n = getInteger()\n for (i in 0 until n) {\n \tvar candies = getInteger()\n println(candies / 2 - (candies % 2) == 0 ? 1 : 0)\n }\n}\n\nfun getIntegers(): List {\n var input = (readLine()!!).split(' ')\n return input.map{it.toInt()}\n}\n \nfun getInteger(): Int {\n return (readLine()!!).toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d21e0cf3e44e197f34ca2cc588faa2c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\n/**\n * @author Ulire\n * @date 2020/11/12 13:28\n **/\n\nsuspend fun main() {\n val t =readLine()!!.toInt();\n IntRange(1,t).forEach { _ ->\n run {\n println(readLine()!!.toBigInteger().minus(BigInteger.ONE).divide(BigInteger.TWO))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9ffea59617ca173926c57311b58b35c3", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n \nfun main() {\n val lines = readInt()\n for (line in 1..lines) {\n val number = readInts()\n println((number-1)/2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d8ad4ca991a1e0956b41d7ff3050ab72", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val scanner = Scanner(System.`in`)\n val numberOfTestCases = scanner.nextInt()\n for (i in 0 until numberOfTestCases) {\n val numberOfCandies = scanner.nextInt()\n println(ceil(numberOfCandies / 2.0).toInt() - 1)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "56deab6293c2d123d4cef496896d75b9", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(){\n val input=Scanner(System.`in`)\n var t:Int=input.nextInt()\n while(t>0){\n var b:Double =input.nextDouble()\n var a:Int=(b/2).toInt()\n if(a*2==b){\n a-- \n println(\"$a\")\n } \n else{\n println(\"$a\")\n }\n t--\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4c57be07b5270a1c968ab93cc2bddca6", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.AssertionError\n\nprivate fun readLn() = readLine()!! \nprivate fun readInt() = readLn().toInt() \nprivate fun readLong() = readLn().toLong() \nprivate fun readDouble() = readLn().toDouble() \nprivate fun readStrings() = readLn().split(\" \") \nprivate fun readInts() = readStrings().map { it.toInt() } \nprivate fun readLongs() = readStrings().map { it.toLong() }\nprivate fun readDoubles() = readStrings().map { it.toDouble() }\n\nprivate fun myAssert(x: Boolean) {\n if (!x) {\n throw AssertionError()\n }\n}\n\nfun main(args: Array) {\n var tt = readInt()\n for (qq in 0 until tt) {\n \n var (n) = readInt()\n var ans = 0\n if(n<=2) ans=0\n else ans=(n-1)/2 \n\n println(ans)\n \n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4db0fe9db7725a1e3bfc8575f8401c39", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n \n val reader = Scanner(System.`in`)\n var t:Int = reader.nextInt()\n \n for(index in 1..t){\n \n var n:Int = reader.nextInt()\n var ans:Int\n if((n+1)/2>n/2){\n ans=n-(n+1)/2\n }else{\n ans=n-n/2-1\n }\n println(\"$ans\")\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "429147624e0ba5e27c11c7990f9e2732", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": " fun readInts() = readLine()!!.split(' ')\n \n fun main() {\n val tests_cnt = readInts().map { it.toInt() }\n for (i in 1..tests_cnt[0]) {\n val a = readInts().map { it.toBigInteger() }\n if(a[0] > 2.toBigInteger()) {\n if(a[0].mod(2) == 0) {\n println(a[0]/2.toBigInteger() - 1)\n } else {\n println(a[0]/2.toBigInteger())\n }\n } else {\n println(0)\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bfd833296dd0f2841b888f04612a0306", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package dsa\n\nimport java.util.*\nimport kotlin.math.*\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\nfun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\nfun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\nfun Boolean.toInt() = if (this) 1 else 0\nval INF = 0x3f3f3f3f\nval MOD = (1e9 + 7).toLong()\n/***********************************************************************************************/\n\nfun main() {\n var t = readInt()\n for (i in 1..t) {\n var a: Int = readInt()\n if (a % 2 == 0) {\n println(a / 2 - 1)\n } else {\n println(a / 2)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e98135ac4880ffee636a90b4f83a2614", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.Integer.*\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\nprivate fun readLongs() = readStrings().map { it.toLong() }\n\nfun solve(n: Int) {\n if (n%2 == 0) {\n println(max(n / 2 - 1, 0))\n } else {\n println(n/2)\n }\n}\n\nfun main() {\n val t = readInt()\n for(i in 0 until t) {\n val n = readInt()\n solve()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0afcadcd4fe2631c7e62a9bfbe30766e", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ').map { it.toInt() }\n \nfun main() {\n val tests_cnt = readInts()\n for (i in 1..tests_cnt[0]) {\n val a = readInts()\n if(a > 2) println((a/2).toInt())\n else println(0)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fe96999231dc031b2823dc65bebbbda4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject B {\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val t = sc.nextLine().toInt()\n for (i in 0 until t) {\n val x = sc.nextLine().toInt()\n if (x % 2 == 1) println(x / 2) else println(x / 2 - 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "00895ba2fab9c188d20afd31e1f85d3d", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n \nfun main() {\n val lines = readInt()\n for (line in 1..lines) {\n val number = readInts()\n println((number-1)/=2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b860679612178eb114a345adcefc8922", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val scanner = Scanner(System.`in`)\n var t: Int = readLine()!!.toInt()\n while (t-- > 0) {\n val num: Int = scanner.nextInt()\n if (num % 2 == 0) {\n println(\"${(num / 2) - 1}\")\n } else {\n println(\"${(num - 1) / 2}\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4226f6dd4f5504357e9b3a2b845bcaf1", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package b\n\nimport java.io.*\nimport java.util.*\n\nclass MyScanner(inputStream: InputStream) {\n private val br = BufferedReader(InputStreamReader(inputStream));\n private var st: StringTokenizer = StringTokenizer(br.readLine());\n\n fun next(): String {\n while (!st.hasMoreElements()) {\n st = StringTokenizer(br.readLine());\n }\n return st.nextToken();\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next());\n }\n\n fun nextLong(): Long {\n return next().toLong();\n }\n\n fun nextDouble(): Double {\n return next().toDouble();\n }\n\n fun nextLine(): String {\n return br.readLine();\n }\n}\n\nval In = MyScanner(System.`in`);\nval Out = PrintWriter(BufferedOutputStream(System.out))\n\nfun solve() {\n var t = In.nextInt();\n while (t-- > 0) {\n Out.println(\"${(In.nextInt() - 1) / 2}\")\n }\n}\n\nfun main() {\n solve()\n Out.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f9565002c3c7e735a8105a0c31a998c9", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfunc main()\n{\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n for(x in 0 until t)\n {\n val a = sc.nextInt()\n println((a-1)/2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb957fae5372961d5160cecac364ef9c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": " fun readInts() = readLine()!!.split(' ').map { it.toInt() }\n \n fun main() {\n val tests_cnt = readInts()\n for (i in 1..tests_cnt[0]) {\n val a = readInts()\n if(a[0] > 2) {\n if(a[0].mod(2) == 0) {\n println(a[0]/2 - 1)\n } else {\n println(a[0]/2)\n }\n } else {\n println(0)\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "240d05cb82b52cd8c78a2833a7308d43", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ').map { it.toBigDecimal() }\n \nfun main() {\n val tests_cnt = readInts()\n for (i in 1..tests_cnt[0]) {\n val a = readInts()\n if(a > 2) println((a/2).toInt())\n else println(0)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2914d1259fee834208b41dc496dc37b9", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ')\n \nfun main() {\n val tests_cnt = readInts().map { it.toInt() }\n for (i in 1..tests_cnt[0]) {\n val a = readInts().map { it.toBigDecimal() }\n if(a > 2) println((a/2).toInt())\n else println(0)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0b1fa0a1b801c6f7a5e1496a0e172b75", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n val read = Scanner(System.`in`)\n var t = read.nextInt()\n for (i in t) {\n var n = read.nextInt()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ffd2ad330af1244b48181824bab17f0e", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ')\n \nfun main() {\n val tests_cnt = readInts().map { it.toInt() }\n for (i in 1..tests_cnt[0]) {\n val a = readInts().map { it.toBigInteger() }\n if(a > 2) {\n println((a/2).toBigInteger())\n } else {\n println(0)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "297beb2a0b46b127f686c4a556ced6c2", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject main {\n fun main(arg: Array) {\n val `in` = Scanner(System.`in`)\n var t = `in`.nextInt()\n while (t-- > 0) {\n var n: Long\n n = `in`.nextLong()\n if (n % 2 == 0L) {\n println((n - 1) / 2)\n } else println(n / 2)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d701e3ab0b262190faade5d8206c79dd", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.math.*\n \nfun main(args : Array) {\n val input = Scanner(System.`in`)\n val N = input.nextInt()\n for (i in 1..N) {\n var BB = input.nextDouble()\n val save = BB\n if (BB % 2 == 0)\n BB += 1\n val A = Math.ceil(BB/2)\n println(save - A)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ccf869a678e0789175999cbb6f71e808", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val t = readline()\n for (i in t)\n println(\"Hello World!\") {\n val n = readline()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eb3e785e3107ed49fd0f67fb2900385b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": " fun readInts() = readLine()!!.split(' ')\n \n fun main() {\n val tests_cnt = readInts().map { it.toInt() }\n for (i in 1..tests_cnt[0]) {\n val a = readInts().map { it.toBigInteger() }\n if(a[0] > 2.toBigInteger()) {\n if(a[0] % 2 == 0) {\n println(a[0]/2.toBigInteger() - 1)\n } else {\n println(a[0]/2.toBigInteger())\n }\n } else {\n println(0)\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2d33e25efb9edb92afce86737f7e8e1f", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args: Array) {\n val t = Scanner(System.`in`)\n for (i in t) {\n val n = Scanner(System.`in`)\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4076ee3f11eb1a32f23b9fa698574c5b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var n = getInteger()\n for (i in 0 until n) {\n \tvar candies = getInteger()\n println(candies / 2 - !(candies % 2)\n }\n}\n\nfun getIntegers() {\n var input = (readLine()!!).split(' ')\n \treturn input.map{it.toInt()}\n}\n\nfun getInteger() {\n return (readLine()!!).toInt()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b4813bbbfaf7b1a5ef621a51af7261c4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject B {\n @JvmStatic\n fun main(args: Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n for (i in 0 until n) {\n val t = `in`.nextLong()\n if (t <= 2) {\n println(0)\n } else {\n println(if (t % 2 == 0L) t / 2 - 1 else t / 2)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "836bb7d1c5d0602c63ae375b46af662c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var n = getInteger()\n for (i in 0 until n) {\n \tvar candies = getInteger()\n println(candies / 2 - !(candies % 2))\n }\n}\n\nfun getIntegers() {\n var input = (readLine()!!).split(' ')\n \treturn input.map{it.toInt()}\n}\n\nfun getInteger() {\n return (readLine()!!).toInt()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d08aac185199b0483a137921f9f3dbf4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val testsNum : Int = readLine()?.toIntOrNull() ?: -1\n for(testId in 1..testsNum){\n val testInput = readLine() ?: \"\"\n val sweetsNum = testInput.toLong()\n val result = ceil(sweetsNum.toDouble()/2).toInt() -1\n println(result)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "db3136392a9b3d473c305bd84dd33461", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.math.*\n \nfun main(args : Array) {\n val input = Scanner(System.`in`)\n val N = input.nextInt()\n for (i in 1..N) {\n var BB = input.nextFloat()\n val save = BB\n if (BB % 2 == 0)\n BB += 1\n val A = ceil(BB/2)\n println(save - A)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ff9f00b8962a8d45b4fe1353bee02a99", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val t = readline()!!\n for (i in t)\n println(\"Hello World!\") {\n val n = readline()!!\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2f0555186ce672acb36cdd8aca6e3c12", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine().toInt()\n for (i in 0 until n) {\n main2(readLine().toInt())\n }\n}\n\nfun main2(candies:Int){\n val half = candies/2\n println(half)\n println(Integer.max(0,half + half%2 - 2))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1830b41b023f5c063d004c84030b82a6", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "solution.kt", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c63a0e71c4dca9d404f4659e842eecc4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val t = Scanner(System.`in`)\n for (i in t) {\n val n = Scanner(System.`in`)\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "06b6ec8b298cc47c9c615a19a708ed5f", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package practice.taskB\n\nfun main() {\n\tval t = readInt()\n\tfor (i in 1..t) {\n\t\tval n = readInt()\n\t\tval r = (n - 1) / 2\n\t\tprintln(r)\n\t}\n}\n\nfun readInt() = readLine()!!.toInt()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d53ec770e879de2f4cbb99391986c248", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(){\n val sc = Scanner(System.`in`)\n\n var t = sc.readInt()\n\n while(t > 0){\n val a:Int = sc.nextInt()\n\n print((a+1)/2)\n\n t = t-1\n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "27b30590f110883432d3d06ae8312bc2", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Main {\n @JvmStatic\n fun programkt(args: Array) {\n val scanner = Scanner(System.`in`)\n var t = scanner.nextInt()\n while (t-- > 0) {\n val n = Math.max(0, scanner.nextInt() - 2)\n println(n - 2 - (n - 2) / 2)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d94d9cf30d0028a6bf0458d04de7a8c6", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.math.*\n \nfun main(args : Array) {\n val input = Scanner(System.`in`)\n val N = input.nextInt()\n for (i in 1..N) {\n var BB = input.nextFloat()\n val save = BB\n if (BB % 2 == 0)\n BB += 1\n val A = Math.ceil(BB/2)\n println(save - A)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d440ae88f2122d5cc764e4f93b2d1c51", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(){\n val sc = Scanner(System.`in`)\n\n var t = sc.readInt()\n\n while(t > 0){\n val a:Int = sc.readInt()\n\n print((a+1)/2)\n\n t = t-1\n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7ba6cf083ae665fffdcb1fc726c31541", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun one() {\n var n = readInt()\n \n var ans = n%2==0 ? (n-1 - n/2) : (n- n/2);\n\n println(max(0,ans)) \n}\n\nfun main() {\n var t = readInt()\n \n for (i in 1..t) one()\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c53322e7580156ce4e51538e6820ddfb", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun one() {\n var n = readInt()\n \n var ans = if (n%2==0) { (n-1 - n/2) } else{ (n- n/2) }\n\n println(max(0,ans)) \n}\n\nfun main() {\n var t = readInt()\n \n for (i in 1..t) one()\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "da1248c79a660cdec068c48e8280ea9d", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args: Array)\n{\n val sc = Scanner(System.in)\n var t: Int\n var n: Int\n var x: Int\n \n while(t-- > 0)\n {\n n=sc.nextInt()\n x=(n-1)/2\n println(\"$x\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4e0cc58c1ef3457485df6194f2e1c7de", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "readLine()?.toInt()?.let { t ->\n repeat(t){\n readLine()?.toInt()?.let {n ->\n val b = n/2\n val a = n-b\n when {\n a == b -> {\n println(b-1)\n }\n a > b -> {\n println(b)\n }\n else -> {\n println(0)\n }\n }\n\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ec0867255587ccef07963d0a7ac992a7", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n \nfun main(){\n var t = readInt()\n while(t-- > 0){\n var (a) = readInts()\n val x = a/2\n val y = a%2\n val sum = x - y + 1\n println($sum)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "80a0c8bd4b9795b4ebb619166857c887", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package com.mmk\n\nfun main() {\n val firstLine= readInt()\n for(i in 0 until firstLine){\n val n= readInt()\n var a=n\n var b=0\n var count=0\n while(a>b){\n a--\n b++\n if (a>0 && b>0 && a>b)\n count++\n }\n println(count)\n }\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cca7d5411cbe4074835fdd4d68ddfd4e", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval reader = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun readLn() = reader.readLine()\nfun readInt() = readLn().toInt()\nfun readLong() = readLn().toLong()\nfun readDouble() = readLn().toDouble()\n\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readDoubles() = readStrings().map { it.toDouble() }\n\nfun readIntArrays(vararg arrays: IntArray) {\n for (i in 0 until arrays[0].size) {\n for (j in arrays.indices) {\n arrays[j][i] = readInt()\n }\n }\n}\n\nfun main() {\n solve()\n reader.close()\n out.close()\n}\n\nmain()\n\n\nfun solve() {\n for (ii in 0 until readInt()){\n var n = readInt()\n var ans = if (n < 3) 0 else (n-1)/2\n out.println(ans)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "319bcd0bb6450ca706df549c0cdf64fd", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var t = read.nextInt()\n for (i in t) {\n var n = read.nextInt()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2d24f43e1cc5bb816bdb8347d45d0eb5", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": " fun main(args: Array) {\n var T: Int\n val scanner = Scanner(System.`in`)\n T = scanner.nextInt()\n while (T-- > 0) {\n var n = scanner.nextInt()\n if (n < 2) n = 2\n println((n - 1) / 2)\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0d9cf9fa581f982b8d9c6b0c475aaa09", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val tests = readLine().toInt()\n for (i in 0 until tests) {\n val nr = readLine().toInt()\n val ats = (nr-1)/2\n println(ats)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fb63a86ac29a70a932b1d2f4839ec477", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.time.seconds\n\nfun main(){\n val t = readLine()!!.toInt()\n for (i in 1..t){\n var (n,k) = readLine()!!.split(\" \").map { it.toLong() }\n val array = readLine()!!.split(\" \")\n .mapIndexed { index, s ->\n Pair(index, s.toLong())\n }.sortedBy { it.second }\n var max = array.last().second\n val sum = array.map { it.second }.sum()\n var mbMax = (2*(sum+k)+array.size*array.size-1)/(2*array.size)\n if ((2*(sum+k)+array.size*array.size-1)%(2*array.size)!=0L){\n mbMax++\n }\n max = maxOf(mbMax, max)\n var newArray = Array(n.toInt()){\n max+it-n+1\n }\n var length = newArray.sum()-sum-k\n newArray.mapIndexed { index, i ->\n if (i-array[index].second>length){\n val m = length\n length=0\n i-m\n }\n else{\n length-=i-array[index].second\n array[index].second\n }\n }.apply {\n Array(n.toInt()) { index ->\n val ind = array.indexOfFirst { it.first == index }\n this[ind] - array[ind].second\n }.forEach { print(\"$it \") }\n println()\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "97a7264500b49f83161dfc3236903bb1", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.lang.Math.min\nimport java.util.*\n\nfun solve() {\n val t = round3.c.ni()\n for(i in 1..t){\n go()\n }\n}\n\nfun go() {\n var (n, K) = na()\n var a = na()\n var ai: MutableList = mutableListOf()\n for(i in 0..n-1){\n ai.add(intArrayOf(a[i], i, 0))\n }\n ai.sortBy{ it[0] }\n for(i in n-2 downTo 0){\n ai[i][2] = min(K, ai[n-1][0] - ai[i][0] - (n-1-i))\n K -= ai[i][2]\n }\n if(K > 0){\n val plus = (K+n-1)/n\n for(i in 0..n-1){\n ai[i][2] += K/n\n if(n-i <= K%n){\n ai[i][2] += 1\n }\n }\n }\n ai.sortBy{ it[1] }\n for(i in 0..n-1){\n out.print(ai[i][2])\n out.print(\" \")\n }\n out.println()\n\n// out.println(ai)\n}\n\nval out = PrintWriter(System.out)\n\nfun main(args: Array) {\n solve()\n out.flush()\n}\n\nfun nline() = readLine()!!\nfun ni() = nline().toInt()\nfun nl() = nline().toLong()\nfun nd() = nline().toDouble()\nfun nas() = nline().split(\" \")\nfun na() = nas().map { it.toInt() }\nfun nal() = nas().map { it.toLong() }\n\nfun tr(x: Any) = System.err.println(x)\nfun tr(x: IntArray) = System.err.println(Arrays.toString(x))\nfun tr(x: Array) = System.err.println(Arrays.deepToString(x))\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "29581e11e9fee3007d5d98b565fd86a8", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.Arrays\nimport java.io.UncheckedIOException\nimport java.io.Closeable\nimport java.io.Writer\nimport java.io.OutputStreamWriter\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject programkt {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = DBonusDistribution()\n val testCount = Integer.parseInt(`in`.next())\n for (i in 1..testCount)\n solver.solve(i, `in`, out)\n out.close()\n }\n }\n\n internal class DBonusDistribution {\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val n = `in`.readInt()\n var k = `in`.readInt()\n val a = IntArray(n)\n val index = arrayOfNulls(n)\n for (i in 0 until n) {\n a[i] = `in`.readInt()\n index[i] = i\n }\n Arrays.sort(index) { i, j -> -Integer.compare(a[i], a[j]) }\n val dist = IntArray(n)\n for (i in 1 until n) {\n var allow = a[index[i - 1]] - 1 - a[index[i]]\n allow = Math.min(k, allow)\n k -= allow\n a[index[i]] += allow\n dist[index[i]] = allow\n }\n val avg = k / n\n for (i in 0 until n) {\n dist[index[i]] += avg\n }\n val remain = k % n\n for (i in 0 until remain) {\n dist[index[i]]++\n }\n\n for (d in dist) {\n out.append(d).append(' ')\n }\n out.println()\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val defaultStringBuf = StringBuilder(1 shl 13)\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n operator fun next(): String {\n return readString()\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n fun readString(builder: StringBuilder): String {\n skipBlank()\n\n while (next > 32) {\n builder.append(next.toChar())\n next = read()\n }\n\n return builder.toString()\n }\n\n fun readString(): String {\n defaultStringBuf.setLength(0)\n return readString(defaultStringBuf)\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4ff87e6225462813502ff5cb572696e0", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "package com.happypeople.codeforces.c1297\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n D1297().run()\n } catch (e: Throwable) {\n println(\"\")\n }\n}\n\nclass D1297 {\n fun run() {\n val sc = Scanner(systemIn())\n val t=sc.nextInt()\n (1..t).forEach { solve(sc) }\n }\n\n fun solve(sc : Scanner) {\n val n=sc.nextInt()\n val k=sc.nextInt()\n val a=(1..n).map { Pair(sc.nextInt(), it) }.sortedBy { -it.first }\n /* Pay the second one max possible d, the third one max possible...\n * if still d available, distribute equal among all, starting with higest\n **/\n\n val ans=IntArray(n)\n var d=0\n (1..n-1).forEach {\n val diff=a[it-1].first - a[it].first\n if(diff>1) {\n if(diff < k-d)\n ans[it]=diff\n else\n ans[it]=k-d\n } else\n ans[it]=0\n\n d+=ans[it]\n }\n\n val v=(k-d)/n\n if(v>0) {\n (0..n - 1).forEach {\n ans[it] +=v\n d+=v\n }\n }\n (1..(k-d)).forEach {\n ans[it-1]++\n }\n\n (0..n-1).map {\n Pair(ans[it], a[it].second)\n }.sortedBy { it.second }.forEach {\n print(\"${it.first} \")\n }\n println()\n }\n\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "338aa0946930805dbbaed32c7773494a", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "\n\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.Random\nimport java.io.UncheckedIOException\nimport java.io.Closeable\nimport java.io.Writer\nimport java.io.OutputStreamWriter\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject programkt {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = DBonusDistribution()\n val testCount = Integer.parseInt(`in`.next())\n for (i in 1..testCount)\n solver.solve(i, `in`, out)\n out.close()\n }\n }\n\n internal class DBonusDistribution {\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val n = `in`.readInt()\n var k = `in`.readInt()\n val a = IntArray(n)\n val index = IntArray(n)\n for (i in 0 until n) {\n a[i] = `in`.readInt()\n index[i] = i\n }\n CompareUtils.quickSort(index, { i, j -> -Integer.compare(a[i], a[j]) }, 0, n)\n val dist = IntArray(n)\n for (i in 1 until n) {\n var allow = a[index[i - 1]] - 1 - a[index[i]]\n allow = Math.min(k, allow)\n k -= allow\n a[index[i]] += allow\n dist[index[i]] = allow\n }\n val avg = k / n\n for (i in 0 until n) {\n dist[index[i]] += avg\n }\n val remain = k % n\n for (i in 0 until remain) {\n dist[index[i]]++\n }\n\n for (d in dist) {\n out.append(d).append(' ')\n }\n out.println()\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal object Randomized {\n private val random = Random(0)\n\n fun nextInt(l: Int, r: Int): Int {\n return random.nextInt(r - l + 1) + l\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val defaultStringBuf = StringBuilder(1 shl 13)\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n operator fun next(): String {\n return readString()\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n fun readString(builder: StringBuilder): String {\n skipBlank()\n\n while (next > 32) {\n builder.append(next.toChar())\n next = read()\n }\n\n return builder.toString()\n }\n\n fun readString(): String {\n defaultStringBuf.setLength(0)\n return readString(defaultStringBuf)\n }\n\n }\n\n internal interface IntComparator {\n fun compare(a: Int, b: Int): Int\n\n }\n\n internal object SequenceUtils {\n fun swap(data: IntArray, i: Int, j: Int) {\n val tmp = data[i]\n data[i] = data[j]\n data[j] = tmp\n }\n\n }\n\n internal object CompareUtils {\n private val THRESHOLD = 4\n\n fun insertSort(data: IntArray, cmp: IntComparator, l: Int, r: Int) {\n for (i in l + 1..r) {\n var j = i\n val `val` = data[i]\n while (j > l && cmp.compare(data[j - 1], `val`) > 0) {\n data[j] = data[j - 1]\n j--\n }\n data[j] = `val`\n }\n }\n\n fun quickSort(data: IntArray, cmp: IntComparator, f: Int, t: Int) {\n if (t - f <= THRESHOLD) {\n insertSort(data, cmp, f, t - 1)\n return\n }\n SequenceUtils.swap(data, f, Randomized.nextInt(f, t - 1))\n var l = f\n var r = t\n var m = l + 1\n while (m < r) {\n val c = cmp.compare(data[m], data[l])\n if (c == 0) {\n m++\n } else if (c < 0) {\n SequenceUtils.swap(data, l, m)\n l++\n m++\n } else {\n SequenceUtils.swap(data, m, --r)\n }\n }\n quickSort(data, cmp, f, l)\n quickSort(data, cmp, m, t)\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2f78dbf638f03d7a2c25fb1987f73790", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\n\nfun main(args: Array) {\n var tc = nextInt()\n while (tc > 0) {\n var (n,k) = nextInts()\n val data = ArrayList(nextLongs())\n\n var datas = ArrayList< Pair >()\n var ans = ArrayList()\n\n var idx = 0\n for (x in data) {\n datas.add(Pair(x, idx))\n ans.add(0)\n idx += 1\n }\n\n datas = ArrayList(datas.sortedBy { it.first })\n\n\n var l : Long = 0\n var r : Long= 2000000000\n var ret : Long= r+1\n\n var cnt = 0\n \n idx = 0\n while(idx < n){\n data[datas[idx].second] -= cnt.toLong()\n cnt+=1\n idx+=1\n }\n\n\n\n while(l <= r){\n var mid : Long= l + (r-l)/2;\n var evalu : Long = 0 \n for (x in data){\n if(x > mid){\n continue\n } else {\n evalu += mid - x\n }\n }\n if(evalu < k){\n l = mid+1\n } else {\n r = mid-1\n ret = mid\n }\n }\n\n idx = n-1\n while(idx >= 0){\n if(data[datas[idx].second] >= ret){\n idx-=1\n } else {\n var sisa = k\n if((ret - data[datas[idx].second]) <= sisa) sisa = (ret - data[datas[idx].second]).toInt()\n ans[datas[idx].second] = sisa.toLong()\n k -= sisa\n idx-=1\n }\n }\n\n var before = -1\n for (x in ans) {\n if (before != -1) print(\" \")\n print(x)\n before = x\n }\n println(\"\")\n\n tc = tc - 1\n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5ca1aff330c92beab6a9c43afa7e136c", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.math.min\nimport kotlin.test.fail\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var (n,k) = readInts()\n val aa = readInts().withIndex().sortedBy { (_,a) -> a }\n val dd = IntArray(n)\n dd[n-1] = 0\n for (i in n-2 downTo 0) {\n val (ai, a) = aa[i]\n val (ain, an) = aa[i+1]\n dd[ai] = minOf(k, an + dd[ain] - a -1)\n k -= dd[ai]\n if (k == 0) {\n break\n }\n }\n if (k > 0) {\n val inc = k/n\n val rem = k%n\n for (i in 0 until n-rem) {\n val (ai, _) = aa[i]\n dd[ai] += inc\n }\n for (i in n-rem until n) {\n val (ai, _) = aa[i]\n dd[ai] += inc+1\n }\n }\n println(dd.joinToString(\" \"))\n}\n\nfun main() {\n val t = readInt()\n repeat(t) {\n solve()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e796a70229c5b80abfb8e3a3a7576da5", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.time.seconds\n\nfun myread() = readLine()!!\nfun readint() = myread().toInt()\nfun readLong() = myread().toLong()\nfun readints() = myread().split(\" \").map{it.toInt()}\nfun readLongs() = myread().split(\" \").map{it.toLong()}\n\nfun main() {\n val t = readint()\n for(i in 1 .. t){\n val (n,k) = readints()\n var a = readints()\n var v = mutableListOf>()\n for(j in 0 .. (n-1)){\n v.add(Pair(j,a[j]))\n }\n v.sortBy { it.second }\n v.reverse()\n var l = v[0].second\n var r = v[0].second + k\n while(l!=r){\n var m = l / 2 + r / 2\n if(l%2==1 && r%2==1)m++\n var tk = 0\n for(j in 0 .. (n-1)){\n tk += (m-j) - v[j].second\n }\n if(tk >= k){\n r = m\n } else{\n l = m + 1\n }\n }\n var tk = k\n var ans = IntArray(n)\n for(j in 0 .. (n-1)){\n if(tk > (l-j)-v[j].second) {\n ans[v[j].first] = (l-j)-v[j].second\n tk -= (l-j)-v[j].second\n } else {\n ans[v[j].first] = tk\n tk = 0\n }\n }\n for(j in 0 .. (n-1)){\n if(j > 0)print(\" \")\n print(ans[j])\n }\n println(\"\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c74df79169d5f31895ff97f3feb92b51", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.IllegalArgumentException\nimport java.lang.StringBuilder\nimport java.util.*;\nimport kotlin.Comparator\n\nimport kotlin.collections.ArrayList\nimport kotlin.math.*;\nimport kotlin.system.exitProcess\nimport kotlin.collections.*\nimport kotlin.time.seconds\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\nclass Bit(var n:Int) {\n var a = ArrayList()\n init {\n a.resize(n+1,0);\n }\n fun clear(m:Int) {\n n = m\n a.resize(n+1,0)\n }\n fun add(x:Int,v:Long) {\n var p = x\n while(p<=n) {\n a[p] += v\n p += p and -p\n }\n }\n fun sum(x:Int) : Long {\n var ans : Long = 0\n var p = x\n while(p>0) {\n ans += a[p]\n p -= p and -p\n }\n return ans\n }\n}\n\n\nfun lower_bound(a:ArrayList, l:Int, r:Int , x:Int ): Int {\n var L=l-1\n var R=r-1\n while(R-L>1) {\n var mid = (L+R)/2\n if(a[mid]>=x) R=mid\n else L=mid\n }\n return R\n}\n\nfun ArrayList.resize(n:Int, v:T) {\n this.clear()\n for(i in 0..n-1) this.add(v)\n}\n\n//---------------------------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------------------------\n\nclass PI (val first:Long,val second:Int):Comparable {\n override fun compareTo(other: PI): Int {\n if(first==other.first) return second.compareTo(other.second)\n return first.compareTo(other.first)\n }\n}\n\nvar n = 0\nvar k = 0\nvar a = ArrayList()\n\nfun ok(m: Long):Boolean {\n var K:Long = k.toLong()\n var pre = m\n K -= m-a[0]\n if(K<=0) return true\n for(i in 1..n-1) {\n var add = min(K,pre-1-a[i])\n K -= add\n pre = a[i]+add\n }\n return K<=0\n}\n\nfun main () {\n var T = readInt()\n repeat(T) {\n val (nn,kk) = readInts()\n n = nn\n k = kk\n a.clear()\n var b = readLongs()\n var o = ArrayList()\n for(i in 0..n-1) {\n a.add(b[i])\n o.add(PI(b[i],i))\n }\n Collections.sort(a)\n Collections.reverse(a)\n\n Collections.sort(o)\n Collections.reverse(o)\n\n var L :Long = (a[0]-1).toLong()\n var R : Long = 3000000000\n while(R-L>1) {\n var mid = (L+R)/2\n if(ok(mid)) R=mid\n else L = mid\n }\n var ans = ArrayList()\n ans.resize(n,0)\n var K = k-(R-a[0])\n ans[o[0].second] = R-a[0]\n var pre = R\n\n for(i in 1..n-1) {\n val add = min(K,pre-1-a[i])\n K -= add\n ans[o[i].second] = add\n pre = o[i].first + add\n }\n //println(R-a[0])\n for(x in ans) print(\"$x \")\n println()\n }\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5d2ce5ea7bc2cbb7c0e17185723f05fe", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "fun spreadUnequalAmong(remaining: Int, n: Int, bonuses: MutableList) {\n val delta = remaining / n\n val r = remaining % n\n for (i in 0 until n) bonuses[i] += delta\n for (i in 1..r) bonuses[n - i] += 1\n}\n\nfun main() {\n val tasks = readLine()!!.toInt()\n repeat(tasks) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val salaries = readLine()!!.split(\" \").map { it.toInt() }.withIndex().sortedBy { it.value }\n check(salaries.size == n)\n\n val sv = salaries.map { it.value }\n\n var remaining = k\n val bonuses = MutableList(n) { 0 }\n for (i in 0..salaries.lastIndex - 1) {\n val delta = sv[i + 1] - sv[i] - 1\n val deduction = delta * (i + 1)\n when {\n deduction == 0 -> continue\n deduction <= remaining -> {\n remaining -= deduction\n for (j in 0..i) bonuses[j] += delta\n }\n else -> {\n spreadUnequalAmong(remaining, i + 1, bonuses)\n remaining = 0\n }\n }\n if (remaining == 0) break\n }\n if (remaining > 0) {\n spreadUnequalAmong(remaining, n, bonuses)\n }\n check(bonuses.sum() == k)\n val ibonuses = salaries.zip(bonuses) { (index, s), b ->\n// println(\"$index:\\t$s\\t+\\t$b =\\t${s + b}\")\n IndexedValue(index, b)\n }\n println(ibonuses.sortedBy { it.index }.map { it.value }.joinToString(\" \"))\n// println()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9dcdb317ef6b4b8bda2cd8f28d78d95e", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "package org.ehmeed.competitive.kotlinheroes.third\n\n\nprivate fun main() {\n solve(StdInput)\n// solveTestInputs()\n}\n\ndata class Employee(val index: Int, val salary: Int)\n\nprivate fun solve(input: Input) {\n val cases = input.nextLine().toInt()\n repeat(cases) {\n val (employeesCount, totalBonus) = input.nextLine().toInts()\n val employees = input.nextLine().toInts().mapIndexed { index, salary -> Employee(index, salary) }.sortedByDescending { it.salary } //different\n val bonuses = Array(employeesCount) { 0 }\n\n var bonusLeft = totalBonus\n var currentEmployeeIndex = 1\n while (bonusLeft > 0) {\n if (currentEmployeeIndex == employees.lastIndex + 1) {\n currentEmployeeIndex = 0\n while (bonusLeft > 0) {\n bonuses[employees[currentEmployeeIndex].index] += 1\n bonusLeft -= 1\n currentEmployeeIndex += 1\n if (currentEmployeeIndex == employees.lastIndex + 1) currentEmployeeIndex = 0\n }\n }\n val prevEmployee = employees[currentEmployeeIndex - 1]\n val previousEsalary = prevEmployee.salary + bonuses[prevEmployee.index]\n val currEsalary = employees[currentEmployeeIndex].salary + bonuses[employees[currentEmployeeIndex].index]\n val diff = (previousEsalary - currEsalary - 1).coerceAtMost(bonusLeft)\n\n bonuses[employees[currentEmployeeIndex].index] += diff\n bonusLeft -= diff\n currentEmployeeIndex += 1\n }\n println(bonuses.joinToString(\" \"))\n }\n}\n\n// test inputs\nprivate fun solveTestInputs() {\n listOf(\n \"\"\"\n5\n4 1\n3 1 4 2\n2 3\n10 2\n4 1000000000\n987654321 1000000000 999999999 500000000\n8 9\n5 6 1 8 3 4 2 7\n6 1\n6 3 1 8 5 9\n\n \"\"\",\n \"\"\"\n\n \"\"\",\n \"\"\"\n \n \"\"\"\n )\n .filter { it.isNotBlank() }\n .map { it.trimIndent().trimEnd() }\n .map { it.asTestInput() }\n .mapIndexed(::solveTestInput)\n\n}\n\n\nprivate const val DELIMITER = \"----------------------------------------------\"\nprivate fun solveTestInput(index: Int, input: TestInput) {\n println(\"$DELIMITER INPUT: $index $DELIMITER\")\n println(input.input)\n println(\"$DELIMITER SOLUTION: $index $DELIMITER\")\n solve(input)\n}\n\nprivate fun String.toInts() = split(\" \").map { it.toInt() }\n\n\nprivate interface Input {\n fun nextLine(): String\n}\n\nprivate object StdInput : Input {\n override fun nextLine(): String = readLine()!!\n}\n\nprivate class TestInput(val input: String) : Input {\n private val iterator = input.split('\\n').iterator()\n override fun nextLine(): String = iterator.next()\n}\n\nprivate fun String.asTestInput() = TestInput(this)\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2c7f9f07801a22d5e1ffb64e688ab91a", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream: OutputStream = System.out\n val `in` = InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val solver = Task()\n var tc = `in`.nextInt()\n while (tc-- > 0) {\n solver.solve(1, `in`, out)\n }\n out.close()\n }\n\n internal class Task {\n internal inner class Pair(var a: Int, var b: Int) : Comparable {\n override fun compareTo(other: Pair): Int {\n if (a == other.a) return 0\n return if (a > other.a) 1 else -1\n }\n\n }\n\n fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {\n val n = `in`.nextInt()\n val k = `in`.nextInt()\n val org = IntArray(n)\n val s = arrayOfNulls(n)\n for (i in 0 until n) {\n val `val` = `in`.nextInt()\n org[i] = `val`\n s[i] = Pair(`val`, i)\n }\n Arrays.sort(s)\n var lo = 0\n var hi = k\n var foo = LongArray(n)\n while (lo < hi) {\n val m = (lo + hi) / 2\n foo = LongArray(n)\n for (i in n - 1 downTo 0) {\n foo[s[i]!!.b] = s[i]!!.a.toLong()\n }\n foo[s[n - 1]!!.b] = (s[n - 1]!!.a + m).toLong()\n var rest = k - m.toLong()\n var last = foo[s[n - 1]!!.b]\n var i = n - 2\n while (i >= 0 && rest > 0) {\n val need = Math.min(rest, last - s[i]!!.a - 1)\n foo[s[i]!!.b] = s[i]!!.a + need\n rest -= need\n last = foo[s[i]!!.b]\n i--\n }\n if (rest == 0L) {\n hi = m\n } else {\n lo = m + 1\n }\n }\n foo = LongArray(n)\n for (i in n - 1 downTo 0) {\n foo[s[i]!!.b] = s[i]!!.a.toLong()\n }\n foo[s[n - 1]!!.b] = (s[n - 1]!!.a + lo).toLong()\n var rest = k - lo.toLong()\n var last = foo[s[n - 1]!!.b]\n run {\n var i = n - 2\n while (i >= 0 && rest > 0) {\n val need = Math.min(rest, last - s[i]!!.a - 1)\n foo[s[i]!!.b] = s[i]!!.a + need\n rest -= need\n last = foo[s[i]!!.b]\n i--\n }\n }\n for (i in 0 until n) {\n out.print((foo[i] - org[i]).toString() + \" \")\n }\n out.println()\n }\n }\n\n internal class InputReader(stream: InputStream?) {\n var `in`: BufferedReader\n var tok: StringTokenizer?\n fun nextToken(): String? {\n var line: String? = \"\"\n while (tok == null || !tok!!.hasMoreTokens()) {\n try {\n if (`in`.readLine().also { line = it } != null) tok = StringTokenizer(line) else return null\n } catch (e: IOException) { // TODO Auto-generated catch block\n e.printStackTrace()\n return null\n }\n }\n return tok!!.nextToken()\n }\n\n fun nextInt(): Int {\n return nextToken()!!.toInt()\n }\n\n fun nextLong(): Long {\n return nextToken()!!.toLong()\n }\n\n fun nextDouble(): Double {\n return nextToken()!!.toDouble()\n }\n\n init {\n `in` = BufferedReader(InputStreamReader(stream), 32768)\n tok = null\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "da6b4d0c4d5e6c40c1243c9e7f000f9a", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import com.sun.corba.se.spi.orbutil.threadpool.Work\n\nimport java.util.*\nimport java.io.*\n\n/**\n * A Template Used For Competitive Programming\n * By XGN from HHS 2020\n * Intellij is too hard to use...\n * Code created at 2020/2/27 21:59\n */\nclass D1297 {\n\n\n internal inner class Worker(var salary: Int, var id: Int)\n\n internal fun ok(maxW: Int, k: Int, wo: Array): Boolean {\n var leftOver = k - maxW\n var lastSal = wo[0].salary + maxW\n for (i in 1 until wo.size) {\n if (leftOver <= 0) {\n return true\n }\n val toCost = lastSal - 1 - wo[i].salary\n if (toCost < 0) {\n return false\n }\n lastSal = lastSal - 1\n leftOver -= toCost\n }\n return leftOver <= 0\n }\n\n fun solve(args: Array) {\n val `in` = InputReader(System.`in`)\n val out = PrintWriter(System.out)\n\n var t = `in`.nextInt()\n while (t-- != 0) {\n val n = `in`.nextInt()\n val k = `in`.nextInt()\n val wo = arrayOfNulls(n)\n for (i in 0 until n) {\n wo[i] = Worker(`in`.nextInt(), i)\n }\n\n Arrays.sort(wo) { o1, o2 -> -Integer.compare(o1.salary, o2.salary) }\n\n var l = 0\n var r = k\n while (l <= r) {\n val m = (l + r) / 2\n if (ok(m, k, wo)) {\n r = m - 1\n } else {\n l = m + 1\n }\n }\n\n // out.println(l);\n //construct\n val ans = IntArray(n)\n var leftOver = k - l\n var lastSal = wo[0].salary + l\n ans[wo[0].id] = l\n for (i in 1 until wo.size) {\n if (leftOver <= 0) {\n break\n }\n val toCost = Math.min(leftOver, lastSal - 1 - wo[i].salary)\n ans[wo[i].id] = toCost\n lastSal = lastSal - 1\n leftOver -= toCost\n }\n\n for (i in 0 until n) {\n out.print(ans[i].toString() + \" \")\n }\n out.println()\n }\n\n out.flush()\n out.close()\n }\n\n internal class InputReader(stream: InputStream) {\n var reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n }\n\n companion object {\n @JvmStatic\n fun main(args: Array) {\n val me = D1297()\n me.solve(args)\n }\n }\n}\n\nfun main(){\n D1297.main(arrayOf(\"\"));\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e6931180c9deae0e5c578929f78371ca", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.Random\nimport java.io.UncheckedIOException\nimport java.io.Closeable\nimport java.io.Writer\nimport java.io.OutputStreamWriter\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject programkt {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = DBonusDistribution()\n val testCount = Integer.parseInt(`in`.next())\n for (i in 1..testCount)\n solver.solve(i, `in`, out)\n out.close()\n }\n }\n\n internal class DBonusDistribution {\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val n = `in`.readInt()\n var k = `in`.readInt()\n val a = IntArray(n)\n val index = IntArray(n)\n for (i in 0 until n) {\n a[i] = `in`.readInt()\n index[i] = i\n }\n CompareUtils.quickSort(index, { i: Int, j: Int -> -Integer.compare(a[i], a[j]) }, 0, n)\n val dist = IntArray(n)\n for (i in 1 until n) {\n var allow = a[index[i - 1]] - 1 - a[index[i]]\n allow = Math.min(k, allow)\n k -= allow\n a[index[i]] += allow\n dist[index[i]] = allow\n }\n val avg = k / n\n for (i in 0 until n) {\n dist[index[i]] += avg\n }\n val remain = k % n\n for (i in 0 until remain) {\n dist[index[i]]++\n }\n\n for (d in dist) {\n out.append(d).append(' ')\n }\n out.println()\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal object Randomized {\n private val random = Random(0)\n\n fun nextInt(l: Int, r: Int): Int {\n return random.nextInt(r - l + 1) + l\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val defaultStringBuf = StringBuilder(1 shl 13)\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n operator fun next(): String {\n return readString()\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n fun readString(builder: StringBuilder): String {\n skipBlank()\n\n while (next > 32) {\n builder.append(next.toChar())\n next = read()\n }\n\n return builder.toString()\n }\n\n fun readString(): String {\n defaultStringBuf.setLength(0)\n return readString(defaultStringBuf)\n }\n\n }\n\n internal interface IntComparator {\n fun compare(a: Int, b: Int): Int\n\n }\n\n internal object SequenceUtils {\n fun swap(data: IntArray, i: Int, j: Int) {\n val tmp = data[i]\n data[i] = data[j]\n data[j] = tmp\n }\n\n }\n\n internal object CompareUtils {\n private val THRESHOLD = 4\n\n fun insertSort(data: IntArray, cmp: IntComparator, l: Int, r: Int) {\n for (i in l + 1..r) {\n var j = i\n val `val` = data[i]\n while (j > l && cmp.compare(data[j - 1], `val`) > 0) {\n data[j] = data[j - 1]\n j--\n }\n data[j] = `val`\n }\n }\n\n fun quickSort(data: IntArray, cmp: IntComparator, f: Int, t: Int) {\n if (t - f <= THRESHOLD) {\n insertSort(data, cmp, f, t - 1)\n return\n }\n SequenceUtils.swap(data, f, Randomized.nextInt(f, t - 1))\n var l = f\n var r = t\n var m = l + 1\n while (m < r) {\n val c = cmp.compare(data[m], data[l])\n if (c == 0) {\n m++\n } else if (c < 0) {\n SequenceUtils.swap(data, l, m)\n l++\n m++\n } else {\n SequenceUtils.swap(data, m, --r)\n }\n }\n quickSort(data, cmp, f, l)\n quickSort(data, cmp, m, t)\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bbcf853b0976effc83fd6c51f21eed9f", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "package contest\n\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.Arrays\nimport java.io.UncheckedIOException\nimport java.io.Closeable\nimport java.io.Writer\nimport java.io.OutputStreamWriter\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject programkt {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = DBonusDistribution()\n val testCount = Integer.parseInt(`in`.next())\n for (i in 1..testCount)\n solver.solve(i, `in`, out)\n out.close()\n }\n }\n\n internal class DBonusDistribution {\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val n = `in`.readInt()\n var k = `in`.readInt()\n val a = arrayOfNulls(n)\n for (i in 0 until n) {\n a[i] = Employee()\n a[i]?.v = `in`.readInt()\n }\n val sorted = a.clone()\n Arrays.sort(sorted) { x, y -> -Integer.compare(x!!.v, y!!.v) }\n for (i in 1 until n) {\n var allow = sorted[i - 1]!!.v - 1 - sorted[i]!!.v\n allow = Math.min(k, allow)\n k -= allow\n sorted[i]!!.v += allow\n sorted[i]!!.k = allow\n }\n val avg = k / n\n for (i in 0 until n) {\n sorted[i]!!.k += avg\n }\n val remain = k % n\n for (i in 0 until remain) {\n sorted[i]!!.k++\n }\n\n for (e in a) {\n out.append(e!!.k).append(' ')\n }\n out.println()\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val defaultStringBuf = StringBuilder(1 shl 13)\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n operator fun next(): String {\n return readString()\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n fun readString(builder: StringBuilder): String {\n skipBlank()\n\n while (next > 32) {\n builder.append(next.toChar())\n next = read()\n }\n\n return builder.toString()\n }\n\n fun readString(): String {\n defaultStringBuf.setLength(0)\n return readString(defaultStringBuf)\n }\n\n }\n\n internal class Employee {\n var v: Int = 0\n var k: Int = 0\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dc5d18c3cb15fe50ad0ed9a4d59379bf", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin 1.4", "source_code": "import java.lang.AssertionError\r\nimport java.util.Scanner\r\nprivate fun readLn() = readLine()!! // string line\r\nprivate fun readInt() = readLn().toInt() // single int\r\nprivate fun readLong() = readLn().toLong() // single long\r\nprivate fun readDouble() = readLn().toDouble() // single double\r\nprivate fun readStrings() = readLn().split(\" \") // list of strings\r\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\r\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\r\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\r\n\r\nfun main(args: Array)\r\n{\r\n\tval sc = Scanner(System.`in`)\r\n var t:Int = 1\r\n \r\n while(t>0)\r\n {\r\n \r\n var n = readInt()\r\n var dp = ArrayInt(n+9)\r\n var sum = ArrayLong(n+9)\r\n var cnt = ArrayInt(n+9)\r\n \r\n for(i in 1..n)\r\n {\r\n var j = i\r\n cnt[j] = 0\r\n while(j<=n){\r\n cnt[j]++\r\n j+=i\r\n }\r\n }\r\n \r\n dp[0] = 1; dp[1] = 1; sum[1] = 1\r\n for(i in 2..n)\r\n {\r\n dp[i] = cnt[i]\r\n dp[i]+=cnt[i]; dp[i]%=998244353\r\n sum[i] = (sum[i-1]+dp[i])%998244353\r\n }\r\n \r\n println(dp[n])\r\n \r\n t--\r\n }\r\n \r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5c86fbb979ed67385760951c1964aede", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "/**\n * Class that solves codeforces problem.\n * It tries to replace wild cards(?) to letters to create lexicographically smallest palindrome.\n */\nclass PatternHandler(private val pattern: CharArray,\n private val alphabet: Int) {\n\n private val IMPOSSIBLE_MESSAGE = \"IMPOSSIBLE\"\n private val usedChars = BitSet(alphabet)\n\n init {\n pattern\n .filter { it != '?' }\n .map { getIndex(it) }\n .forEach { usedChars[it] = true }\n }\n\n /**\n * Returns index of symbol in usedChars array\n */\n private fun getIndex(symbol: Char): Int = symbol - 'a'\n\n /**\n * Returns index of symbol in usedChars array\n */\n private fun getSymbol(index: Int): Char = 'a' + index\n\n /**\n * Get index letter that should be on the wild card sign.\n * It's take the most biggest lexicographically letter,\n * because we are starting to remove wild cards from center of the palindrome.\n */\n private fun getAppropriateLetterIndex(): Int {\n val index = usedChars.previousClearBit(alphabet - 1)\n\n return if (index == -1) {\n 0\n } else {\n index\n }\n }\n\n /**\n * l, r -- indices in pattern.\n * If they are both wild cards they will be replaced by most biggest lexicographically letter.\n */\n private fun removeWildCardPairs(l: Int, r: Int) {\n if (pattern[l] == '?' && pattern[r] == '?') {\n val letterIndex = getAppropriateLetterIndex()\n val letter = getSymbol(letterIndex)\n usedChars[letterIndex] = true\n pattern[l] = letter\n pattern[r] = letter\n }\n }\n\n /**\n * Cleaning rest of wild cards.\n * If there any of chars at indices l, r equals wild card, then it should be replaced by another char.\n */\n private fun cleanWildCards(l: Int, r: Int) {\n if (pattern[l] == '?') {\n pattern[l] = pattern[r]\n }\n\n if (pattern[r] == '?') {\n pattern[r] = pattern[l]\n }\n }\n\n /**\n * Solving codeforces task.\n * It returns processed symmetric palindrome if it's possible.\n * Otherwise it returns IMPOSSIBLE_MESSAGE\n */\n fun solve(): String {\n if (alphabet > pattern.size) {\n return IMPOSSIBLE_MESSAGE\n }\n\n var r = pattern.size / 2\n while (r < pattern.size) {\n val indent = r - pattern.size / 2\n val l = r - (pattern.size + 1) % 2 - 2 * indent\n\n // process pattern\n removeWildCardPairs(l, r)\n cleanWildCards(l, r)\n\n if (pattern[l] != pattern[r]) {\n return IMPOSSIBLE_MESSAGE\n }\n\n r++\n }\n\n if (usedChars.cardinality() != alphabet) {\n return IMPOSSIBLE_MESSAGE\n }\n\n return String(pattern)\n }\n}\n\n/**\n * CLI for task: http://codeforces.com/contest/59/problem/C\n * Successful submission: http://codeforces.com/contest/59/my\n * Input contains of two lines. At the first line there is a number k.\n * On the second line there is pattern for constructing palindrome.\n */\nfun main(args: Array) {\n val k = Integer.parseInt(readLine())\n val pattern = readLine()!!\n val result = PatternHandler(pattern.toCharArray(), k).solve()\n print(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "69c351ed85059b76b04c8738c31b3551", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\nimport java.util.*\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val k = input.nextInt()\n val pattern: String = input.next()\n\n val len = pattern.length\n var possible = true\n var free = 0\n\n val answer = CharArray(len)\n val used = BooleanArray(k)\n\n loop@ for (symbol in pattern) {\n val number = symbol.minus('a')\n when {\n number < 0 -> continue@loop\n number >= k -> possible = false\n else -> used[number] = true\n }\n }\n\n for (index in 0..(len - 1) / 2) {\n val left = pattern[index]\n val right = pattern[len - 1 - index]\n\n when {\n left != '?' && right != '?' && left != right -> possible = false\n left == '?' && right != '?' -> {\n answer[index] = right\n answer[len - 1 - index] = right\n }\n left != '?' && right == '?' -> {\n answer[index] = left\n answer[len - 1 - index] = left\n }\n left == '?' && right == '?' -> free++\n left == right -> {\n answer[index] = left\n answer[len - 1 - index] = right\n }\n }\n }\n\n val need = k - (used.filter { it }).size\n free -= need\n\n var currentPosition = 0\n (0..(len - 1) / 2)\n .asSequence()\n .filter { pattern[it] == '?' && pattern[len - 1 - it] == '?' }\n .forEach {\n if (free-- > 0) {\n answer[it] = 'a'\n answer[len - 1 - it] = 'a'\n } else {\n while (currentPosition < k && used[currentPosition]) {\n currentPosition++\n }\n\n if (currentPosition >= k) {\n possible = false\n }\n val symbol = 'a'.plus(currentPosition++)\n answer[it] = symbol\n answer[len - 1 - it] = symbol\n }\n }\n\n if (possible) {\n println(String(answer))\n } else {\n println(\"IMPOSSIBLE\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c3f04d6aa88bafa6d540d24083ace8fd", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\nfun checkIn(character: Char, maxChar: Char) = character in 'a'..maxChar\n\nfun main() {\n val numberOfRequiredLetters = readLine()?.toInt()\n val pattern = readLine()\n\n if (numberOfRequiredLetters == null || pattern == null) {\n println(\"Wrong input\")\n return\n }\n\n val sz = pattern.length\n var free = 0\n val maxChar = ('a' + numberOfRequiredLetters - 1)\n val unusedChars = ('a'..maxChar).toHashSet()\n val stringArray = Array(sz) {'?'}\n\n for ((i, j) in (0 until sz).zip(sz - 1 downTo 1)) {\n val first = pattern[i]\n val second = pattern[j]\n\n if (first == '?' && second == '?') {\n free++\n continue\n }\n\n if (first == '?') {\n stringArray[i] = second\n stringArray[j] = second\n } else {\n stringArray[i] = first\n stringArray[j] = first\n }\n\n if (!checkIn(stringArray[i], maxChar)) {\n println(\"IMPOSSIBLE\")\n return\n }\n unusedChars.remove(stringArray[i])\n }\n\n if (free < unusedChars.size) {\n println(\"IMPOSSIBLE\")\n return\n }\n\n for ((i, j) in (0 until sz).zip(sz - 1 downTo 1)) {\n if (stringArray[i] != '?') {\n continue\n }\n\n val unusedCharacter = unusedChars.firstOrNull() ?: 'a'\n stringArray[i] = unusedCharacter\n stringArray[j] = unusedCharacter\n unusedChars.remove(unusedCharacter)\n }\n\n println(stringArray.joinToString(separator = \"\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "17ed0a88c0214a7cb193404cfbfcd47f", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\nimport java.util.*\n\nfun getTitle(amountOfLetters: Int, pattern: String): String {\n val patternChars: CharArray = pattern.toCharArray()\n val patternLength = patternChars.size\n val occupiedLetters = mutableListOf()\n for (index in 0 until amountOfLetters) {\n occupiedLetters.add(index, false)\n }\n patternChars.forEach { letter ->\n run {\n if (letter != '?') {\n occupiedLetters[letter - 'a'] = true\n }\n }\n }\n val startIndex = if (patternLength % 2 == 0)\n patternLength / 2 - 1\n else\n patternLength / 2\n for (i in startIndex downTo 0) {\n if (patternChars[i] == '?') {\n val symmetricLetterIndex = patternLength - i - 1\n if (patternChars[patternLength - i - 1] == '?') {\n val theLastNotOccupiedLetterIndex = occupiedLetters.lastIndexOf(false)\n if (theLastNotOccupiedLetterIndex == -1) {\n patternChars[i] = 'a'\n } else {\n patternChars[i] = 'a' + theLastNotOccupiedLetterIndex\n occupiedLetters[theLastNotOccupiedLetterIndex] = true\n }\n patternChars[patternLength - i - 1] = patternChars[i]\n } else {\n patternChars[i] = patternChars[symmetricLetterIndex]\n }\n }\n }\n\n (0 until patternLength)\n .filter { patternChars[it] == '?' }\n .forEach { patternChars[it] = patternChars[patternLength - it - 1] }\n (0 until patternLength)\n .filter { patternChars[it] != patternChars[patternLength - it - 1] }\n .forEach { return \"IMPOSSIBLE\" }\n\n if (occupiedLetters.contains(false)) {\n return \"IMPOSSIBLE\"\n }\n return patternChars.joinToString(separator = \"\")\n}\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val amountOfLetters: Int = input.nextInt()\n val pattern: String = input.next()\n input.close()\n println(getTitle(amountOfLetters, pattern))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "10e11ed932db6e3615c88c3f265e2086", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\nimport kotlin.math.PI\nimport kotlin.math.atan\n\ndata class Vector(val xCoordinate : Int, val yCoordinate : Int, val identifier : Int)\n\nfun getVectorAngle(vector : Vector) =\n when {\n vector.xCoordinate > 0 -> atan(vector.yCoordinate / vector.xCoordinate.toDouble())\n vector.xCoordinate < 0 -> PI + atan(vector.yCoordinate / vector.xCoordinate.toDouble())\n else ->\n if (vector.yCoordinate > 0) {\n PI / 2\n } else {\n -PI / 2\n }\n }\n\nfun readVectors() : ArrayList {\n val reader = Scanner(System.`in`)\n val vectorsNumber = reader.nextInt()\n val listOfVectors = ArrayList()\n\n for (identifier in 1..vectorsNumber) {\n val xCoordinate = reader.nextInt()\n val yCoordinate = reader.nextInt()\n val vector = Vector(xCoordinate, yCoordinate, identifier)\n\n listOfVectors.add(vector)\n }\n\n return listOfVectors\n}\n\nfun getNearliestVectorPair(listOfVectors : ArrayList) : Pair {\n listOfVectors.sortWith(compareByDescending { getVectorAngle(it) })\n\n var bestAngleDifference : Double = 2 * PI + getVectorAngle(listOfVectors.last()) - getVectorAngle(listOfVectors.first())\n var bestFirstIndex = 0\n var bestSecondIndex = listOfVectors.size - 1\n\n for (i in 0 until listOfVectors.size - 1) {\n val angleDifference = getVectorAngle(listOfVectors[i]) - getVectorAngle(listOfVectors[i + 1])\n\n if (angleDifference < bestAngleDifference) {\n bestFirstIndex = i\n bestSecondIndex = i + 1\n bestAngleDifference = angleDifference\n }\n }\n\n return Pair(listOfVectors[bestFirstIndex], listOfVectors[bestSecondIndex])\n}\n\nfun getSymbolsFromString(string : String) : HashSet {\n val stringSymbols = HashSet()\n for (symbol in string) {\n if (!stringSymbols.contains(symbol)) {\n stringSymbols.add(symbol)\n }\n }\n\n return stringSymbols\n}\n\nfun getStringMissingSymbols(string: String) : ArrayList {\n val stringSymbols = getSymbolsFromString(string)\n val missingSymbols = ArrayList()\n\n for (symbol in 'a'..'z') {\n if (!stringSymbols.contains(symbol)) {\n missingSymbols.add(symbol)\n }\n }\n\n return missingSymbols\n}\n\nfun hasAnswer(string: String) : Boolean {\n for (i in 0..(string.length + 1) / 2) {\n if (string[i] != '?' && string[string.length - 1 - i] != '?') {\n if (string[i] != string[string.length - 1 - i]) {\n return false\n }\n }\n }\n\n return true\n}\n\nfun solveProblem(string: String, mustHaveCharsNumber : Int) : ArrayList? {\n val chars = ArrayList()\n val missingSymbols = getStringMissingSymbols(string)\n var index = 0\n\n if (!hasAnswer(string)) {\n return null\n }\n\n for (char in string) {\n chars.add(char)\n }\n\n for (i in 0 until (string.length + 1) / 2) {\n if (string[i] == '?' && string[string.length - 1 - i] == '?') {\n if (index == missingSymbols.size) {\n chars[i] = 'a'\n chars[string.length - 1 - i] = 'a'\n } else {\n chars[i] = missingSymbols[index]\n chars[string.length - 1 - i] = missingSymbols[index]\n index++\n }\n } else if (string[i] == '?') {\n chars[i] = string[string.length - 1 - i]\n chars[string.length - 1 - i] = string[string.length - 1 - i]\n } else {\n chars[i] = string[i]\n chars[string.length - 1 - i] = string[i]\n }\n }\n\n return if (index < missingSymbols.size && missingSymbols[index] - 'a' <= mustHaveCharsNumber) {\n chars\n } else {\n null\n }\n}\n\nfun main() {\n val reader = Scanner(System.`in`)\n val mustHaveCharsNumber = reader.nextInt()\n val string = reader.next()\n val resultString = solveProblem(string, mustHaveCharsNumber)\n\n if (resultString == null) {\n print(\"IMPOSSIBLE\")\n } else {\n for (char in resultString) {\n print(char)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5174770bdc4421a54a9cbe5ff6cadd04", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\n\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n print(Solver.read(System.`in`).solve())\n}\n\nclass Solver(k: Int, private val bookTitle: CharArray) {\n companion object {\n fun read(inputStream: InputStream) : Solver {\n val input = Scanner(inputStream)\n val k = input.nextInt()\n val bookTitle = input.next().toCharArray()\n return Solver(k, bookTitle)\n }\n\n val IMPOSSIBLE = \"IMPOSSIBLE\".toCharArray()\n }\n\n private val unusedLetters = (('a' until 'a' + k) - bookTitle.toSortedSet()).toSortedSet()\n private val halfOfBookTitleSize = bookTitle.size / 2\n\n fun solve(): CharArray {\n if (!removePairedQuestionMarks())\n return IMPOSSIBLE\n if (!removeSingleQuestionMarks())\n return IMPOSSIBLE\n return bookTitle\n }\n\n private fun removeSingleQuestionMarks(): Boolean {\n var i = 0\n while (i < halfOfBookTitleSize) {\n val correspondingIndex = getCorrespondingIndex(i)\n if (bookTitle[i] == '?' || bookTitle[correspondingIndex] == '?') {\n if (bookTitle[i] == '?') {\n bookTitle[i] = bookTitle[correspondingIndex]\n } else {\n bookTitle[correspondingIndex] = bookTitle[i]\n }\n } else {\n if (bookTitle[i] != bookTitle[correspondingIndex]) {\n return false\n }\n }\n i++\n }\n return true\n }\n\n private fun removePairedQuestionMarks(): Boolean {\n var i = halfOfBookTitleSize\n while (i < bookTitle.size) {\n val correspondingIndex = getCorrespondingIndex(i)\n if (bookTitle[i] == '?' && bookTitle[correspondingIndex] == '?') {\n bookTitle[i] = getAndExtractMaxUnusedLetterOrA()\n bookTitle[correspondingIndex] = bookTitle[i]\n }\n i++\n }\n return unusedLetters.isEmpty()\n }\n\n private fun getAndExtractMaxUnusedLetterOrA(): Char {\n if (unusedLetters.isEmpty())\n return 'a'\n val lastFromUnusedLetters = unusedLetters.last()\n unusedLetters.remove(lastFromUnusedLetters)\n return lastFromUnusedLetters\n }\n\n private fun getCorrespondingIndex(i: Int): Int = bookTitle.size - i - 1\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bc1d692a3f9d721a38ee32be416c8210", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\n\nimport java.util.*\n\nfun getTitle(amountOfLetters: Int, pattern: String): String {\n val patternChars: CharArray = pattern.toCharArray()\n val patternLength = patternChars.size\n val occupiedLetters = mutableListOf()\n for (index in 0 until amountOfLetters) {\n occupiedLetters.add(index, false)\n }\n patternChars.forEach { letter ->\n run {\n if (letter != '?') {\n occupiedLetters[letter - 'a'] = true\n }\n }\n }\n val startIndex = if (patternLength % 2 == 0)\n patternLength / 2 - 1\n else\n patternLength / 2\n for (i in startIndex downTo 0) {\n if (patternChars[i] == '?') {\n val symmetricLetterIndex = patternLength - i - 1\n if (patternChars[patternLength - i - 1] == '?') {\n val theLastNotOccupiedLetter = occupiedLetters.lastIndexOf(false)\n patternChars[i] = 'a' + theLastNotOccupiedLetter\n patternChars[patternLength - i - 1] = patternChars[i]\n occupiedLetters[theLastNotOccupiedLetter] = true\n } else {\n patternChars[i] = patternChars[symmetricLetterIndex]\n }\n }\n }\n\n (0 until patternLength)\n .filter { patternChars[it] == '?' }\n .forEach { patternChars[it] = patternChars[patternLength - it - 1] }\n (0 until patternLength)\n .filter { patternChars[it] != patternChars[patternLength - it - 1] }\n .forEach { return \"IMPOSSIBLE\" }\n\n if (occupiedLetters.contains(false)) {\n return \"IMPOSSIBLE\"\n }\n return patternChars.joinToString(separator = \"\")\n}\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val amountOfLetters: Int = input.nextInt()\n val pattern: String = input.next()\n input.close()\n println(getTitle(amountOfLetters, pattern))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c819331692f4b334102dd339c74023be", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\n\nimport java.io.InputStream\nimport java.util.*\n\nclass Solver(k: Int, private val bookTitle: CharArray) {\n companion object {\n fun read(inputStream: InputStream) : Solver {\n val input = Scanner(inputStream)\n val k = input.nextInt()\n val bookTitle = input.next().toCharArray()\n return Solver(k, bookTitle)\n }\n\n val IMPOSSIBLE = \"IMPOSSIBLE\".toCharArray()\n }\n\n private val unusedLetters = (('a' until 'a' + k) - bookTitle.toSortedSet()).toSortedSet()\n private val halfOfBookTitleSize = bookTitle.size / 2\n\n fun solve(): CharArray {\n if (!removePairedQuestionMarks())\n return IMPOSSIBLE\n if (!removeSingleQuestionMarks())\n return IMPOSSIBLE\n return bookTitle\n }\n\n private fun removeSingleQuestionMarks(): Boolean {\n var i = 0\n while (i < halfOfBookTitleSize) {\n val correspondingIndex = getCorrespondingIndex(i)\n if (bookTitle[i] == '?' || bookTitle[correspondingIndex] == '?') {\n if (bookTitle[i] == '?') {\n bookTitle[i] = bookTitle[correspondingIndex]\n } else {\n bookTitle[correspondingIndex] = bookTitle[i]\n }\n } else {\n if (bookTitle[i] != bookTitle[correspondingIndex]) {\n return false\n }\n }\n i++\n }\n return true\n }\n\n private fun removePairedQuestionMarks(): Boolean {\n var i = halfOfBookTitleSize\n while (i < bookTitle.size) {\n val correspondingIndex = getCorrespondingIndex(i)\n if (bookTitle[i] == '?' && bookTitle[correspondingIndex] == '?') {\n bookTitle[i] = getAndExtractMaxUnusedLetterOrA()\n bookTitle[correspondingIndex] = bookTitle[i]\n }\n i++\n }\n return unusedLetters.isEmpty()\n }\n\n private fun getAndExtractMaxUnusedLetterOrA(): Char {\n if (unusedLetters.isEmpty())\n return 'a'\n val lastFromUnusedLetters = unusedLetters.last()\n unusedLetters.remove(lastFromUnusedLetters)\n return lastFromUnusedLetters\n }\n\n private fun getCorrespondingIndex(i: Int): Int = bookTitle.size - i - 1\n}\n\nfun main(args: Array) {\n print(Solver.read(System.`in`).solve())\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3502294187d4e98df0742b1cd9f805e7", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\n\nprivate const val MATCH_FAILED: Char = '.'\nprivate const val QUESTION_MARK: Char = '?'\n\nprivate fun matchNonQuestionMark(pair: Pair): Char {\n val (x, y) = pair\n\n return when {\n x == QUESTION_MARK -> y\n y == QUESTION_MARK -> x\n x == y -> x\n else -> MATCH_FAILED\n }\n}\n\nprivate fun fillQuestionMarksFromTheOtherPalindromeSide(str: List): List {\n return str.zip(str.reversed()).map(::matchNonQuestionMark)\n}\n\nprivate fun fillQuestionMarksFromQueue(str: List,\n queue: MutableList,\n default: Char = 'a'): List {\n val result = str.toMutableList()\n\n for (idx in result.size / 2 - 1 downTo 0) {\n if (result[idx] == QUESTION_MARK)\n result[idx] = if (queue.isEmpty()) default else queue.removeAt(0)\n }\n\n return result\n}\n\nfun getTitle(lettersCount: Int, pattern: String): String? {\n val match = fillQuestionMarksFromTheOtherPalindromeSide(pattern.toList())\n\n val mustBeUsed = ('a'..'z').take(lettersCount)\n val leftToUse = (mustBeUsed.toSet() - match).sortedDescending().toMutableList()\n val bestMatch = fillQuestionMarksFromQueue(match, leftToUse, default = 'a')\n\n val notAllWereUsed = leftToUse.isNotEmpty()\n val notAllMatched = MATCH_FAILED in bestMatch\n\n return if (notAllMatched || notAllWereUsed) null else\n fillQuestionMarksFromTheOtherPalindromeSide(bestMatch).joinToString(\"\")\n}\n\nfun main(args: Array) {\n val numOfLetters = readLine()?.toIntOrNull() ?: return\n val pattern = readLine() ?: return\n\n println(getTitle(numOfLetters, pattern) ?: \"IMPOSSIBLE\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "910c96338a2460985a5deb6079e44b3d", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\n\nimport java.util.*\n\nfun notInRange(range: Int, letter: Char): Boolean {\n return ((letter < 'a') or (letter >= 'a' + range)) and (letter != '?')\n}\n\nfun fillPattern(pattern: CharArray, range: Int): CharArray? {\n return CharArray((pattern.size + 1) / 2, {\n i ->\n val a = pattern[i]\n val b = pattern[pattern.size - i - 1]\n when {\n notInRange(range, a) or notInRange(range, b) -> return null\n a == b -> a\n a == '?' -> b\n b == '?' -> a\n else -> return null\n }\n })\n}\n\nfun main(args: Array) {\n with(Scanner(System.`in`)) {\n val k = nextInt()\n nextLine()\n val patternString = nextLine()\n val odd = patternString.length % 2\n val pattern = fillPattern(patternString.toCharArray(), k)\n if (pattern == null) {\n print(\"IMPOSSIBLE\")\n return\n }\n val unusedLetters = ('a' until ('a' + k)).filter { ! pattern.contains(it) }\n val questionCount = pattern.count { it == '?' }\n if (unusedLetters.size > questionCount) {\n print(\"IMPOSSIBLE\")\n return\n }\n var j = 0\n for (i in 0 until pattern.size) {\n if (pattern[i] == '?') {\n if (questionCount - j > unusedLetters.size)\n pattern[i] = 'a'\n else\n pattern[i] = unusedLetters[j + unusedLetters.size - questionCount]\n j++\n }\n }\n pattern.forEach { print(it) }\n pattern.reverse()\n (odd until pattern.size).forEach { print(pattern[it]) }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1d9651cf953f8f4fb883911b7d62e7d7", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.Collections.copy\nimport java.util.Collections.min\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n var (n,t) = listOfInt()\n var g = MutableList(n){ mutableListOf()}\n var ind=mutableMapOf,Int>()\n repeat(n-1){\n var (x,y) = listOfInt()\n --x; --y;\n ind[Pair(x,y)]=it\n ind[Pair(y,x)]=it\n g[x].add(y)\n g[y].add(x)\n }\n var re=MutableList(n){Pair(-1,-1)}\n var dp = MutableList(n){ MutableList(t+1){re.toMutableList()}}\n var sz=mutableListOf(n){1}\n fun dfs(v:Int, p:Int) {\n dp[v][0]=mutableListOf()\n dp[v][1]= mutableListOf()\n g[v].forEach { w ->\n if(w==p) return@forEach\n dfs(w,v)\n sz[v]+=sz[w]\n for(i in min(sz[v],t) downTo 1){\n for(j in 0 until min(sz[w]+1,i)){\n if(j==0 || dp[v][i-j].size+dp[w][j].size=0) re.add(Pair(p,v))\n }\n if(p>=0) dp[v][0].add(Pair(v,p))\n }\n dfs(0,-1)\n println(re.size)\n println(re.map{p -> ind.getValue(p)+1}.joinToString (\" \"))\n pw.flush()\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\nfun listOfLong() = listOfString().map { it.toLong() }\nfun listOfDouble() = listOfString().map { it.toDouble() }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5ae3c188625d6d200007658aaf4b865c", "src_uid": "56168b28f9ab4830b3d3c5eeb7fc0d3c", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.util.stream.IntStream\nimport kotlin.math.min\nimport kotlin.random.Random\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nval ids = Array(410) { ArrayList() }\nval adj = Array(410) { ArrayList() }\nval mem = HashMap, IntArray>()\nval nex = HashMap, ArrayList>()\nvar ops = 0\nfun dfs(u: Int, p: Int = -1): IntArray {\n if (mem.containsKey(Pair(p, u))) {\n return mem[Pair(p, u)]!!\n }\n var ans = intArrayOf(0)\n var bes = ArrayList()\n for (v in adj[u]) {\n if (v == p) {\n bes.add(IntArray(0))\n continue\n }\n var t = dfs(v, u)\n var nAns = IntArray(ans.size + t.size - 1) { 1000000 }\n bes.add(IntArray(nAns.size))\n for (i in 0 until ans.size) {\n for (j in 0 until t.size) {\n ops++\n if (ans[i] + t[j] <= nAns[i + j]) {\n nAns[i + j] = min(nAns[i + j], ans[i] + t[j])\n bes[bes.size - 1][i + j] = j\n }\n }\n }\n ans = nAns\n }\n val ret = ans.toMutableList()\n ret.add(0, 1)\n val retArray = ret.toIntArray()\n mem[Pair(p, u)] = retArray\n nex[Pair(p, u)] = bes\n return retArray\n}\n\n\nfun build(u: Int, p: Int, k: Int, ans: ArrayList) {\n if (k == 0) return\n var kk = k - 1\n val bes = nex[Pair(p, u)]!!\n for(i in adj[u].size - 1 downTo 0) {\n val v = adj[u][i]\n if (v == p) continue\n val b = bes[i][kk]\n if (b == 0) {\n ans.add(ids[u][i])\n } else {\n build(v, u, b, ans)\n kk -= b\n }\n }\n}\n\nfun main() {\n val r = Random.Default\n val (N, K) = readInts()\n for (i in 0 until N - 1) {\n var (u, v) = readInts()\n// var (u, v) = intArrayOf(r.nextInt(i + 1) + 1, i + 2)\n// var (u, v) = intArrayOf(i + 1, i + 2)\n u--\n v--\n ids[u].add(i)\n ids[v].add(i)\n adj[u].add(v)\n adj[v].add(u)\n }\n for (i in 0 until N) {\n dfs(i)\n }\n val bn = (IntStream.range(0, N).boxed().min { a, b -> dfs(a)[K].compareTo(dfs(b)[K]) }).get()\n val ans = ArrayList()\n build(bn, -1, K, ans)\n ans.sort()\n println(ans.size)\n for (i in ans) {\n print(i + 1)\n print(\" \")\n }\n println()\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "73d2de8218ec975a414880c221726aef", "src_uid": "56168b28f9ab4830b3d3c5eeb7fc0d3c", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\nimport java.lang.Long.parseLong\nimport java.lang.Math.max\nimport java.lang.Math.min\nimport java.lang.System.arraycopy\nimport java.lang.System.exit\nimport java.util.Arrays.copyOf\n\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\nimport java.util.StringTokenizer\n\nobject H {\n\n internal var n: Int = 0\n internal var k: Int = 0\n internal var edges: Array\n internal var ans: IntList? = null\n\n internal var `in`: BufferedReader? = null\n internal var out: PrintWriter? = null\n internal var tok: StringTokenizer? = null\n\n internal class IntList {\n\n var data = IntArray(3)\n var size = 0\n\n val isEmpty: Boolean\n get() = size == 0\n\n fun size(): Int {\n return size\n }\n\n operator fun get(index: Int): Int {\n if (index < 0 || index >= size) {\n throw IndexOutOfBoundsException()\n }\n return data[index]\n }\n\n fun clear() {\n size = 0\n }\n\n operator fun set(index: Int, value: Int) {\n if (index < 0 || index >= size) {\n throw IndexOutOfBoundsException()\n }\n data[index] = value\n }\n\n fun expand() {\n if (size >= data.size) {\n data = copyOf(data, (data.size shl 1) + 1)\n }\n }\n\n fun insert(index: Int, value: Int) {\n if (index < 0 || index > size) {\n throw IndexOutOfBoundsException()\n }\n expand()\n arraycopy(data, index, data, index + 1, size++ - index)\n data[index] = value\n }\n\n fun delete(index: Int): Int {\n if (index < 0 || index >= size) {\n throw IndexOutOfBoundsException()\n }\n val value = data[index]\n arraycopy(data, index + 1, data, index, --size - index)\n return value\n }\n\n fun push(value: Int) {\n expand()\n data[size++] = value\n }\n\n fun pop(): Int {\n if (size == 0) {\n throw NoSuchElementException()\n }\n return data[--size]\n }\n\n fun unshift(value: Int) {\n expand()\n arraycopy(data, 0, data, 1, size++)\n data[0] = value\n }\n\n fun shift(): Int {\n if (size == 0) {\n throw NoSuchElementException()\n }\n val value = data[0]\n arraycopy(data, 1, data, 0, --size)\n return value\n }\n }\n\n @Throws(Exception::class)\n internal fun solve() {\n n = scanInt()\n k = scanInt()\n edges = arrayOfNulls(n)\n for (i in 0 until n) {\n edges[i] = IntList()\n }\n for (i in 0 until n - 1) {\n val a = scanInt() - 1\n val b = scanInt() - 1\n edges[a].push(b)\n edges[a].push(i)\n edges[b].push(a)\n edges[b].push(i)\n }\n ans = null\n dfs(0, -1, -1)\n out!!.println(ans!!.size)\n for (i in 0 until ans!!.size) {\n out!!.print((ans!!.data[i] + 1).toString() + \" \")\n }\n }\n\n internal fun dfs(cur: Int, prev: Int, upEdgeId: Int): Array? {\n var cans = arrayOfNulls(1)\n cans[0] = IntList()\n run {\n var i = 0\n while (i < edges[cur].size) {\n val next = edges[cur].data[i]\n if (next == prev) {\n i += 2\n continue\n }\n val nans = dfs(next, cur, edges[cur].data[i + 1])\n val merged = arrayOfNulls(cans.size + nans!!.size - 1)\n for (j in merged.indices) {\n var best = Integer.MAX_VALUE\n val from = max(0, j - nans.size + 1)\n val to = min(cans.size - 1, j)\n for (k in from..to) {\n best = min(best, cans[k].size + nans[j - k].size)\n }\n for (k in from..to) {\n if (best == cans[k].size + nans[j - k].size) {\n merged[j] = IntList()\n for (ii in 0 until cans[k].size) {\n merged[j].push(cans[k].data[ii])\n }\n for (ii in 0 until nans[j - k].size) {\n merged[j].push(nans[j - k].data[ii])\n }\n break\n }\n }\n }\n cans = merged\n i += 2\n }\n }\n if (cans.size >= k) {\n var mySize = cans[k - 1].size\n if (upEdgeId >= 0) {\n ++mySize\n }\n if (ans == null || ans!!.size > mySize) {\n if (ans == null) {\n ans = IntList()\n } else {\n ans!!.size = 0\n }\n for (i in 0 until cans[k - 1].size) {\n ans!!.push(cans[k - 1].data[i])\n }\n if (upEdgeId >= 0) {\n ans!!.push(upEdgeId)\n }\n }\n }\n if (upEdgeId >= 0) {\n val nans = arrayOfNulls(cans.size + 1)\n arraycopy(cans, 0, nans, 1, cans.size)\n nans[0] = IntList()\n nans[0].push(upEdgeId)\n return nans\n } else {\n return null\n }\n }\n\n @Throws(IOException::class)\n internal fun scanInt(): Int {\n return parseInt(scanString())\n }\n\n @Throws(IOException::class)\n internal fun scanLong(): Long {\n return parseLong(scanString())\n }\n\n @Throws(IOException::class)\n internal fun scanString(): String {\n while (tok == null || !tok!!.hasMoreTokens()) {\n tok = StringTokenizer(`in`!!.readLine())\n }\n return tok!!.nextToken()\n }\n\n @JvmStatic\n fun main(args: Array) {\n try {\n `in` = BufferedReader(InputStreamReader(System.`in`))\n out = PrintWriter(System.out)\n solve()\n `in`!!.close()\n out!!.close()\n } catch (e: Throwable) {\n e.printStackTrace()\n exit(1)\n }\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "be22151b6abe9b09ce60cb962d5cb211", "src_uid": "56168b28f9ab4830b3d3c5eeb7fc0d3c", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x,y,z,a,b,c) {\n if a >= x\n return 0\n if a+b >= x+y\n return 0\n if a+b+c >= x+y+z\n return 0\n return 1\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif solve(x,y,z,a,b,c) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0defecd805e0c86ebc67f517b9f89b49", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n\tvar (x, y, z) = readLine()!!.split(' ').map(String::toInt)\n\tvar (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n\tif (a < x || a + b < x + y || a + b + c < x + y + z) {\n\t\tprintln(\"NO\")\n\t} else {\n\t\tprintln(\"YES\")\n\t}\n\treturn 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "863fe21f787ac2ab7928d104ec2e0475", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main() {\n var (a, b) = readLine()!!.split(' ').map { it.toInt() }\n if (a==b && a==0)\n var ans = abs(a-b)\n if (ans<=1){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3205d4823f82a786f457a86b7498d4d3", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package avito\n\nfun main(args: Array) {\n val input = readLine()!!.toInt()\n if(input<=2){\n println(input)\n }else{\n println(1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6cc2296815813b8cdbbde8458896b301", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cp.april\n\nfun main(){\n var a = readLine()!!.toInt()\n var b = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n if(b.none { it == 1 }) {\n println(\"EASY\")\n }else{\n println(\"HARD\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5caff7ffd3a3ee22544bf770f6aa41dd", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n var a = readLine()!!.toInt()\n var b = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n if(b.none { it == 1 }) {\n println(\"EASY\")\n }else{\n println(\"HARD\")\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b055f87469e30b157356c7c1556025ee", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cp.april\n\nclass April11_1 {\n fun main(args: Array) {\n var (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n for (i in 1..b) {\n if (a % 10 == 0) {\n a /= 10\n } else {\n a -= 1\n }\n }\n println(a)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a833857f1a91f84ed6e5eb5bf9d8c4be", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val num = readLine()!!.toInt()\n val values = readLine()!!.split(\" \").map { it.toInt() }\n println( if (values.contains(1)) \"HARD\" else \"EASY)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67df4fed435d9eecf3d8458e15d10a4d", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tA.forEach{\n\t\tif (it == 1)\n\t\t\treturn \"HARD\"\n\t}\n\treturn \"EASY\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "de31c79b0950ae257a3c9dd019267f25", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tA.foreach{\n\t\tif (it == 1)\n\t\t\treturn \"HARD\"\n\t}\n\treturn \"EASY\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fead7e89f98480d5afb7e21c2fb9245b", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine().toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsKey(1)){\n\t\treturn \"HARD\"\n\t}\n\telse{\n\t\treturn \"EASY\"\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f4c0b1682c41708cf0276ffeade78efe", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class April11_2{\n fun main(args: Array) {\n var a = args[0].toInt()\n var b = args[1].split(\" \").map { it.toInt() }.toIntArray()\n if (b.none { it == 1 }) {\n println(\"EASY\")\n } else {\n println(\"HARD\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0f05210fd8a33eba416cb16013778584", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n readLine()\n val opinions = readInts()\n opinions.forEach {\n if (it == 1) {\n println(\"HARD\")\n return\n }\n }\n println(\"EASY\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "526d6de5a61ad55345f6e8b6df3f89bb", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.globalround5\n\nprivate fun solve(n: Int, m: Int = 1): Int {\n\tif (m == n || m + 1 == n) return 1\n\tif (m > n) return 0\n\treturn solve(n, 2 * m + 1 + m % 2)\n}\n\nfun main() = println(solve(readInt()))\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9a0df33762c4db93bae02856aff1d3c4", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val n = readLine()!!.toInt()\n val i = 0\n while (i < n)\n {\n val m = readLine()!!.toInt() / 2\n println(m)\n i += 1\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "300d54b9090f2b0993508ce7a6d5fc5f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()\n for (i in 0 until n) {\n val x = readLine().toInt()\n val t = x / 2\n if (t*2 == x) {\n pritnln(t)\n } else {\n println(t+1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "37ba98c0a10a0fcc449fbce12a8e74d2", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package train\n\nfun main(args: Array) {\n val t = readInt()\n for (i in 1..t) {\n val x = readInt()\n val result = x / 7 + if (x % 7 > 1) 1 else if (x % 7 == 1) 2 else 0\n println(result)\n }\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "acd610a0f8da16e0578858f786608a46", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.swrdfish.learning\n\nfun main() {\n var t = Integer.parseInt(readLine())\n\n while(t > 0) {\n var res = solve(Integer.parseInt(readLine()))\n println(res)\n t--\n }\n\n}\n\nfun solve(n:Int):Int {\n var res = 0\n var m = n\n for(i in 7 downTo 2) {\n res += m/i\n m %= i\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a16f5af8ea12975adb7c2194b0ee2c7d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: array)\n{\nval t=readline()!!.toInt()\nrepeat(t)\n{\nval x=readLine()!!.toInt()\nprintln(x/2)\n}\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a4798b0b850da3887d387d178c18f883", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readInt()\n for (i in 1..t) {\n val summ = readLine()!!.toInt()\n recCal(summ)\n }\n }\nfun recCal(value: Int) {\n return when {\n value in 2..7 -> 1\n value == 8 -> 2\n else -> recCal(value - 7) + 1\n \n }\n}\nfun check(value: Int, m: Int) = (value / m) * m + (value % m)\n\nfun readInt() = readLine()!!.toInt()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e61ac0672f77c52ec02564bc17936df3", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/*\n * This Kotlin source file was generated by the Gradle 'init' task.\n */\npackage practice\n\nfun calcurate(sum: Int): Int {\n val quotient = sum / 7\n val mod = sum % 7 // 7\u3067\u5272\u3063\u305f\u4f59\u308a\n return when {\n /*\n * 1\u306f\u51fa\u305b\u306a\u3044\u306e\u3067\u5272\u308b\u6570\u3092\u6e1b\u3089\u3059 -> quotient - 1\n * 8\u4f59\u308b\u306e\u30676\u3067\u5272\u308b -> +1\n * 2\u4f59\u308b -> +1\n * => quotient - 1 + 1 + 1\n */\n mod == 1 -> quotient + 1\n /*\n * 2\u301c6\u4f59\u308b -> +1\n */\n else -> quotient + 1\n }\n}\n\nfun dice(input: Sequence): String {\n return input.drop(1)\n .mapNotNull{it?.toInt()}\n .map(::calcurate)\n .joinToString(\"\\n\")\n}\n\nfun main(args: Array) {\n print(dice(generateSequence(::readLine)))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "437ebefca10c92f740a6c02c0e95e9bb", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun readln() = readLine()!!\nfun readlnByte() = readln().toByte()\nfun readlnShort() = readln().toShort()\nfun readlnInt() = readln().toInt()\nfun readlnLong() = readln().toLong()\nfun readlnFloat() = readln().toFloat()\nfun readlnDouble() = readln().toDouble()\nfun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)\nfun readlnBigDecimal() = readln().toBigDecimal()\n\nfun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)\nfun readlnStrings() = readln().split(' ')\nfun readlnBytes() = readlnStrings().map { it.toByte() }\nfun readlnShorts() = readlnStrings().map { it.toShort() }\nfun readlnInts() = readlnStrings().map { it.toInt() }\nfun readlnLongs() = readlnStrings().map { it.toLong() }\nfun readlnFloats() = readlnStrings().map { it.toFloat() }\nfun readlnDoubles() = readlnStrings().map { it.toDouble() }\n\nfun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }\nfun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }\nfun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }\nfun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }\nfun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }\nfun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }\n\nfun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }\nfun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }\nfun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }\nfun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }\nfun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }\nfun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }\n\nfun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }\nfun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }\nfun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }\nfun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }\nfun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }\nfun readDoubleArray2d(rows: Int, cols: Int) = Array(rows) { readDoubleArray().also { require(it.size == cols) } }\n\nfun isWhiteSpace(c: Char) = c in \" \\r\\n\\t\"\n\n// JVM-only targeting code follows next\n\n// readString() via sequence is still slightly faster than Scanner\nfun readString() = generateSequence { System.`in`.read().toChar() }\n .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString(\"\")\n\nfun readByte() = readString().toByte()\nfun readShort() = readString().toShort()\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readFloat() = readString().toFloat()\nfun readDouble() = readString().toDouble()\nfun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)\nfun readBigDecimal() = readString().toBigDecimal()\n\nfun readBytes(n: Int) = generateSequence { readByte() }.take(n)\nfun readShorts(n: Int) = generateSequence { readShort() }.take(n)\nfun readInts(n: Int) = generateSequence { readInt() }.take(n)\nfun readLongs(n: Int) = generateSequence { readLong() }.take(n)\nfun readFloats(n: Int) = generateSequence { readFloat() }.take(n)\nfun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)\n\nfunc main(){\nval n = readInt()\nfor (j in 1..n) {\n val v = readInt()\n println(v / 2)\n}\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b4db2597f60d7014a3eb0c84c9417ff9", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.aexp.cbp.onedatalinter\n\nfun main() {\n val numberOfQueries = readLine()!!.toInt()\n val output = mutableListOf()\n\n repeat(numberOfQueries) {\n val target = readLine()!!.toInt()\n\n val result = when {\n target < 8 -> 1\n target % 7 == 0 -> target / 7\n else -> ((target - (target % 7)) / 7) + 1\n }\n\n output.add(result)\n }\n\n output.forEach { x -> println(x) }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "78a41779d98018590baa139993f128bb", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args : Ayrray ){\n val t = readInt()\n while(t--){\n val n = readInt()\n val range = 2..7\n for(i in range){\n if(n % i != 1){\n val tmp = 0\n if(n%i != 0)tmp = 1\n println(n/i + tmp)\n break\n }\n }\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "59d51541ebc0b0a84902c3f2b2dcff0b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.io.*\n\nvar temp = readLine()\ntemp = readLine()\nwhile (temp != null) {\n val blah = temp.toInt()\n if (blah >= 2 && blah <= 7) {\n println(\"1\")\n } else {\n if (blah%2 == 0) {\n println(blah%2)\n } else {\n println(((blah-7)/2) + 1)\n }\n }\n temp = temp.readLine()\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "387b9c06b50d8bc4c3889a797895d15b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.io.*\n\nfun main() {\n var temp = readLine()\n temp = readLine()\n while (temp != null) {\n val blah = temp.toInt()\n if (blah >= 2 && blah <= 7) {\n println(\"1\")\n } else {\n if (blah%2 == 0) {\n println(blah%2)\n } else {\n println(((blah-7)/2) + 1)\n }\n }\n temp = temp.readLine()\n \n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ad3263aedba39587b1ca2195d182e435", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun readln() = readLine()!!\nfun readlnByte() = readln().toByte()\nfun readlnShort() = readln().toShort()\nfun readlnInt() = readln().toInt()\nfun readlnLong() = readln().toLong()\nfun readlnFloat() = readln().toFloat()\nfun readlnDouble() = readln().toDouble()\nfun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)\nfun readlnBigDecimal() = readln().toBigDecimal()\n\nfun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)\nfun readlnStrings() = readln().split(' ')\nfun readlnBytes() = readlnStrings().map { it.toByte() }\nfun readlnShorts() = readlnStrings().map { it.toShort() }\nfun readlnInts() = readlnStrings().map { it.toInt() }\nfun readlnLongs() = readlnStrings().map { it.toLong() }\nfun readlnFloats() = readlnStrings().map { it.toFloat() }\nfun readlnDoubles() = readlnStrings().map { it.toDouble() }\n\nfun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }\nfun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }\nfun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }\nfun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }\nfun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }\nfun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }\n\nfun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }\nfun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }\nfun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }\nfun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }\nfun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }\nfun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }\n\nfun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }\nfun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }\nfun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }\nfun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }\nfun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }\nfun readDoubleArray2d(rows: Int, cols: Int) = Array(rows) { readDoubleArray().also { require(it.size == cols) } }\n\nfun isWhiteSpace(c: Char) = c in \" \\r\\n\\t\"\n\n// JVM-only targeting code follows next\n\n// readString() via sequence is still slightly faster than Scanner\nfun readString() = generateSequence { System.`in`.read().toChar() }\n .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString(\"\")\nfun readByte() = readString().toByte()\nfun readShort() = readString().toShort()\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readFloat() = readString().toFloat()\nfun readDouble() = readString().toDouble()\nfun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)\nfun readBigDecimal() = readString().toBigDecimal()\n\nfun readBytes(n: Int) = generateSequence { readByte() }.take(n)\nfun readShorts(n: Int) = generateSequence { readShort() }.take(n)\nfun readInts(n: Int) = generateSequence { readInt() }.take(n)\nfun readLongs(n: Int) = generateSequence { readLong() }.take(n)\nfun readFloats(n: Int) = generateSequence { readFloat() }.take(n)\nfun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)\n\n\nval n = readInt()\nfor (j in 0..n){\n val v = readInt()\n println(v/2)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23ba0b7a958ed1dbb4e8aba08b445da9", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\n\n internal var br = BufferedReader(InputStreamReader(System.`in`))\n internal var st: StringTokenizer? = null\n internal var out = PrintWriter(System.out)\n\n @Throws(IOException::class)\n private fun solve() {\n val t = nextInt()\n for (i in 0 until t) {\n val x = nextInt()\n out.println(x / 2)\n }\n }\n\n @Throws(IOException::class)\n internal operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens()) {\n st = StringTokenizer(br.readLine())\n }\n return st!!.nextToken()\n }\n\n @Throws(IOException::class)\n internal fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n @Throws(IOException::class)\n internal fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n @Throws(IOException::class)\n private fun run() {\n solve()\n out.close()\n }\n\n\n fun main(args: Array) {\n run()\n }\n \n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fa8e580c73555b00bed38ae707bc97bb", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "n = int(input())\n\nfor _ in range(n):\n x = int(input())\n if x % 2 == 0 :\n print(x // 2)\n else:\n x = x - 3\n print(x // 2 + 1)\n ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f1b5c484cb4500241884ea473c096036", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var t = readLine()!!.toInt();\n while(t--) {\n var x=readLine()!!.toInt();\n var ans=(x/7),ans2=(x%7);\n if(ans2==0)\n println(ans);\n else\n println(ans+1);\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "31c0725e2dc1471a98bb9b42687c0e0c", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package a\n\nfun main() {\n val n = readLine()!!.toInt()\n for (i in 1..n) {\n val x = readLine()!!.toInt()\n when {\n x < 8 -> print(1)\n x % 2 == 0 -> print(x / 2)\n else -> print((x - 3) / 2 + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23709038bd2a4666986f358461ff8bb4", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "println(readLine())", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0de6be075564efd41a025f5c2e3febca", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n BufferedReader(InputStreamReader(System.`in`)).lineSequence().drop(1).map {\n it.toInt() / 2\n }.joinToString {\n it.toString()\n }.let(::println)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "432fa52b14f83174b3d986b4e09a78bf", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.floor\n\nfun main() {\n (1..readLine()!!.toInt())\n .map { readLine()!!.toDouble() }\n .map {\n floor(it / 2).toInt()\n }\n .forEach(::println)\n}\n\nmain()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b1029d0fe0d72c0c34224844489c4c9b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var t = readLine()!!.toInt();\n while(t--) {\n var x=readLine()!!.toInt();\n var ans=(x/7);\n var ans2=(x%7);\n if(ans2==0)\n println(ans);\n else\n println(ans+1);\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "096909dcfd9aa8745dbeb8c281e0fa3a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class ADiceRolling {\n fun main(args: Array) {\n val count = readLine()?.toInt() ?: 0\n for (i in 0 until count) {\n val target = readLine()!!.toInt()\n val roll = Math.ceil(target / 7.0)\n println(roll)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c3d5bf86dbe90fec68f442a105e24bf8", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject Main {\n @JvmStatic\n fun main(args: Array) {\n //\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n for (i in 0 until t) {\n val x = sc.nextInt()\n if (x % 2 == 0)\n println(x / 2)\n else\n println(1 + (x - 3) / 2)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e63ae33663103c7e76fc706ef1ce84ef", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{\nval t= readline()!!.toInt()\nrepeat(t)\n{\nval x= readLine()!!.toInt()\nprintln(x/2)\n}\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5d2ba6658c7234e5e0c087ea73fbd2b4", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n diceRolling()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ee957ea5750f85e9014332b742073dec", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package train\n\nclass programkt {\n fun main() {\n val t = readInt()\n for (i in 1..t) {\n val x = readInt()\n val result = x / 7 + if (x % 7 > 1) 1 else if (x % 7 == 1) 2 else 0\n println(result)\n }\n }\n\n private fun readLn() = readLine()!!\n private fun readInt() = readLn().toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "368afae4f88ee7a78bfb3175b6ceee7b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main() {\n val `in` = Scanner(System.`in`)\n val tests: Int\n var n: Int\n tests = `in`.nextInt()\n var counter = 0\n for (i in 0 until tests) {\n n = `in`.nextInt()\n if (n >= 7) {\n counter += n / 7\n n = n % 7\n }\n if (n >= 6) {\n counter += n / 6\n n = n % 6\n }\n if (n >= 5) {\n counter += n / 5\n n = n % 5\n }\n if (n >= 4) {\n counter += n / 4\n n = n % 4\n }\n if (n >= 3) {\n counter += n / 3\n n = n % 3\n }\n if (n >= 2) {\n counter += n / 2\n n = n % 2\n }\n if (n == 1) {\n counter++\n }\n println(counter)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3af5fbc9212ebebec1619f1799f6d01d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nfun start():\n{\n int t, x, i, ans;\n cin >> t;\n while(t--)\n {\n i = 7;\n cin >> x;\n ans = 0;\n while(x)\n {\n while(x - i > 1 || x - i == 0)\n {\n x -= i, ++ans;\n // cout << i << \" \";\n }\n --i;\n }\n cout << ans << \" \";\n }\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5d2646195d1b88f8f19a4cff1fe1deb7", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/*\n * This Kotlin source file was generated by the Gradle 'init' task.\n */\npackage practice\n\nfun calcurate(sum: Int): Int {\n val quotient = sum / 7\n val mod = sum % 7 // 7\u3067\u5272\u3063\u305f\u4f59\u308a\n return when {\n /*\n * 1\u306f\u51fa\u305b\u306a\u3044\u306e\u3067\u5272\u308b\u6570\u3092\u6e1b\u3089\u3059 -> quotient - 1\n * 8\u4f59\u308b\u306e\u30676\u3067\u5272\u308b -> +1\n * 2\u4f59\u308b -> +1\n * => quotient - 1 + 1 + 1\n */\n mod == 1 -> quotient + 1\n /*\n * 2\u301c6\u4f59\u308b -> +1\n */\n else -> quotient + 1\n }\n}\n\nfun dice(input: Sequence): String {\n val queryCount = input.first()!!\n\n return input.drop(1)\n .mapNotNull{it?.toInt()}\n .map(::calcurate)\n .joinToString(\"\\n\")\n}\n\nfun main(args: Array) {\n print(dice(generateSequence(::readLine)))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f0ec902e030befe44ed01585dd00382a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n val scanner = Scanner(System.`in`)\n var queries = scanner.nextInt()\n if(queries<=100) {\n while (queries > 0) {\n rollDice(scanner.nextInt())\n queries--\n }\n }\n}\n\nval diceEyes = listOf(2,3,4,5,6,7)\n\nfun rollDice(number: Int): List{\n val rolls = mutableListOf()\n var sum = 0\n var i = diceEyes.size-1\n while(sum != number && i >= 0){\n var tempSum = sum\n tempSum += diceEyes[i]\n if(tempSum <= number){\n sum = tempSum\n rolls.add(diceEyes[i])\n }else{\n i--\n }\n }\n println(\"${rolls.size}\")\n return rolls\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8dd9ed7325a30c31ef11d58f9a8425b9", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val t = readLine()!!.toInt()\n repeat(t) {\n val x = readLine()!!.toInt()\n if (x % 2 == 0){\n println(x / 2)\n }else{\n x = x - 3\n println(x / 2 + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e571164c0b445f9f0509dc1f18f5457f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " val t = readInt()\n for (i in 1..t) {\n val summ = readLine()!!.toInt()\n rekurencja(summ)\n }\n \nfun rekurencja(value: Int) {\n when {\n value in 2..7 -> println(1)\n value % 7 >= 2 -> println((value / 7) + 1)\n value % 5 >= 2 -> println((value / 5) + 1)\n value % 3 >= 2 -> println((value / 3) + 1)\n }\n}\n\nfun readInt() = readLine()!!.toInt()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2aa27c8bc20223a9a258c59f8dba1d9a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example\n\nfun main() {\n val diceNumbers = 7 downTo 2\n val rounds = readLine()!!.toInt()\n\n val queriedNumbers = (1..rounds).asSequence()\n .map { readLine() }\n .filterNotNull()\n .map { it.toInt() }\n .toList()\n\n for (queriedNumber in queriedNumbers)\n {\n var rolls = 0\n var remaining = queriedNumber\n\n for (diceNumber in diceNumbers)\n {\n val rollsWithCurrentNumber = remaining / diceNumber\n\n rolls += rollsWithCurrentNumber\n remaining -= rollsWithCurrentNumber * diceNumber\n\n if (remaining == 0)\n {\n break\n }\n }\n\n println(rolls)\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ef15093793e29225aa2227fe39cd112a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sign\n\nrepeat(readInt()) {\n val n = readInt()\n println(n / 7 + (n % 7).sign)\n}\n\nfun readInt() = readLine()?.toInt() ?: 0", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0df576b05ea7a9a09ffc9c2f23dcf7b6", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n\n val n = scanner.nextInt()\n repeat(n) {\n val t = scanner.nextInt()\n var cnt = 0\n var i += 1\n if ( i == 2 or i == 7 or ( i % 10 == 2 ) or i % 10 == 7 )\n cnt += 1\n println( cnt )\n cnt *= 0\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5849bd67f61472305ca833cf8490e236", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun readInt(): Int {\n return readLine()!.toInt(10)\n}\n\nfun main() {\n val T = readInt()\n for(i in 1..T) {\n var result = 0\n var n = readInt()\n while(n > 0) {\n if(n % 7 == 1)\n n -= 4\n else if(n >= 7)\n n -= 7\n else\n n -= n % 7\n result++\n }\n println(result)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "26046e778d8c030c9f53c639320b280a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array) {\n val input = Scanner(System.`in`)\n val rows = input.nextInt()\n for (n in 0 until rows) {\n val row = input.nextInt()\n when (row) {\n in 2..7 -> 1\n else -> row / 2 + if ((row and 1) == 0) 1 else 0\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9cc11e3b2d98ae15d0e52adade1b26a3", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var t = readLine()!!.toInt();\n while(t>0) {\n var x=readLine()!!.toInt();\n var ans=(x/7),ans2=(x%7);\n if(ans2==0)\n println(ans);\n else\n println(ans+1);\n t--;\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6642966ea10a4c40bc5b03c7dd753843", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject Main {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var T = sc.nextInt()\n while (T-- > 0) {\n val n = sc.nextInt()\n println(n)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23cce189009b3f0e9855b338f6b7ce14", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nfun main()\n{\n var sc = Scanner(System.'in')\n var l:Int = sc.nextInt()\n for(i in 1..l)\n {\n var k:Int = sc.nextInt()\n println(\"${k/2}\")\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6b58184ae1fbdcb1af2519b670510197", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun readInt(): Int {\n return readLine()!.toInt()\n}\n\nfun main() {\n val T = readInt()\n for(i in 1..T) {\n var result = 0\n var n = readInt()\n while(n > 0) {\n if(n % 7 == 1)\n n -= 4\n else if(n >= 7)\n n -= 7\n else\n n -= n % 7\n result++\n }\n println(result)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0b598899327e7b55b1585c0fb2b4d9eb", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.BufferedWriter\nimport java.io.InputStreamReader\nimport java.io.OutputStreamWriter\n\nfun main() {\n val reader = BufferedReader(InputStreamReader(System.`in`))\n val writter = BufferedWriter(OutputStreamWriter(System.out))\n val queries = reader.readLine().toInt()\n val output = IntArray(queries)\n for (i in 0..queries) {\n val point = reader.readLine().toInt()\n output[i] = getCount(point, 7)\n }\n output.forEach {\n writter.write(it)\n writter.newLine()\n }\n}\n\nfun getCount(point: Int): Int {\n return if (point in 2..7) {\n 1\n } else {\n val rem = point % 7\n if (rem == 0) {\n point / 7\n } else {\n (point / 7) + 1\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3528017ef35a867a1205664eff529964", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array)\n{\nval t=readLine()!!.toInt()\nrepeat(t)\n{\nval n=readLine()!!.toInt()\n\nprintln(x/2);\n\n}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a55f8f1c26b02eedce76804f167a8c0a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val x = 0\nx = Integer.valueOf(readLine())\nval num = 7\nval cnt = 0\nwhile(x>1){\ncnt++\nx-=2\n}\nprintln(\"$cnt\")\t", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5573be5d7acf8ee3efebc7b3eaa72805", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nobject kotlinp1 {\n @Throws(IOException::class)\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n // PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n while (sc.hasNextInt())\n {\n val t = sc.nextInt()\n val ans:Int\n if (t % 2 == 0)\n ans = t / 2\n else\n ans = (t - 3) / 2 + 1\n println(ans)\n // out.write(ans);\n }\n // out.close();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7a3874bb0d847096f01870dc554a97e5", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint flag=0;\n\nvoid jian(int m)\n{\n if(m==0)\n return;\n if(m==8)\n {\n flag+=2;\n jian(0);\n }\n if(m>=7)\n {\n flag++;\n jian(m-7);\n }\n if(m>1 &&m<7)\n {\n flag++;\n jian(0);\n }\n if(m==1)\n flag=999999;\n return ;\n}\n\nint main()\n{\n int T;\n cin>>T;\n while(T--)\n {\n int a;\n cin>>a;\n jian(a);\n cout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nint main()\n{\n int t, x, i, ans;\n cin >> t;\n while(t--)\n {\n i = 7;\n cin >> x;\n ans = 0;\n while(x)\n {\n while(x - i > 1 || x - i == 0)\n {\n x -= i, ++ans;\n // cout << i << \" \";\n }\n --i;\n }\n cout << ans << \" \";\n }\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "03262caeaf4595bc6efd69eec462f494", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val n = readLine()!!.toInt()\n for (val i = 0; i < n; i++)\n {\n val m = readLine()!!.toInt() / 2\n println(m)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb653ca57604caf1b52b1a222a2a9b9f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.util.*\n\nobject programktA {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n IntRange(1, t).forEach {\n val x = sc.nextInt()\n println(x / 2)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "20b01201ac49888955590ff055d9c354", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(`in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(`in`: InputReader, out: OutputWriter) {\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "74891efb12494f7a3e43c6858b4a31a4", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args:Array) {\n val read = Scanner(System.`in`)\n val t:Int = read.nextInt()\n for (i in 1..t)\n {\n val n:Int = read.nextInt()\n val ans = n72 + n%7\n println(\"$ans\")\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6fbb6dd92d07ce64eb38dea955c68bae", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n for (i in 1..r())\n println((r() / 2)\n}\n\nfun r() = readLine()!!.toInt()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eebf798f41c82d779e4b379cc2db49f7", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n val tN = testNumber / 2\n tn += 5\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "04c02194cd7394f12c2513b16482863b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n\n val n = scanner.nextInt()\n repeat(k) {\n val t = scanner.nextInt()\n println(t / 6 )\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b7e883d896290f74026076212d351faf", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n for (i in 1..r())\n println((r() / 2)\n}\n\ninline fun r() = readLine()!!.toInt()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6b139d60bd84bc166effbab8a36da06d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array)\n{\nval t=readLine()!!.toInt()\nrepeat(t)\n{\nval n=readLine()!!.toInt()\n\nprintln(n/2);\n\n}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bdb31f1597fcecdd93076647de531217", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class ADiceRolling {\n fun main() {\n val count = readLine()?.toInt() ?: 0\n for (i in 0 until count) {\n val target = readLine()!!.toInt()\n val roll = Math.ceil(target / 7.0)\n println(roll)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "af52f04f841f8d09d94e420c0dfc39dd", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint flag=0;\n\nvoid jian(int m)\n{\n if(m==0)\n return;\n if(m==8)\n {\n flag+=2;\n jian(0);\n }\n if(m>=7)\n {\n flag++;\n jian(m-7);\n }\n if(m>1 &&m<7)\n {\n flag++;\n jian(0);\n }\n if(m==1)\n flag=999999;\n return ;\n}\n\nint main()\n{\n int T;\n cin>>T;\n while(T--)\n {\n int a;\n cin>>a;\n jian(a);\n cout< println(\"1\")\n blah%2 == 0 -> println(blah/2)\n else -> println(((blah-7)/2) + 1)\n }\n temp = readLine()\n }\n \n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7e8680f744e9831c14e90475506df498", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val n = readLine().toInt()\nprintln(n / 3 + 1)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "58adf766a5d1334f76992da4aa59288f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n for (i in 0 until t)\n {\n val x = sc.nextInt()\n if (x % 2 == 0)\n println(x / 2)\n else\n println(1 + (x - 3) / 2)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4da7e4502491f91bdd6cfd6a18a5ec9c", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\n\nvoid jian(int m)\n{\n if(m==0)\n return;\n if(m==8)\n {\n flag+=2;\n jian(0);\n }\n if(m>=7)\n {\n flag++;\n jian(m-7);\n }\n if(m>1 &&m<7)\n {\n flag++;\n jian(0);\n }\n if(m==1)\n flag=999999;\n return ;\n}\n\nint main()\n{\n int T;\n cin>>T;\n while(T--)\n {\n int a;\n cin>>a;\n jian(a);\n cout< 1 || x - i == 0)\n {\n x -= i, ++ans;\n // cout << i << \" \";\n }\n --i;\n }\n printf(\"%d\\n\", ans);\n }\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7dc6fb6b47fb22ad962438bacd3fef0b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Solution {\n\n @JvmStatic\n fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n val n = scanner.nextInt()\n\n repeat(n){\n println(findNumberOfRoles(scanner.nextInt()))\n }\n }\n\n private fun findNumberOfRoles(q: Int): Int {\n return q/2\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9c7835ce5ecdfb2b34ccfc7da1d10161", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val tc = sc.nextInt()\n for (i in 1..tc)\n {\n val n = sc.nextInt()\n println(n)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fb87a0a4c56d8059fcb329e915d60689", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args : Array ){\n val t = readInt()\n while(t--){\n val n = readInt()\n val range = 2..7\n for(i in range){\n if(n % i != 1){\n val tmp = 0\n if(n%i != 0)tmp = 1\n println(n/i + tmp)\n break\n }\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c040abdd2fbfbbd2da19b1312e90015d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val nQueries = readLine()!!.toInt()\nfor (i in 0..nQueries) {\n val value = readLine()!!.toInt()\n println(value/7+1)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9a15dc9b4383c09a7add12cfaab403c2", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "73ab1007d85f7e4288dc5304f27e81e5", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readInt()\n for (i in 1..t) {\n val summ = readLine()!!.toInt()\n recCal(summ)\n }\n }\nfun recCal(value: Int) {\n return when {\n value in 2..7 -> return 1\n value == 8 -> return 2\n else -> recCal(value - 7) + 1\n \n }\n}\nfun check(value: Int, m: Int) = (value / m) * m + (value % m)\n\nfun readInt() = readLine()!!.toInt()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e6769e0cff87290c22741208a2f5b2ec", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "object Solution {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n for (i in 0 until t)\n {\n val x = sc.nextInt()\n if (x <= 7)\n {\n println(1)\n }\n else\n {\n println(x / 7)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cc632a2c306f7af3b8c5de1e2a919af0", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package practice\n\nfun main() {\n var t = readLine()!!.toInt()\n for (i in 0..t) {\n var number = readLine()!!.toInt()\n if (number % 2 == 0) {\n println(number / 2)\n } else {\n println((number - 1) / 2)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "94cb044e42d3f5f8aa267d02eceaa7af", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject Solution {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n for (i in 0 until t)\n {\n val x = sc.nextInt()\n if (x <= 7)\n {\n println(1)\n }\n else\n {\n println(x / 7)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b680782204d46d19a8cadd88c320af59", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "object Solution {\n\n @JvmStatic\n fun main(args: Array) {\n val t = readLine()!!.toInt()\n\n for (i in 0 until t) {\n val x = readLine()!!.toInt()\n println(x / 2)\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fb448da604956ea837acc3e1dfc376ae", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sign\n\nmain() {\n repeat(readInt()) {\n val n = readInt()\n println(n / 7 + (n % 7).sign)\n }\n}\n\nfun readInt() = readLine()?.toInt() ?: 0", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e2dfb87f9879b8b8ae129cc5d5f0b99a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun start():\n{\n var t, x, i, ans;\n scanf(\"%d\",t);\n while(t--)\n {\n i = 7;\n scanf(\"%d\",x);\n ans = 0;\n while(x)\n {\n while(x - i > 1 || x - i == 0)\n {\n x -= i, ++ans;\n // cout << i << \" \";\n }\n --i;\n }\n printf(\"%d\\n\", ans);\n }\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d2b5ffe95c75098de12e341aab7bd62", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val reader = BufferedReader(InputStreamReader(System.`in`))\n val writter = BufferedWriter(OutputStreamWriter(System.out))\n val queries = reader.readLine().toInt()\n val output = IntArray(queries)\n for (i in 0..queries) {\n val point = reader.readLine().toInt()\n output[i] = getCount(point, 7)\n }\n output.forEach {\n writter.write(it)\n writter.newLine()\n }\n}\n\nfun getCount(point: Int): Int {\n return if (point in 2..7) {\n 1\n } else {\n val rem = point % 7\n if (rem == 0) {\n point / 7\n } else {\n (point / 7) + 1\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cf8c2cde1c0b0028b3c60c13565dda1a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nfun main()\n{\n var sc = Scanner(System.in)\n var l:Int = sc.nextInt()\n for(i in 1..l)\n {\n var k:Int = sc.nextInt()\n println(\"${k/2}\")\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f9cb3e240cf8ce55800ffe8176152108", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n#define ll long long\n#define mod 1000000007\n#define pb push_back\n#define debug(x) cout<>t;\n while(t--){\n cin>>n;\n ll ans=(n/7),ans2=(n%7);\n if(ans2==0)\n cout<<(ans)<) = Dice.main(args)\n\nobject Dice {\n fun main(args: Array) {\n val t = args[0].toInt()\n (1..t+1).map {\n val points = args[it].toInt()\n val threes = if (points % 2 == 0) 0 else 1\n val twos = if (threes > 0) (points - 3) / 2 else points / 2\n twos + threes\n }.forEach {\n println(it)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ba7bad585cd7b7ad3662d87573ce50e1", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){ \n var i = 1;\n var t = readLine()\n while (i <= t)\n {\n var x = readLine()\n println((x+1)/7)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1c37fb53e06d13e8085fb3123ce849e2", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt()\n \n for (i in 1..n) {\n val sum = nextInt()\n val numberOfTimes = ceil(sum/7f).toInt()\n println(\"$numberOfTimes\")\n }\n \n println(\"${n}\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5d3b5d384a2d10c06efaa11016b0c423", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n for (i in 0 until n) {\n val x = readLine()!!.toInt()\n println(t/2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b5bf6cbba9aea8f355bb9f63bd9c9366", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint flag=0;\n\nvoid jian(int m)\n{\n if(m==0)\n return;\n if(m==8)\n {\n flag+=2;\n jian(0);\n }\n if(m>=7)\n {\n flag++;\n jian(m-7);\n }\n if(m>1 &&m<7)\n {\n flag++;\n jian(0);\n }\n if(m==1)\n flag=999999;\n return ;\n}\n\nint main()\n{\n int T;\n cin>>T;\n while(T--)\n {\n int a;\n cin>>a;\n jian(a);\n cout<) {\n val n = readLine().toInt()\n for (i in 0 until n) {\n val x = readLine().toInt()\n val t = x / 2\n if (t*2 == x) {\n pritnln(t)\n } else {\n println(t+1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9066accd7cb7f916050eb662fe967dda", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.educational56\n\nval dice: IntArray = intArrayOf(7, 6, 5, 4, 3, 2)\nvar found: Boolean = false\n\nfun solve(sum: Int): Int {\n when (sum) {\n 0 -> {\n found = true\n return 0\n }\n else -> {\n var ans: Int = 0\n for (side in dice) {\n if (!found && sum - side >= 0) {\n ans = 1 + solve(sum - side)\n }\n }\n return ans\n }\n }\n}\n\nfun main(args: Array) {\n val t: Int = readLine()!!.toInt()\n for (i in 1..t) {\n val q: Int = readLine()!!.toInt()\n found = false\n println(solve(q))\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c74e70601dc67c03cbf99d812fba72d0", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n testNumber /= 2\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3da5e78a0a04e949541c9b703211b67d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var T = sc.nextInt()\n while (T-- > 0) {\n val n = sc.nextInt()\n println(n)\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "292249b5394b054d916e38690e38f50d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example\n\nfun main(args: Array) {\n\n val diceNumbers = 7 downTo 2\n val rounds = readLine()!!.toInt()\n\n val queriedNumbers = (1..rounds).asSequence()\n .map { readLine() }\n .filterNotNull()\n .map { it.toInt() }\n .toList()\n\n for (queriedNumber in queriedNumbers)\n {\n var rolls = 0\n var remaining = queriedNumber\n\n for (diceNumber in diceNumbers)\n {\n val rollsWithCurrentNumber = remaining / diceNumber\n\n rolls += rollsWithCurrentNumber\n remaining -= rollsWithCurrentNumber * diceNumber\n\n if (remaining == 0)\n {\n break\n }\n }\n\n println(rolls)\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aba372e5b0aae167959634c11e285f27", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package A\n\nimport java.util.*\nimport kotlin.math.floor\n\nfun main(args: Array){\n\n val scanner = Scanner(System.`in`)\n val dice = arrayOf(7,6,5,4,3,2)\n\n val t = scanner.nextInt()\n val points = IntArray(t)\n for (count in 0 until t)\n points[count] = scanner.nextInt()\n\n for(point in points){\n var rolls = 0\n var tempPoint = point\n for(num in dice)\n if(num <= tempPoint)\n {\n rolls += (tempPoint/num)\n tempPoint %= num\n }\n println(rolls)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2628a086d7b7c3a76ecb08530abbd5cc", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example\n\nfun main() {\n \n val diceNumbers = 7 downTo 2\n val rounds = readLine()!!.toInt()\n\n val queriedNumbers = (1..rounds).asSequence()\n .map { readLine() }\n .filterNotNull()\n .map { it.toInt() }\n .toList()\n\n for (queriedNumber in queriedNumbers)\n {\n var rolls = 0\n var remaining = queriedNumber\n\n for (diceNumber in diceNumbers)\n {\n val rollsWithCurrentNumber = remaining / diceNumber\n\n rolls += rollsWithCurrentNumber\n remaining -= rollsWithCurrentNumber * diceNumber\n\n if (remaining == 0)\n {\n break\n }\n }\n\n println(rolls)\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "59f6f0cd8c99005517a257d76488d78a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n var testNumber = testNumber\n testNumber = 1\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "374ced0288d3c84068d7b5b9f4cb435d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args : Array ){\n val reader = Scanner(System.`in`)\n\n var t = reader.nextInt()\n while(t--){\n val n = reader.nextInt()\n val range = 2..7\n for(i in range){\n if(n % i != 1){\n var tmp = 0\n if(n%i != 0)tmp = 1\n println(n/i + tmp)\n break\n }\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1997242b2b21095f3a6ca3f2ff7cf15f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "object ProblemA {\n\n @JvmStatic\n fun main(args: Array) {\n val input = readLine()!!\n val testCases = input.toInt()\n for (i in 1..testCases) {\n val n = readLine()!!.toInt()\n println((n / 7) + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dacca97b9ff2f803d2dc248d31a3dc29", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\n\nclass Main @Throws(IOException::class)\nconstructor() {\n\n internal var br = BufferedReader(InputStreamReader(System.`in`))\n internal var st: StringTokenizer? = null\n internal var out = PrintWriter(System.out)\n\n @Throws(IOException::class)\n private fun solve() {\n val t = nextInt()\n for (i in 0 until t) {\n val x = nextInt()\n out.println(x / 2)\n }\n }\n\n @Throws(IOException::class)\n internal operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens()) {\n st = StringTokenizer(br.readLine())\n }\n return st!!.nextToken()\n }\n\n @Throws(IOException::class)\n internal fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n @Throws(IOException::class)\n internal fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n @Throws(IOException::class)\n private fun run() {\n solve()\n out.close()\n }\n\n companion object {\n\n @Throws(IOException::class)\n @JvmStatic\n fun main(args: Array) {\n Main().run()\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "02df4463e971b7b36c802a27eb9c6ff2", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package main\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n var T = readInt()\n while(T>0) {\n var x = readInt()\n println(\"%d\".format(x))\n T--\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a436643856cf99b9bfe9643cc298e56f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.test.assertEquals\n\nval dice = 7 downTo 2\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\n\nprivate fun rollTry(pointToGet: Int): Int {\n if (pointToGet in dice) return 1\n\n var rem = pointToGet\n var counter = 0\n while (rem > 0) {\n dice.forEach rolling@{\n counter += rem / it\n rem %= it\n if (rem == 0) return@rolling\n }\n if (rem != 0) {\n rem = pointToGet\n counter = 0\n }\n }\n return counter\n}\n\nfun main() {\n val queryNum = readInt()\n repeat(queryNum) {\n val pointToGet = readInt()\n println(rollTry(pointToGet))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c52d4050e77c3f67c3482b435f3e6e96", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package a\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n for (i in 1..n) {\n val x = readLine()!!.toInt()\n when {\n x < 8 -> print(1)\n x % 2 == 0 -> print(x / 2)\n else -> print((x - 3) / 2 + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "63aa795861b9df7d3f44900424404b9e", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package contest\n\nclass Contest {\n\n fun main(args: Array) {\n val n = readLine()!!.toInt()\n for (i in 0 until n) {\n val t = readLine()!!.toInt()\n if (t <= 7) {\n println(1)\n continue\n }\n val s = t / 7\n val rem = t % 7\n if (rem == 1) {\n println(s)\n } else {\n println(s + 1)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1201a1cea304c9d263be6f86e4590478", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nobject codeforces {\n internal var pw = PrintWriter(System.out)\n @Throws(Exception::class)\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val x = sc.nextInt()\n while (x-- > 0)\n {\n val max = 0\n val y = sc.nextInt()\n val count = 0\n for (j in 7 downTo 2)\n {\n val z = y\n for (i in j downTo 2)\n {\n count += (z / i)\n z = (z % i)\n }\n if (z == 0) {\n pw.println(count)\n break\n }\n }\n }\n pw.flush()\n pw.close()\n }\n internal class pair(x:Int, y:Int):Comparable {\n var x:Int = 0\n var y:Int = 0\n init{\n this.x = x\n this.y = y\n }\n public override fun compareTo(o:pair):Int {\n if (x == o.x) return o.y - y\n return x - o.x\n }\n public override fun toString():String {\n return x + \" \" + y\n }\n }\n internal class Scanner {\n var st:StringTokenizer\n var br:BufferedReader\n constructor(system:InputStream) {\n br = BufferedReader(InputStreamReader(system))\n }\n @Throws(Exception::class)\n constructor(file:String) {\n br = BufferedReader(FileReader(file))\n }\n @Throws(IOException::class)\n fun next():String {\n while (st == null || !st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st.nextToken()\n }\n @Throws(IOException::class)\n fun nextLine():String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextInt():Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextDouble():Double {\n val x = next()\n val sb = StringBuilder(\"0\")\n val res = 0.0\n val f = 1.0\n val dec = false\n val neg = false\n val start = 0\n if (x.get(0) == '-')\n {\n neg = true\n start++\n }\n for (i in start until x.length)\n if (x.get(i) == '.')\n {\n res = java.lang.Long.parseLong(sb.toString()).toDouble()\n sb = StringBuilder(\"0\")\n dec = true\n }\n else\n {\n sb.append(x.get(i))\n if (dec)\n f *= 10.0\n }\n res += java.lang.Long.parseLong(sb.toString()) / f\n return res * (if (neg) -1 else 1)\n }\n @Throws(IOException::class)\n fun nextChar():Char {\n return next().get(0)\n }\n @Throws(IOException::class)\n fun nextLong():Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun ready():Boolean {\n return br.ready()\n }\n @Throws(IOException::class)\n fun nextIntArray(n:Int):IntArray {\n val a = IntArray(n)\n for (i in 0 until n)\n a[i] = nextInt()\n return a\n }\n @Throws(IOException::class)\n fun nextLongArray(n:Int):LongArray {\n val a = LongArray(n)\n for (i in 0 until n)\n a[i] = nextLong()\n return a\n }\n @Throws(IOException::class)\n fun nextHashMap(n:Int):HashMap {\n val map = HashMap()\n for (i in 0 until n)\n {\n val x = nextInt()\n val b = (map as java.util.Map).getOrDefault(x, 0)\n map.put(x, b + 1)\n }\n return map\n }\n @Throws(IOException::class)\n fun nextTreeMap(n:Int):TreeMap {\n val map = TreeMap()\n for (i in 0 until n)\n {\n val x = nextInt()\n val b = (map as java.util.Map).getOrDefault(x, 0)\n map.put(x, b + 1)\n }\n return map\n }\n @Throws(IOException::class)\n fun nextHashSet(n:Int):HashSet {\n val set = HashSet()\n for (i in 0 until n) set.add(nextInt())\n return set\n }\n @Throws(IOException::class)\n fun nextTreeSet(n:Int):TreeSet {\n val set = TreeSet()\n for (i in 0 until n) set.add(nextInt())\n return set\n }\n @Throws(IOException::class)\n fun nextLongArraySorted(n:Int):LongArray {\n val arr = nextLongArray(n)\n Arrays.parallelSort(arr)\n return arr\n }\n @Throws(IOException::class)\n fun nextIntArraySorted(n:Int):IntArray {\n val arr = nextIntArray(n)\n Arrays.parallelSort(arr)\n return arr\n }\n @Throws(InterruptedException::class)\n fun waitForInput() {\n Thread.sleep(3000)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "734e154a905448dde3df301756a6d795", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n\n val n = scanner.nextInt()\n repeat(k) {\n val t = scanner.nextInt()\n println(t / 6 +\"\\n\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "53310e510e12ea2c147725fba3cabb38", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/**\n *\n * @author YCHT\n */\npackage heroes.practice\n\nfun main() {\n for (i in 1..readNumber()) {\n println(readNumber())\n }\n}\n\nfun readNumber(): Int {\n return readLine()!!.toInt()\n}\n\nfun readNumbers(): List {\n return readLine()!!.split(' ').map { it.toInt() }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "82e8de1fa9cb84c7155d703ba16c327b", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array){\n if (args.isNotEmpty()) {\n var a:Int\n for (i in 1..args[0].toInt()) {\n a = (args[i].toInt() / 7)+1\n return a\n println(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "73ad976ca7ceca1242cb0de584d5d221", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){ \n while (1)\n {\n var i = 1;\n var t: Int =Integer.valueOf(readLine())\n while (i <= t)\n {\n var x: Int =Integer.valueOf(readLine())\n println((x-1)/7 + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "af84bc237c40849d8e4b9114d9eb56b1", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nusing ll = long long ;\nint x;\nint dp[110];\nint solve(int a){\nif(a==x)return 0;\nif(a>x)return 1e8;\nif(dp[a]!=-1)return dp[a];\nint d = 1e8;\nfor(int i = 2 ; i < 8 ; i++){\n d=min(d,1+solve(a+i));\n}\nreturn dp[a]=d;\n}\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n int _(1);\n cin>>_;\n while(_--){\n cin>>x;\n memset(dp,-1,sizeof dp);\n cout<= 6)\n {\n j++\n x -= 6\n }\n \n \n \n } \n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c517c8653be88dd9adb34320cfaddfdc", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject kotlin_a {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = Problem()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class Problem {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n val tN = testNumber / 2\n val t = `in`.readInt()\n val x = IntArray(t)\n for (i in 0 until t) x[i] = `in`.readInt()\n for (i in 0 until t) out.printLine(x[i] / 2)\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "95ef4a807e03e210d9dcaae178abbd81", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class problem {\n\n @JvmStatic\n fun main(args: Array) {\n val input = readLine()!!\n val testCases = input.toInt()\n for (i in 1..testCases) {\n val n = readLine()!!.toInt()\n println((n / 7) + 1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b6538e399bdc44cc01aae3ce01a1f7b4", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.ceil\n\n(1..readLine()!!.toInt())\n .map { readLine()!!.toDouble() }\n .map {\n ceil(it / 2).toInt()\n }\n .forEach(::println)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "025e3854d79593084fc858db95152ecf", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n for (j in 1..n) {\n val v = readInt()\n println(v / 2)\n }\n}\n\nfun readln() = readLine()!!\nfun readlnByte() = readln().toByte()\nfun readlnShort() = readln().toShort()\nfun readlnInt() = readln().toInt()\nfun readlnLong() = readln().toLong()\nfun readlnFloat() = readln().toFloat()\nfun readlnDouble() = readln().toDouble()\nfun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)\nfun readlnBigDecimal() = readln().toBigDecimal()\n\nfun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)\nfun readlnStrings() = readln().split(' ')\nfun readlnBytes() = readlnStrings().map { it.toByte() }\nfun readlnShorts() = readlnStrings().map { it.toShort() }\nfun readlnInts() = readlnStrings().map { it.toInt() }\nfun readlnLongs() = readlnStrings().map { it.toLong() }\nfun readlnFloats() = readlnStrings().map { it.toFloat() }\nfun readlnDoubles() = readlnStrings().map { it.toDouble() }\n\nfun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }\nfun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }\nfun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }\nfun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }\nfun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }\nfun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }\n\nfun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }\nfun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }\nfun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }\nfun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }\nfun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }\nfun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }\n\nfun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }\nfun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }\nfun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }\nfun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }\nfun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }\nfun readDoubleArray2d(rows: Int, cols: Int) = Array(rows) { readDoubleArray().also { require(it.size == cols) } }\n\nfun isWhiteSpace(c: Char) = c in \" \\r\\n\\t\"\n\n// JVM-only targeting code follows next\n\n// readString() via sequence is still slightly faster than Scanner\nfun readString() = generateSequence { System.`in`.read().toChar() }\n .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString(\"\")\n\nfun readByte() = readString().toByte()\nfun readShort() = readString().toShort()\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readFloat() = readString().toFloat()\nfun readDouble() = readString().toDouble()\nfun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)\nfun readBigDecimal() = readString().toBigDecimal()\n\nfun readBytes(n: Int) = generateSequence { readByte() }.take(n)\nfun readShorts(n: Int) = generateSequence { readShort() }.take(n)\nfun readInts(n: Int) = generateSequence { readInt() }.take(n)\nfun readLongs(n: Int) = generateSequence { readLong() }.take(n)\nfun readFloats(n: Int) = generateSequence { readFloat() }.take(n)\nfun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)\n\n\n\n\n\n\nmain()", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5572ce96691f3bf96a97c4359ab1143c", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){ \n var i = 1;\n var t = readline()\n while (i <= t)\n {\n var x = readline()\n println((x+1)/7)\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "399e53456a874d166641790881a4ed9d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val tc = sc.nextInt()\n while (--tc >= 0)\n {\n val n = sc.nextInt()\n println(n)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ff69252c484cfa0d35de68b7fb79036a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class A281 {\n fun main(args: Array) {\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d1579d1fc4b460c9639347e1136eb13c", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val str = readLn()\n\tprintln(str.elementAt(0).toUpperCase() + str.drop(1))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c337bd059cbdab02bd2140a923bddf9c", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.FileInputStream\nimport java.io.InputStreamReader\n\nfun main(args: Array) {\n val reader = readInput1File()\n reader.use {\n val el = it.readLine().fromStringToListInt(\"+\")?.sorted()\n val res: StringBuilder = StringBuilder()\n el?.forEach { it1 -> res.append(it1).append(\"+\") }\n print(res.removeSuffix(\"+\").toString())\n }\n}\n\nfun String?.fromStringToListInt(delimeter: String) = this?.split(delimeter)?.map(String::toInt)\nfun readSysIn(): BufferedReader = BufferedReader(InputStreamReader(System.`in`))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1e6b1214667ba4ccdbf4e07af8ffe483", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val result : StringBuffer = StringBuffer()\n readLine()?.split(\"+\")?.sortedBy { it.toInt() }?.forEach { result.append(it + \"+\") }.also { result.deleteCharAt(result.length-1);print(result.toString())}\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d80ebf1c8ecaf212e281be4c22cf91d8", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import com.sun.jdi.connect.Connector\nimport java.util.*\n\n\nfun main() {\n\n val read = Scanner(System.`in`)\n\n\n val s = readLine()!!.split(\"+\").sorted()\n var ans = \"\"\n for(i in s) ans+= \"$i+\"\n print(ans.dropLast(1))\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1b2e03251d75415a8a89743cb62b927e", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject MainKt {\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream: OutputStream = System.out\n val `in` = InputReader(inputStream)\n val out = OutputWriter(outputStream)\n val solver = HelpfulMaths()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class HelpfulMaths {\n fun solve(testNumber: Int, `in`: InputReader, out: OutputWriter) {\n var s = `in`.next()\n s = s.replace(\"[+]\".toRegex(), \"\")\n if (s.length == 1) {\n out.println(s)\n } else {\n val a = s.toCharArray()\n Arrays.sort(a)\n for (i in a.indices) {\n out.print(a[i])\n if (i < a.size - 1) out.print(\"+\")\n }\n }\n }\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar = 0\n private var numChars = 0\n private val filter: SpaceCharFilter? = null\n fun read(): Int {\n if (numChars == -1) {\n throw InputMismatchException()\n }\n if (curChar >= numChars) {\n curChar = 0\n numChars = try {\n stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0) {\n return -1\n }\n }\n return buf[curChar++].toInt()\n }\n\n fun nextString(): String {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n val res = StringBuilder()\n do {\n if (Character.isValidCodePoint(c)) {\n res.appendCodePoint(c)\n }\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c) ?: isWhitespace(c)\n }\n\n operator fun next(): String {\n return nextString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n\n companion object {\n fun isWhitespace(c: Int): Boolean {\n return c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1\n }\n }\n\n }\n\n internal class OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream?) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer?) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any?) {\n for (i in 0 until objects.size) {\n if (i != 0) {\n writer.print(' ')\n }\n writer.print(objects[i])\n }\n }\n\n fun println(vararg objects: Any?) {\n print(*objects)\n writer.println()\n }\n\n fun print(i: Char) {\n writer.print(i)\n }\n\n fun close() {\n writer.close()\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "53cab861ed9b988a93a93884d2ef90ee", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import com.sun.jdi.connect.Connector\nimport java.util.*\n\n\nfun main() {\n\n val read = Scanner(System.`in`)\n\n\n val s = readLine()!!.split(\"+\").sorted()\n for(i in s ) {\n\n if (i == s[0]) {\n print(s)\n } else {\n print(\"+$s\")\n }\n break\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2e837743942ec26e4bd5a44ce452e146", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example.myapplication\n\nimport java.util.*\n\nfun main() {\n val n: Int\n val a: Int\n val b: Int\n val c: Int\n\n with(Scanner(System.`in`)) {\n n = nextInt()\n a = nextInt()\n b = nextInt()\n c = nextInt()\n }\n\n val max1 = maxOf(a, b, c)\n val max2 = if (max1 == a) maxOf(b, c) else if (max1 == b) maxOf(a, c) else maxOf(a, b)\n val max3 = minOf(a, b, c)\n\n var result = 4000\n\n for(i1 in n / max1 downTo 0) {\n val remains1 = n - i1 * max1\n if (remains1 == 0 && i1 == 1) continue\n for(i2 in remains1 / max2 downTo 0) {\n val remains2 = remains1 - i2 * max2\n if (remains2 == 0 && i1 == 0 && i2 ==1) continue\n if (remains2 % max3 == 0 && i1 + i2 + remains2 / max3 != 1) {\n result = minOf(i1 + i2 + remains2 / max3, result)\n }\n }\n }\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d951f581a696adee19ec57e19396485", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n println(ex1(n, a, b, c))\n}\n\nfun ex1(n: Int, a: Int, b: Int, c: Int): Int {\n var answer = 0\n for (ia in 0..n) {\n for (ib in 0..n) {\n val num = n - ib * b - ia * a\n if (num < 0) break\n if (num % c == 0) {\n val ic = num / c\n answer = max(answer, ia + ib + ic)\n }\n }\n }\n\n return answer\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "476b029d56c7999cb7eef50744132af7", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "class Memorize(val func: (T) -> R) {\n val cache = mutableMapOf()\n\n operator fun getValue(thisRef: Any?, property: KProperty<*>) = { n: T ->\n cache.getOrPut(n) { func(n) }\n }\n}\n\nvar a by Delegates.notNull()\nvar b by Delegates.notNull()\nvar c by Delegates.notNull()\n\nval f:(Int) -> Int by Memorize { len ->\n when {\n len < 1 -> -Int.MAX_VALUE\n len == a -> maxOf(0, f(len - b), f(len - c)) + 1\n len == b -> maxOf(0, f(len - a), f(len - c)) + 1\n len == c -> maxOf(0, f(len - a), f(len - b)) + 1\n else -> maxOf(f(len - a), f(len - b), f(len - c)) + 1\n }\n}\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val (l, x, y, z) = r.readLine()!!.split(\" \").map { it.toInt() }\n val (l, x, y, z) = listOf(100, 1, 2, 3)\n a = x\n b = y\n c = z\n println(f(l))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "92a718209f3182671701461754ac2c7b", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(){\n val t = readLine()!!.toInt()\n\tfor (i in 1..t){\n var m = readLine()!!.toInt()\n\tvar n = readLine()!!.split(\" \").map { it.toInt() }\n var b = m\n var count = 0\n var counta:Int\n var countb:Int\n var totala = 0\n var totalb = 0\n var step = 0\n \twhile (b>a+1){\n counta = 0\n while ((counta<=count)&&(a+1) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n \n\t print(NOOFMOVES)\n\t print(\" \")\n print(ALICEEATS)\n print(\" \")\n\t println(BOBEATS)\n \n }\n }\n }\n fun getMoves(arr:IntArray) {\n var aliceEats = 0\n var bobEats = 0\n var i = 0\n var j = arr.size - 1\n var noOfMoves = 0\n var previous = 0\n var isAliceTurn = true\n var isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e4e7a3d5672bb3935973208f9be42bee", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n@kotlin.ExperimentalStdlibApi\n@OptIn(kotlin.ExperimentalStdlibApi::class)\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n var q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "de192ebc783fbc7ac84c6c02de1b95d3", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\n\nprivate fun splitString() = readLn().split(\" \")\nprivate fun readInts() = splitString().map { it.toInt() }.toMutableList()\n\n@kotlin.ExperimentalStdlibApi\nfun main() {\n val t = readInt()\n (1..t).forEach {\n val a = readInt()\n val b = readInts()\n solve(a, b)\n }\n}\n\nfun solve(a: Int, b: MutableList) {\n var alice = 0\n var aliceSum = 0\n var bob = 0\n var bobSum = 0\n var rounds = 0\n var aliceRound = true\n while (b.size > 0) {\n when (aliceRound) {\n true -> {\n do {\n alice += b.removeFirst()\n } while (alice <= bob && b.isNotEmpty())\n aliceSum += alice\n bob = 0\n aliceRound = false\n rounds++\n }\n false -> {\n do {\n bob += b.removeLast()\n } while (bob <= alice && b.isNotEmpty())\n bobSum += bob\n alice = 0\n aliceRound = true\n rounds++\n }\n }\n }\n println(\"$rounds $aliceSum $bobSum\")\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3f22e1940cdb1f5d3f3276dc72d7f854", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main (args:Array)\n{\n val read = Scanner(System.`in`)\n var t=read.nextInt()\n while(t>0)\n{t--\n var n=read.nextInt()\n var ar= Array(n){0}\n var x:Int = 0\n while( x < n)\n {\n ar[x] = read.nextInt()\n x++\n }\n var al:Int=0\nvar bob:Int =n-1\nvar ind:Int=0\nvar mov:Int\nvar candal:Int\nvar candbob:Int\n init{\n candal = 0\n candbob = 0\nmov=0\n }\nwhile(indcurbob)\n{break\n}\n}\ncandal=candal+cural\nmov++\nfor(j in bob downTo al)\n{\n curbob+=ar[j]\nbob++\nind++\nif(cural PrevEat) {\n PrevEat = ThisEat\n ThisEat = 0\n TurnWho = if (Turn == 0) 1 else 0\n TurnCnt += 1\n }\n }\n print(\"$TurnCnt $A_sum $B_sum\\n\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8e7c52fa8465b37a63a33f100ed5ac8d", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package codeforces.KotlinHeroesPractice4\n\nfun readString() = readLine()!!\n\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\n\nfun readIntArray() = readString().split(\" \").map { it.toInt() }\nfun readLongArray() = readString().split(\" \").map { it.toLong() }\n\nfun main() {\n repeat(1) {\n val n = readInt()\n val set = readIntArray().toMutableList()\n var turns = 0\n var aTotal = 0\n var bTotal = 0\n var last = 0\n var a = true\n while (set.isNotEmpty()) {\n turns++\n var current = 0\n while (current <= last && set.isNotEmpty()) {\n if (a) {\n current += set.first()\n set.removeAt(0)\n } else {\n current += set.last()\n set.removeAt(set.lastIndex)\n }\n }\n if (a) {\n aTotal += current\n } else {\n bTotal += current\n }\n last = current\n a = !a\n }\n println(\"$turns $aTotal $bTotal\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1f4c5a7f63c39a24d4b62c5792d98c1a", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args:Array) { \n val input = Scanner(System.`in`)\n val t = input.nextInt()\n for(i in 0 until t){\n val n = input.nextInt() \n var i:Int = 0\n val sz:Int = input.nextInt()\n var arr = Array(sz){0}\n while( i < sz){\n arr[i] = readLine()!!.toInt()\n i++\n }\n var l:Int = 0\n var r:Int = sz-1\n var a:Int = 0\n var b:Int = 0\n var mov:Int = 0\n var mx:Int = 0\n var f:Int = 0\n while(l <= r){\n f = 1-f\n mov++\n if(f == 1){\n var sum:Int = 0\n while(sum <= mx || l <= r){\n sum += arr[l]\n l++\n }\n a += sum\n mx = sum\n }\n else{\n var sum:Int = 0\n while(sum <= mx || l <= r){\n sum += arr[r]\n r--\n }\n b += sum\n mx = sum\n }\n }\n println(mov + \" \" + a + \" \" + b)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "04e5f722f3ad0ca8226c378be06a80bb", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.*\n\nfun main(args: Array) {\n\tval t = readLine()!!.toInt()\n\tfor (i in 1..t) {\n\t\tval n = readLine()!!.toInt()\n\t\tval arr = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\t\tval (total, a, b) = solve(n, arr)\n\t\tprintln(\"%d %d %d\".format(total, a, b))\n\t}\n}\n\nfun solve(n: Int, arr: IntArray): Triple {\n\tval cumsum_1 = IntArray(n)\n\tval cumsum_2 = IntArray(n)\n\tcumsum_1[0] = arr[0]\n\tcumsum_2[n - 1] = arr[n - 1]\n\tfor (i in 1..(n - 1)) {\n\t\tcumsum_1[i] = cumsum_1[i - 1] + arr[i]\n\t\tcumsum_2[n - 1 - i] = cumsum_2[n - i] + arr[n - 1 - i]\n\t}\n\tvar a = 0\n\tvar index_1 = -1\n\tvar b = 0\n\tvar index_2 = n\n\tvar prv = 0\n\tvar turn = 0\n\twhile (index_2 - index_1 > 1) {\n\t\tturn += 1\n\t\tif (turn % 2 == 1) {\n\t\t\tval base = if (index_1 == -1) { 0 } else { cumsum_1[index_1] }\n\t\t\tval index = binary_search(prv + base, index_1 + 1, index_2 - 1, cumsum_1)\n\t\t\tif (index == null) {\n\t\t\t\tprv = cumsum_1[index_2 - 1] - base\n\t\t\t\ta += prv\n\t\t\t\tindex_1 = index_2 - 1\n\t\t\t} else {\n\t\t\t\tprv = cumsum_1[index] - base\n\t\t\t\ta += prv\n\t\t\t\tindex_1 = index\n\t\t\t}\n\t\t} else {\n\t\t\tval base = if (index_2 == n) { 0 } else { cumsum_2[index_2] }\n\t\t\tval index = binary_search(prv + base, index_2 - 1, index_1 + 1, cumsum_2)\n\t\t\tif (index == null) {\n\t\t\t\tprv = cumsum_2[index_1 + 1] - base\n\t\t\t\tb += prv\n\t\t\t\tindex_2 = index_1 + 1\n\t\t\t} else {\n\t\t\t\tprv = cumsum_2[index] - base\n\t\t\t\tb += prv\n\t\t\t\tindex_2 = index\n\t\t\t}\n\t\t}\n\t}\n\treturn Triple(turn, a, b)\n}\n\nfun binary_search(x: Int, s: Int, e: Int, arr: IntArray): Int? {\n\tif (arr[e] <= x) {\n\t\treturn null\n\t}\n\tif (arr[s] > x) {\n\t\treturn sz\n\t}\n\tvar l = s\n\tvar r = e\n\twhile (abs(r - l) > 1) {\n\t\tval mid = (l + r) / 2\n\t\tif (arr[mid] > x) {\n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid\n\t\t}\n\t}\n\treturn r\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8d1d8a0fc5f85eb186af084b51558bea", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "#include\n#define ll long long int\n#define ld long double\n#define pb push_back\n#define pob pop_back\n#define vi vector\n#define mp make_pair\n#define sz size()\n#define rep1(i,n) for(ll i=1;i<=n;i++)\n#define rep(i,n) for(ll i=0;i\n#define mod 1000000007\nusing namespace std;\n\n\n\n\n\n/*\nvoid sieve()\n{\n ll n=100000;\n ll i;\n ll prime[n+1]={0}; \n ll j;\n prime[1]=1;\n prime[0]=1;\n for(i=2;i*i<=n;i++)\n {\n if(prime[i]==0)\n {\n for(j=2*i;j<=n;j=j+i)\n {\n prime[j]=1;\n }\n }\n }\n \n ll cnt=0;\n for(i=0;i<=n;i++)\n {\n \tif(prime[i]==0)\n \t{\n \t\tv.pb(i);\n\t\t}\n }\n // return v;\n}\n*/\n\n\n\n\nint main()\n{\n\tll t;\n\tcin>>t;\n\twhile(t--)\n\t{\n\t\t\n\tchar ch;\n\t//db aa,bb,cc,dd,xx;\n\tstring s1,s2,s3,str;\n ll i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;\n cin >> n;\n low=1;high=n-1;\n ll arr[n];\n rep(i,n)\tcin >> arr[i];\n x=0;y=0;z=0;ll w=0;\n ll cntt=0;\n for(i=0;ihigh){\n \t\t\tok=false;break;\n \t\t}\n \t}\n \tans++;x+=z;if(!ok)\tbreak;\n }\n ans++;\n cout<) {\n var alice = 0\n var aliceSum = 0\n var bob = 0\n var bobSum = 0\n var rounds = 0\n var aliceRound = true\n while (b.size > 0) {\n when (aliceRound) {\n true -> {\n do {\n alice += b.removeFirst()\n } while (alice <= bob && b.isNotEmpty())\n aliceSum += alice\n bob = 0\n aliceRound = false\n rounds++\n }\n false -> {\n do {\n bob += b.removeLast()\n } while (bob <= alice && b.isNotEmpty())\n bobSum += bob\n alice = 0\n aliceRound = true\n rounds++\n }\n }\n }\n println(\"$rounds $aliceSum $bobSum\")\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0959c45e81154d00589985ddb7e88ba5", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject ChocolateBar {\n var NOOFMOVES:Int = 0\n var ALICEEATS:Int = 0\n var BOBEATS:Int = 0\n @JvmStatic fun main(args:Array) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n \n\t print(NOOFMOVES)\n\t print(\" \")\n print(ALICEEATS)\n print(\" \")\n\t println(BOBEATS)\n \n }\n }\n }\n fun getMoves(arr:IntArray) {\n var aliceEats = 0\n var bobEats = 0\n var i = 0\n var j = arr.size - 1\n var noOfMoves = 0\n var previous = 0\n var isAliceTurn = true\n var isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8a9894919ce58523a5904cf171f1a9dc", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readLine()!!.toInt()\n for (i in 1..t) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(' ').map(String::toInt)\n val deque = mutableListOf()\n for (a in aa) deque.add(a)\n val ans = arrayListOf(0, 0)\n var cur = 0\n var move = 0\n var m = 0\n while (deque.isNotEmpty()) {\n if (cur == 0) {\n cur = deque.removeFirst()\n ans[0] += cur\n } else {\n var x = 0\n while (deque.isNotEmpty()) {\n x += if (move == 0) deque.removeFirst() else deque.removeLast()\n if (x > cur) break\n }\n ans[move] += x\n cur = x\n }\n move = 1 - move\n m++\n }\n println(\"$m \" + ans[0] + \" \" + ans[1])\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bbfa64bc40d430661c005e0f51ce6883", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array): Unit = with(Scanner(System.`in`)) {\n repeat(nextInt()) {\n val n = nextInt()\n val d = ArrayDeque((0 until n).map { nextInt() })\n var a = 0\n var b = 0\n var prev = 0\n var turn = true\n var turns = 0\n while (!d.isEmpty()) {\n var x = 0\n turns++\n if (turn) {\n do {\n x += d.pollFirst()\n }\n while (!d.isEmpty() && x <= prev)\n a += x\n }\n else {\n do {\n x += d.pollLast()\n }\n while (!d.isEmpty() && x <= prev)\n b += x\n }\n prev = x\n turn = !turn\n }\n println(\"$turns $a $b\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ac7a3de9cb9a6317f6eaf130a394c7b9", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject ChocolateBar {\n var NOOFMOVES:Int = 0\n var ALICEEATS:Int = 0\n var BOBEATS:Int = 0\n @JvmStatic fun main(args:Array) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n println(NOOFMOVES + \" \" + ALICEEATS + \" \" + BOBEATS)\n }\n }\n }\n fun getMoves(arr:IntArray) {\n val aliceEats = 0\n val bobEats = 0\n val i = 0\n val j = arr.size - 1\n val noOfMoves = 0\n val previous = 0\n val isAliceTurn = true\n val isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n val sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n val sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2d20525a60636f6a4c20271d9c49228f", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n var q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6b6a267db4a97ca3281b5df46cfab845", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n fun main(args: Array) {\n val `in` = Scanner(System.`in`)\n for (T in `in`.nextInt() downTo 1) {\n val n = `in`.nextInt()\n val a = IntArray(n)\n for (i in 0 until n) {\n a[i] = `in`.nextInt()\n }\n val s = IntArray(n + 1)\n for (i in 0 until n) {\n s[i + 1] = s[i] + a[i]\n }\n var i = 0\n var j = n - 1\n var steps = 0\n var alice = 0\n var bob = 0\n val used = BooleanArray(n)\n var prev = 0\n while (true) {\n run {\n var t = 0\n while (i < n && prev >= t) {\n if (used[i]) {\n i++\n continue\n }\n t += a[i]\n used[i] = true\n i++\n }\n if (t != 0) {\n steps++\n alice += t\n prev = t\n } else\n break\n }\n run {\n var t = 0\n while (j >= 0 && prev >= t) {\n if (used[j]) {\n j--\n continue\n }\n t += a[j]\n used[j] = true\n j--\n }\n if (t != 0) {\n steps++\n bob += t\n prev = t\n } else\n break\n }\n }\n println(\"$steps $alice $bob\")\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4696de60df03f0dba4f4fb31f2d18880", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "private fun solve() {\n val n = readInt()\n var l = 0\n var r = n-1\n var a = mutableListOf()\n repeat(n) {\n a.add(readInt())\n }\n var pre = 0\n var times = 0\n var turn = 0\n var A = 0\n var B = 0\n while (true) {\n var cur = 0\n if (turn==0) {\n while (l<=r && cur<=pre) {\n cur += a[l];\n ++l;\n }\n A += cur\n }\n else {\n while (l<=r && cur<=pre) {\n cur += a[r];\n --r;\n }\n B += cur\n }\n pre = cur\n ++times\n if (l>r) \n break\n turn = 1 - turn\n }\n println (\"${times.toString()} ${A.toString()} ${B.toString()} \")\n}\n\nfun main () {\n val n = readInt()\n for (i in 1..n) solve()\n}\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c2f94e8fc21f60919ccee4c4ac9cd8a8", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\npublic class ChocolateBar {\n var NOOFMOVES:Int = 0\n var ALICEEATS:Int = 0\n var BOBEATS:Int = 0\n \npublic fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n \n\t print(NOOFMOVES)\n\t print(\" \")\n print(ALICEEATS)\n print(\" \")\n\t println(BOBEATS)\n \n }\n }\n }\n fun getMoves(arr:IntArray) {\n var aliceEats = 0\n var bobEats = 0\n var i = 0\n var j = arr.size - 1\n var noOfMoves = 0\n var previous = 0\n var isAliceTurn = true\n var isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b6aee6b27f84fe0755e4424ed5d68dd9", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n\n var count = readLine()!!.toInt()\n val results = mutableListOf()\n\n while (count-- != 0) {\n val size = readLine()\n val sweets = readLine()!!.split(' ').map { it.toInt() }.toMutableList()\n results.add(game(sweets))\n }\n\n results.forEach { r ->\n println(\"${r.moves} ${r.leftWeight} ${r.rightWeight}\")\n }\n}\n\ndata class GameResult(\n val moves: Int,\n val leftWeight: Int,\n val rightWeight: Int\n)\n\nfun game(sweets: MutableList): GameResult {\n var moves = 0\n var leftWeight = 0\n var rightWeight = 0\n\n while (sweets.isNotEmpty()) {\n leftWeight += eatLeft(rightWeight, sweets)\n moves++\n\n if (sweets.isEmpty())\n break\n\n rightWeight += eatRight(leftWeight, sweets)\n moves++\n }\n\n return GameResult(moves, leftWeight, rightWeight)\n}\n\nfun eatLeft(min: Int, sweets: MutableList): Int {\n var eaten = 0\n do {\n eaten += sweets.removeAt(0)\n } while (eaten < min && sweets.isNotEmpty())\n\n return eaten\n}\n\nfun eatRight(min: Int, sweets: MutableList): Int {\n var eaten = 0\n do {\n eaten += sweets.removeAt(sweets.size - 1)\n } while (eaten < min && sweets.isNotEmpty())\n\n return eaten\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "36c233a34dec5f353a2bf38b221cb2a0", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nclass ChocolateBar {\n var NOOFMOVES:Int = 0\n var ALICEEATS:Int = 0\n var BOBEATS:Int = 0\n @JvmStatic fun main(args:Array) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n \n\t print(NOOFMOVES)\n\t print(\" \")\n print(ALICEEATS)\n print(\" \")\n\t println(BOBEATS)\n \n }\n }\n }\n fun getMoves(arr:IntArray) {\n var aliceEats = 0\n var bobEats = 0\n var i = 0\n var j = arr.size - 1\n var noOfMoves = 0\n var previous = 0\n var isAliceTurn = true\n var isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e234cdb9e9c2007ecc3cf18f61fa649b", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "@ExperimentalStdlibApi\nfun main() = with(Scanner(System.`in`)) {\n repeat(nextInt()) {\n val candies = ArrayDeque((0 until nextInt()).map { nextInt() })\n var turn = true\n\n var a = 0\n var b = 0\n var turns = 0\n var amount = 0\n\n while (candies.isNotEmpty()) {\n turns++\n var takenSum = 0\n\n if (turn) {\n do {\n takenSum += candies.removeFirst()\n } while (candies.isNotEmpty() && takenSum <= amount)\n a += takenSum\n } else {\n do {\n takenSum += candies.removeLast()\n } while (candies.isNotEmpty() && takenSum <= amount)\n b += takenSum\n }\n amount = takenSum\n turn = !turn\n }\n println(\"$turns $a $b \")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c2d72fc5f67b0841bf25a8fcdc1bbe3b", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n = Array(1001){i->0}\n val t = readLine()!!.toInt()\n\tfor (i in 1..t){\n var m = readLine()!!.toInt()\n\t\tn = readLine()!!.split(' ').map{ it.toInt() }\n\t\tvar a = -1\n var b = m\n var count = 0\n var counta:Int\n var countb:Int\n var totala = 0\n var totalb = 0\n var step = 0\n \twhile (b>a+1){\n counta = 0\n while ((counta<=count)&&(a+1(sweets.map { it.toInt() })\n val alice = mutableListOf()\n val bob = mutableListOf()\n var turn = 0\n var min = 0\n while (!list.isEmpty()) {\n if (turn % 2 != 0) { //Bob\n var tmp = 0\n while (tmp <= min) {\n val n = list.pollLast() ?: break\n bob.add(n)\n tmp += n\n }\n min = tmp\n } else { // Alice\n var tmp = 0\n while (tmp <= min) {\n val n = list.pollFirst() ?: break\n alice.add(n)\n tmp += n\n }\n min = tmp\n }\n turn++\n }\n println(\"$turn ${alice.sum()} ${bob.sum()}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "349315b26636252e1b7600c92a5df833", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nclass ChocolateBar {\n var NOOFMOVES:Int = 0\n var ALICEEATS:Int = 0\n var BOBEATS:Int = 0\n \nfun main(args:Array) {\n val scanner = Scanner(System.`in`)\n if (scanner.hasNext())\n {\n val testCases = scanner.nextInt()\n for (i in 0 until testCases)\n {\n val n = scanner.nextInt()\n val arr = IntArray(n)\n for (j in 0 until n)\n {\n arr[j] = scanner.nextInt()\n getMoves(arr)\n }\n \n\t print(NOOFMOVES)\n\t print(\" \")\n print(ALICEEATS)\n print(\" \")\n\t println(BOBEATS)\n \n }\n }\n }\n fun getMoves(arr:IntArray) {\n var aliceEats = 0\n var bobEats = 0\n var i = 0\n var j = arr.size - 1\n var noOfMoves = 0\n var previous = 0\n var isAliceTurn = true\n var isBobTurn = false\n while (i <= j)\n {\n if (isAliceTurn)\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[i]\n aliceEats += arr[i]\n i++\n }\n noOfMoves++\n previous = sum\n isAliceTurn = false\n isBobTurn = true\n }\n else\n {\n var sum = 0\n while (sum < previous + 1 && i <= j)\n {\n sum += arr[j]\n bobEats += arr[j]\n j--\n }\n noOfMoves++\n previous = sum\n isAliceTurn = true\n isBobTurn = false\n }\n }\n //System.out.println(noOfMoves+\" \"+aliceEats+\" \"+bobEats);\n\n NOOFMOVES = noOfMoves\n ALICEEATS = aliceEats\n BOBEATS = bobEats\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e4f377550ca065d5f95af65747fa73ab", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\nfun main(args: Array) {\n var t = readInt()\n for (tc in 0..t - 1) {\n var n = readInt()\n var a = readInts()\n var x = 0\n var y = 0\n var s = 1\n var ant = 0\n var l = 0\n var r = n - 1\n while (l <= r) {\n if (s % 2) {\n var cur = 0\n while (l <= r && cur <= ant) {\n cur += a[l]\n l++\n }\n ant = cur\n x += cur\n } else {\n var cur = 0\n while (l <= r && cur <= ant) {\n cur += a[r]\n r--\n }\n ant = cur\n y += cur\n }\n s++\n }\n println(\"${s - 1} ${x} ${y}\")\n }\n}\n\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "900a9138f6a82fcae4e7d1bbc4ee7ab4", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n@kotlin.ExperimentalStdlibApi\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n var q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ce47e3896d38be03947f77ce82fd4250", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readLine()!!.toInt()\n for (i in 1..t) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(' ').map(String::toInt)\n val deque = arrayListOf()\n for (a in aa) deque.add(a)\n val ans = arrayListOf(0, 0)\n var cur = 0\n var move = 0\n var m = 0\n while (deque.isNotEmpty()) {\n if (cur == 0) {\n cur = deque.removeFirst()\n ans[0] += cur\n } else {\n var x = 0\n while (deque.isNotEmpty()) {\n x += if (move == 0) deque.removeFirst() else deque.removeLast()\n if (x > cur) break\n }\n ans[move] += x\n cur = x\n }\n move = 1 - move\n m++\n }\n println(\"$m \" + ans[0] + \" \" + ans[1])\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e91aeacd327dc58ac0cdc5498cb71bd", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n = Array(1001){i->0}\n val t = readLine()!!.toInt()\n\tfor (i in 1..t){\n var m = readLine()!!.toInt()\n\t\tn = readLine()!!.split(\" \").map{ it.toInt() }\n\t\tvar a = -1\n var b = m\n var count = 0\n var counta:Int\n var countb:Int\n var totala = 0\n var totalb = 0\n var step = 0\n \twhile (b>a+1){\n counta = 0\n while ((counta<=count)&&(a+10){\n var n = sc.nextInt()\n val a = Array(n) {sc.nextInt()}\n var start = 0\n var end = n-1\n var alice = 0\n var bob = 0\n var moves = 0\n var sum1 = 0\n var sum2 = 0\n while(start<=end){\n var cur = 0\n while(start<=end && cur<=sum2){\n cur+=a[start]\n start++\n }\n moves++\n alice+=cur\n sum1 = cur\n cur = 0\n while(start<=end && cur): Triple {\n var a = 0\n var b = 0\n var step = 0\n\n var lastSum = 0\n val currentCandyList = candyList.toMutableList()\n\n while (currentCandyList.isNotEmpty()) {\n var currentSum = 0\n\n while (currentSum <= lastSum && currentCandyList.isNotEmpty()) {\n if (!step.isOdd()) {\n val candy = currentCandyList.removeFirst()\n currentSum += candy\n a += candy\n } else {\n val candy = currentCandyList.removeLast()\n currentSum += candy\n b += candy\n }\n }\n\n lastSum = currentSum\n step++\n }\n\n return Triple(step, a, b)\n}\n\nfun Int.isOdd(): Boolean = this % 2 != 0", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "725d263b2154e00930809b2501fc5768", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args:Array) { \n val input = Scanner(System.`in`)\n val t = input.nextInt()\n for(i in 0 until t){\n val n = input.nextInt() \n var i:Int = 0\n val sz:Int = input.nextInt()\n var arr = Array(sz){0}\n while( i < sz){\n arr[x] = readLine()!!.toInt()\n i++\n }\n var l:Int = 0\n var r:Int = sz-1\n var a:Int = 0\n var b:Int = 0\n var mov:Int = 0\n var mx:Int = 0\n var f:Int = 0\n while(l <= r){\n f = 1-f\n mov++\n if(f == 1){\n var sum:int = 0\n while(sum <= mx || l <= r){\n sum += arr[l]\n l++\n }\n a += sum\n mx = sum\n }\n else{\n var sum:int = 0\n while(sum <= mx || l <= r){\n sum += arr[r]\n r--\n }\n b += sum\n mx = sum\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3e9ce0c8b897d3737ddc087d9e4ae27d", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static IO in;\n public static PrintWriter out;\n\n static void init_io(String filename) throws Exception {\n if (filename.equals(\"\")) {\n in = new IO(System.in);\n out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);\n } else {\n in = new IO(new FileInputStream(filename + \".in\"));\n out = new PrintWriter(new BufferedWriter(new FileWriter(filename + \".out\")), true);\n }\n }\n\n final static long mod = 998244353;\n\n/*\nfun main(args: Array) {\n Main.main(args);\n}\n*/\n\n static void solve(int tc) throws Exception {\n int n = in.nint();\n \n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = in.nint();\n\n int v = 0, u = 0;\n int c = 0, t = 0;\n int l = 0, r = n - 1;\n while (l <= r) {\n int x = 0;\n ++t;\n while (l <= r && x <= c) {\n x += a[l];\n v += a[l];\n ++l;\n }\n if (l > r) break;\n ++t;\n c = x;\n x = 0;\n while (l <= r && x <= c) {\n x += a[r];\n u += a[r];\n --r;\n }\n c = x;\n }\n out.println(t + \" \" + v + \" \" + u);\n }\n\n public static void main(String[] _u_n_u_s_e_d_) throws Exception {\n init_io(\"\");\n\n int t = 1;\n t = in.nint();\n for (int tc = 0; tc < t; tc++) {\n solve(tc);\n }\n }\n\n static long minv(long v) {\n return mpow(v, mod - 2);\n }\n\n static long mpow(long base, long exp) {\n long res = 1;\n\n while (exp > 0) {\n if ((exp & 1) == 1) {\n res = (res * base) % mod;\n }\n base = (base * base) % mod;\n exp >>= 1;\n }\n\n return res;\n }\n\n static long gcd(long x, long y) {\n if (x == 0) return y;\n return gcd(y % x, x);\n }\n\n static void rsort(long[] arr) {\n Random r = new Random();\n for (int i = 0; i < arr.length; i++) {\n int j = i + r.nextInt(arr.length - i);\n long t = arr[i];\n arr[i] = arr[j];\n arr[j] = t;\n }\n Arrays.sort(arr);\n }\n\n static void rsort(int[] arr) {\n Random r = new Random();\n for (int i = 0; i < arr.length; i++) {\n int j = i + r.nextInt(arr.length - i);\n int t = arr[i];\n arr[i] = arr[j];\n arr[j] = t;\n }\n Arrays.sort(arr);\n }\n\n /* static void qsort(long[] arr) {\n Long[] oarr = new Long[arr.length];\n for (int i = 0; i < arr.length; i++) {\n oarr[i] = arr[i];\n }\n\n ArrayList alist = new ArrayList(Arrays.asList(oarr));\n Collections.sort(alist);\n\n for (int i = 0; i < arr.length; i++) {\n arr[i] = (long)alist.get(i);\n }\n } */\n\n static void reverse(long[] arr) {\n for (int i = 0; i < arr.length / 2; i++) {\n long temp = arr[i];\n arr[i] = arr[arr.length - 1 - i];\n arr[arr.length - 1 - i] = temp;\n }\n }\n\n static String atos(long[] arr) {\n String s = Arrays.toString(arr);\n s = s.substring(1, s.length() - 1);\n return s.replace(\",\", \"\");\n }\n\n static class IO {\n public BufferedReader in;\n public StringTokenizer tokens;\n\n public IO(InputStream x) throws Exception {\n in = new BufferedReader(new InputStreamReader(x));\n tokens = new StringTokenizer(in.readLine());\n }\n\n int nint() throws Exception {\n return Integer.parseInt(nstr());\n }\n\n long nlong() throws Exception {\n return Long.parseLong(nstr());\n }\n\n double ndouble() throws Exception {\n return Double.parseDouble(nstr());\n }\n\n String nstr() throws Exception {\n if (!tokens.hasMoreTokens()) tokens = new StringTokenizer(in.readLine());\n return tokens.nextToken();\n }\n \n long[] nla(int n) throws Exception {\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = nlong();\n }\n return arr;\n }\n }\n\n static class Pair, B extends Comparable> implements Comparable> {\n public A f;\n public B s;\n\n public Pair(A a, B b) {\n f = a;\n s = b;\n }\n\n public int compareTo(Pair other) {\n int v = f.compareTo(other.f);\n if (v != 0) return v;\n return s.compareTo(other.s);\n }\n\n public String toString() {\n return \"(\" + f.toString() + \", \" + s.toString() + \")\";\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b360824ae477f8715fe5ce59e9e94acd", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n//Namy 007\nfun main(args: Array): Unit = with(Scanner(System.`in`)) {\n\trepeat(nextInt()) {\n\t\tval s = nextInt()\n\t\t val d = ArrayDeque((0 until n).map { nextInt() })\n\t\t var a = 0\n\t\t var b = 0\n\t\t var prev = 0\n\t\t var turn = true\n\t\t var turns = 0\n\t\twhile (!d.isEmpty()) {\n\t\t\tvar x = 0\n\t\t\t turns++\n\t\t\tif (turn) {\n\t\t\t\tdo {\n\t\t\t\t\tx += d.pollFirst()\n\t\t\t\t}\n\t\t\t\twhile (!d.isEmpty() && x <= prev)\n\t\t\t\t\ta += x\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tdo {\n\t\t\t\t\tx += d.pollLast()\n\t\t\t\t}\n\t\t\t\twhile (!d.isEmpty() && x <= prev)\n\t\t\t\t\tb += x\n\t\t\t\t}\n\t\t\tprev = x\n\t\t\t turn = !turn\n\t\t}\n\t\tprintln(\"$turns $a $b\")\n\t}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d0fadf65c63b3f1d5db0f26df2c83a66", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array): Unit = with(Scanner(System.`in`)) {\n repeat(nextInt()) {\n val nn = nextInt()\n val dd = ArrayDeque((0 until nn).map { nextInt() })\n var aa = 0\n var bb = 0\n var prevv = 0\n var turnn = true\n var turnss = 0\n while (!dd.isEmpty()) {\n var xx = 0\n turnss++\n if (turnn) {\n do {\n xx += dd.pollFirst()\n }\n while (!dd.isEmpty() && xx <= prevv)\n aa += xx\n }\n else {\n do {\n xx += dd.pollLast()\n }\n while (!dd.isEmpty() && xx <= prevv)\n b += x\n }\n prev = x\n turn = !turn\n }\n println(\"$turns $a $b\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ecc92dfbbbd320e95a333eaf1833a001", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\nimport com.korektur.codeforces.round640.SolutionD\nimport java.io.PrintWriter\nimport java.util.*\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(\n _reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\nfun main() {\n var t = readInt()\n while(t-- > 0) {\n\n val n = readInt()\n val arr = readIntArray(n);\n\n var ansA = 0\n var ansB = 0\n var i = 0\n var j = arr.size - 1\n var cnt = 0\n var prevCnt = 0\n while (i <= j) {\n cnt++\n var curCnt = 0\n if (cnt % 2 == 1) {\n while (i <= j && prevCnt >= curCnt) {\n ansA += arr[i]\n curCnt += arr[i++]\n }\n } else {\n while (i <= j && prevCnt >= curCnt) {\n ansB += arr[j]\n curCnt += arr[j--]\n }\n }\n prevCnt = curCnt\n }\n\n output { println(\"$cnt $ansA $ansB\") }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "275712be39145fef8aca7fbbcbf9d056", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n@kotlin.ExperimentalStdlibApi\n@OptIn(kotlin.ExperimentalStdlibApi::class)\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n val q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d0e4a00851cde6a4cb80c9e4f7e7db25", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n val q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d01e3561c09ece667833a5562099f1a", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n val T=nint()\n repeat(T){\n val n=nint()\n val vs=nlint()\n @kotlin.ExperimentalStdlibApi\n val deq=ArrayDeque(vs)\n val re= mutableListOf(0,0,0)\n var last=0\n repeat(1123456){\n if(deq.isEmpty()) return@repeat\n var sum=0\n while(deq.isNotEmpty() && sum<=last){\n sum+=deq.removeFirst()\n }\n re[1]+=sum\n if(sum>0) ++re[0]\n last=sum\n sum=0\n while(deq.isNotEmpty() && sum<=last){\n sum+=deq.removeLast()\n }\n re[2]+=sum\n if(sum>0) ++re[0]\n last=sum\n sum=0\n }\n println(re.joinToString(\" \"))\n }\n pw.flush()\n}\n\nfun next() = readLine()!!\nfun nint() = next().toInt()\nfun nlong() = next().toLong()\nfun ndouble() = next().toDouble()\nfun nlstring() = next().split(\" \")\nfun nlint() = nlstring().map { it.toInt() }\nfun nllong() = nlstring().map { it.toLong() }\nfun nldouble() = nlstring().map { it.toDouble() }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b345c3883011a467ea344e75ad65e3a0", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "7\n11\n3 1 4 1 5 9 2 6 5 3 5\n1\n1000\n3\n1 1 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 1\n7\n1 1 1 1 1 1 1\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0e8828c66444c82c3a2a5a2e314340d4", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n@OptIn(ExperimentalStdlibApi::class)\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n var q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "97218476059c1ec07460c031fc329999", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "var aTotal :Int = 0\nvar bTotal:Int = 0\nvar aMove :Int = 0\nvar bMove:Int = 0\nvar steps = 0\n\nfun moveA(list: MutableList): MutableList{\n steps +=1\n return if(bMove == 0){\n aTotal += list[0]\n aMove = list[0]\n list.removeAt(0)\n list\n }\n else{\n var aValTemp = 0\n while(aValTemp <= bMove && list.size >=0){\n aValTemp += list[0]\n aTotal += list[0]\n list.removeFirst()\n }\n aMove = aValTemp\n list\n }\n}\nfun moveB(list: MutableList): MutableList{\n steps +=1\n var bValTemp = 0\n while(bValTemp <= aMove && list.size > 0){\n bValTemp += list[list.size - 1]\n bTotal += list[list.size - 1]\n list.removeLast()\n }\n bMove = bValTemp\n return list\n}\n\nfun main(args: Array) {\n var cases = readLine()!!.toInt()\n while (cases > 0) {\n aTotal = 0\n bTotal = 0\n aMove = 0\n bMove = 0\n steps = 0\n var gameLength = readLine()!!.toInt()\n var game = readLine()!!.split(' ').map(String::toInt).toMutableList()\n while(game.size > 0){\n game = moveA(game)\n if(game.size > 0) {\n game = moveB(game)\n }\n }\n println(\"$steps $aTotal $bTotal\")\n cases -= 1\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ec38bb3a633257ee97eb073d00bced67", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.ArrayList\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nprivate fun solve() {\n var n = readInt();\n var a1 = readInts();\n val q = ArrayDeque(a1);\n\n var numMoves = 0;\n var a = 0;\n var b = 0;\n var prevA = 0;\n var prevB = 0;\n while (q.isNotEmpty()) {\n var curA = 0;\n while (curA <= prevB && q.isNotEmpty()) {\n curA += q.removeFirst();\n }\n a += curA;\n prevA = curA;\n if (curA > 0) {\n numMoves++;\n }\n\n var curB = 0;\n while (curB <= prevA && q.isNotEmpty()) {\n curB += q.removeLast();\n }\n b += curB;\n prevB = curB;\n if (curB > 0) {\n numMoves++;\n }\n }\n println(\"$numMoves $a $b\");\n}\n\nfun main() {\n var t = 1;\n t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "03998ac0fc3c905e2039f73e8b0dd80e", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args:Array) { \n val input = Scanner(System.`in`)\n val t = input.nextInt()\n for(i in 0 until t){\n var i:Int = 0\n val sz:Int = input.nextInt()\n var arr = Array(sz){0}\n while( i < sz){\n arr[i] = readLine()!!.toInt()\n i++\n }\n var l:Int = 0\n var r:Int = sz-1\n var a:Int = 0\n var b:Int = 0\n var mov:Int = 0\n var mx:Int = 0\n var f:Int = 0\n while(l <= r){\n f = 1-f\n mov++\n if(f == 1){\n var sum:Int = 0\n while(sum <= mx || l <= r){\n sum += arr[l]\n l++\n }\n a += sum\n mx = sum\n }\n else{\n var sum:Int = 0\n while(sum <= mx || l <= r){\n sum += arr[r]\n r--\n }\n b += sum\n mx = sum\n }\n }\n println(mov + \" \" + a + \" \" + b)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "171d7370ff83abbabe91b9228a1fc7dc", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n val T=nint()\n repeat(T){\n val n=nint()\n val vs=nlint()\n val deq=ArrayDeque(vs)\n val re= mutableListOf(0,0,0)\n var last=0\n repeat(1123456){\n if(deq.isEmpty()) return@repeat\n var sum=0\n while(deq.isNotEmpty() && sum<=last){\n sum+=deq.removeFirst()\n }\n re[1]+=sum\n if(sum>0) ++re[0]\n last=sum\n sum=0\n while(deq.isNotEmpty() && sum<=last){\n sum+=deq.removeLast()\n }\n re[2]+=sum\n if(sum>0) ++re[0]\n last=sum\n sum=0\n }\n println(re.joinToString(\" \"))\n }\n pw.flush()\n}\n\nfun next() = readLine()!!\nfun nint() = next().toInt()\nfun nlong() = next().toLong()\nfun ndouble() = next().toDouble()\nfun nlstring() = next().split(\" \")\nfun nlint() = nlstring().map { it.toInt() }\nfun nllong() = nlstring().map { it.toLong() }\nfun nldouble() = nlstring().map { it.toDouble() }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f451e4eba3d10983af7e0cedcee711a3", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args: Array) {\n var sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var a = sc.nextInt()\n val b= IntArray(n+1)\n for (i in 1 ..n )b[i]=sc.nextInt()\n\n var c =0\n for ( i in 1 ..n){\n if(b[i] == 1 ){\n var d=i-k\n var j=k-d\n var l=b[j]\n if(j<1||j>n||b[i]==l) c++\n }\n }\n\n println(c)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "80da4db0e485b6dad46c39c224228db6", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package Codeforces\n\nfun main() {\n var (a, m) = readLine()!!.split(' ').map { it.toInt() }\n var list = readLine()!!.split(' ').map { it.toInt() }\n\n var max = maxOf(m, list.size - m)\n var left = m - 2\n var right = m\n var count = 0\n var i = 0\n while (i < max) {\n if (left >= 0 && right < list.size) {\n if (list[left] == 1 && list[right] == 1) {\n count += 2\n }\n } else if (left >= 0) {\n if (list[left] == 1) count++\n } else if (right < list.size) {\n if (list[right] == 1) count++\n }\n i++\n right++\n left--\n }\n if (list[m - 1] == 1) {\n count++\n }\n\n println(count)\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4ead750d1c4a29440e8c5e8911d55c16", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var str = readLine()!!\n var c1 = str[0]\n str = str.substring(1)\n\n if (str.toUpperCase() === str) {\n str = str.toLowerCase()\n if (Character.toUpperCase(c1) == c1)\n c1 = Character.toLowerCase(c1)\n else\n c1 = Character.toUpperCase(c1)\n }\n println(c1 + str)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2f014e12475b6e210c46f2ec67c39bdf", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val input = InputReader(inputStream)\n val output = PrintWriter(outputStream)\n val solver = Task()\n solver.solve(input, output)\n output.close()\n}\n\nprivate class Task {\n fun solve(input: InputReader, output: PrintWriter) {\n val word = input.next()\n output.print(if (word.all { it.isUpperCase() } || (word.length > 1 && word.first().isLowerCase() && word.substring(1).all { it.isUpperCase() })) {\n word.toLowerCase().capitalize()\n } else {\n word\n })\n }\n}\n\n\nprivate class InputReader(stream: InputStream) {\n private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n\n operator fun next(): String {\n while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return next().toInt()\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a02214889e6ead198e6e0256011bbdc3", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "@ExperimentalStdlibApi\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n var str = r.readLine()!!\n val len = str.length\n var upper = true\n for (i in 1..len - 1) {\n if (str[i].toInt() > 96) upper = false\n }\n if (!upper) {\n if (len == 1) println(str.toUpperCase())\n else println(str)\n } else{\n str = str.toLowerCase()\n println(str.capitalize(Locale.ROOT))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3f4d3705f61f83efc1df503e5a129329", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.*\n\nfun readLn() = readLine()!!\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map{ it.toInt() }\n\nfun main() {\n var (n) = readInts()\n var (s) = readStrings()\n var mp = HashMap()\n for (i in 0..n - 2) {\n var t = s.substring(i, i + 2)\n mp[t] = mp.getOrDefault(t, 0) + 1\n }\n var ans = \"\"\n var mx = 0\n for ((key, val) in mp) {\n if (val > mx) {\n mx = val\n ans = key\n }\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e50f508df6262422c30a6b1654413216", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q: Int = myMap.get(str)?.1\n myMap.minus(str)\n myMap.plus(Pair(str , q+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6d059e5c79a9aa16d990b0d520a7a1ec", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n var map = HashMap()\n for (i in 0 until len-1) {\n var temp:String = n.subString(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res:String = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c491c700101febc20d007dae87808a32", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\n\ninline fun T.mapK(k: Int, f: (T) -> T): T {\n var res = this\n for (i in 1..k) {\n res = f(res)\n }\n return res\n}\n\nfun solve(s: String): String =\n (s.indices.let { it.first until it.last }).map {\n s.substring(it..it + 1)\n }.groupBy { it }\n .map { it.key to it.value.size }\n .maxBy { it.second }!!\n .first\n\nfun main() {\n readLine()\n val s = readLine()\n println(solve(s))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "abcf3a1cb19372bba93110e3d6ef6ce2", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n var map = mapOf()\n for (i in 0 until len-1) {\n var temp:String = n.substring(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res:String = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "259ab8300cb2bdeafaa72cbccf15e0af", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n var map = mutableMapOf()\n for (i in 0 until len-1) {\n var temp:String = n.substring(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res:String = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67c8c9276e9899d38ce7246b31760c9f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n readLine() // discard first line\n val string = readLine()\n val map = mutableMapOf()\n (string.chunked(2) + string.drop(1).chunked(2))\n .filter { it.length == 2 }\n .forEach { map[it] = 1 + (map[it] ?: 0) }\n println(map.maxBy { it.value }!!.key)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1490d7b315c8d6937973fc3b048b11e2", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.regex.Pattern\n\n\n val n = readLine()?.toInt() ?: 0\n val s = readLine().orEmpty()\n val chars = s.toList()\n if(chars.size == n) {\n val allPairs = chars.map { c ->\n chars.map {\n \"$it\" + \"$c\"\n }.distinct()\n }.flatten().distinct()\n val m = allPairs.map {\n val pattern = Pattern.compile(it) //case insensitive, use [g] for only lower\n val matcher = pattern.matcher(s)\n var count = 0\n while (matcher.find()) count++\n it to count\n }.maxBy { it.second }\n println( m)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c0f3c4e4215c19e2e8f060f75900332d", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s.substring(0,2)\n for(i in 0..n-1)\n {\n var x = s.substring(i:i+2)\n all.add(x)\n }\n var alls = all.sortedArray()\n var f = 0\n var x = 0, mx = 0;\n for(i in alls)\n {\n if(i==x)\n {\n f++;\n }\n else\n {\n f = 1;\n x = i;\n }\n if(f >mx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "42104ffcb5934d8fe9d5a41d00b32fdc", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.subSequence(x-1 ,x+1)\n x++\n if(myMap.containsKey(str)){\n myMap[str] = myMap[str] + 1\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "76151159d470a5dfb2b0b54ec0c2a64f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q: Int = myMap.get(str): 1?\n myMap.minus(str)\n myMap.plus(Pair(str , q+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "463c4e4b83c13c6df0ef9f19ab919483", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package io.github.fabiomaciel\n\nobject programkt{\n//object TwoGram {\n @JvmStatic\n fun main(vararg args: String){\n val n = readLine()!!.toInt()\n val str = readLine()!!\n val result = exec(n, str)\n println(result)\n }\n\n fun exec(n: Int, str: String): String {\n var tg= Pair(0, \"\")\n for(i in 0 until n-2){\n val match = str.substring(i, i+2)\n val times = match.toRegex().findAll(str).count()\n if(times > tg.first)\n tg = Pair(times, match)\n }\n return tg.second\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1e637c52939d7ce8a6e98f1d6ed70760", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s[0:2]\n for(int i =0; imx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a0b7a58f086497400bafc3de5a241f45", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.company\nimport java.util.*\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val map = HashMap()\n val n = Integer.parseInt(sc.nextLine())\n val str = sc.nextLine()\n for (i in 0 until n - 1)\n {\n val word = str.substring(i, i + 2)\n (map as java.util.Map).merge(word, 1, BiFunction({ p, p1-> Integer.sum(p, p1) }))\n }\n println(map.entries.stream().max({ entry1, entry2-> if (entry1.value > entry2.value) 1 else -1 }).get().key)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0ae7566cf5374b160c91c178693b86db", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n myMap.minus(str)\n myMap.plus(Pair(str , (q?.1)+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2951534574690e409528fe1ba0ece475", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2[x-1] + num2[x] \n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n myMap.minus(str)\n myMap.plus(Pair(str , q + 1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a330fff3f036ad0c5f4a4eeff792d3fc", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.HashMap\nimport java.util.concurrent.atomic.AtomicInteger\n\n/**\n * Created by azhdanov on 07.09.2019.\n */\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\n\nfun main() {\n val n = readInt()\n val s = readLn()\n val map = HashMap()\n var maxCounts = 0;\n var twoGramma : String? = null\n for (i in 0 .. n - 2) {\n val candidate = s.subSequence(i, i + 2)\n val cnt = map.getOrDefault(candidate, AtomicInteger(0)).incrementAndGet()\n if (cnt > maxCounts) {\n maxCounts = cnt\n twoGramma = candidate.toString()\n }\n }\n println(twoGramma)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2aafb1803eb6bfb17542e0dfb4fbfdcc", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n var map = mutableMapOf()\n for (i in 0 until len-1) {\n var temp:String = n.substring(IntRange(i,i+1))\n if (map.get(temp) != null) {\n var t:Integer = map.get(temp)\n map.remove(temp)\n map.put(temp, t+1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res:String = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "97c7f64d2009a4648d7f6f9695ca5bc8", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() = readLine() != null && print(\n readLine()!!.asSequence()\n .windowed(2, 1)\n .map { \"${it[0]}${it[1]}\"}\n .groupBy { it }\n .maxBy { it.value.size }?.key\n)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e45987e1c115a63d3e55607587e6e63", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "main(){\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2a67044965bb43d83c882eeb6ceb4d1d", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n = cin.next()\n val map = HashMap()\n for (i in 0 until n.length() - 1) {\n var temp = String(\"\")\n temp += n.charAt(i)\n temp += n.charAt(i + 1)\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res = String(\"\")\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9db347f3743f0d9051e429dfea6eec60", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.substring(x-1 , x+1)\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n q++\n myMap.minus(str)\n myMap.plus(Pair(str , q))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23897038e3f501a1b416d590a7f21e7f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = Integer.valueOf(readLine())\n var num2 = readLine()\n val myMap = mutableMapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n myMap.merge(str , 1 , Int::plus)\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0d669f4bf709bda5a18258912d8137c1", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val str = sc.nextLine()\n\n var mm = mutableMapOf()\n var maxa = 0\n var res = \"\"\n for (i in 0 until n-1) {\n ++mm[\"${str[i]}${str[i+1]}\"]\n }\n for ((key, value) in mm) {\n if (value > maxa) {\n maxa = value\n res = key\n }\n }\n println(res)\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dc6cb741d5780159f53497f790e456d6", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n var map = HashMap()\n for (i in 0 until len-1) {\n var temp:String = n.subSequence(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp, t)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res:String = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "651717e651380898fffd143c67ac2d8a", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.subString(x-1 , x+1)\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n q = q+1\n myMap.minus(str)\n myMap.plus(Pair(str , q))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1f1d6e7d9f921320da6c4b5f6429fabc", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val length = readLine()!!\n val string = readLine()!!\n \tprintln(sol(length, string))\n}\n\nfun sol(length: Int, string: String): String{\n val array = Array(91, {IntArray(91)})\n for (i in 0..(length-2)){\n var beg = string[i].toInt()\n var end = string[i+1].toInt()\n\t\tarray[beg][end]++\n }\n var maxi = 0\n var l1 = 0\n var l2 = 0\n for (i in 41..90){\n for (j in 41..90){\n if (maxi < array[i][j]){\n maxi = array[i][j]\n l1=i\n l2=j\n }\n }\n }\n var p1 = l1.toChar()\n var p2 = l2.toChar()\n return \"$p1$p2\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f0a7418a92ea89e75dffb0619cdaed9f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Main {\n\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val map = HashMap()\n\n val n = Integer.parseInt(sc.nextLine())\n val str = sc.nextLine()\n\n for (i in 0 until n - 1) {\n val word = str.substring(i, i + 2)\n\n val count = map[word]\n\n if (count == null) {\n map[word] = 1\n } else {\n map[word] = count + 1\n }\n }\n\n println(map.entries.stream().max { entry1, entry2 -> if (entry1.value > entry2.value) 1 else -1 }.get().key)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c47b7eb181256b60e1de8854dc669822", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s.substring(0,2)\n var i = 0\n for(i in 0..n-1)\n {\n var x = s.substring(i,i+2)\n all.add(x)\n }\n var alls = all.sortedArray()\n var f = 0\n var x = 0; var mx = 0;\n for(i in alls)\n {\n if(i==x)\n {\n f++;\n }\n else\n {\n f = 1;\n x = i;\n }\n if(f >mx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4e85eb4b6b6be97bfb644f5a06594cb1", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject test {\n fun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n:String = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n val temp = n.substring(IntRange(i,i+1))\n map[temp] = map[temp]+1;\n }\n var MIN = 0\n var res = \"\"\n for ((key, value) in map) {\n if (MIN < value) {\n MIN = value\n res = key\n }\n }\n System.out.println(res)\n cin.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d27ada13300e4283b1655277c904702b", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.subSequence(x-1 ,x+1)\n x++\n if(myMap.containsKey(str)){\n var q:Int = myMap.get(str)\n myMap.minus(str)\n myMap.plus(Pair(str , q + 1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4c8d14cf2c8d933aa6609d6c9efe21ac", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject test {\n fun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n:String = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n var temp = n.substring(IntRange(i,i+1))\n if(map.containsKey(temp))\n map[temp] = map[temp]!! + 1\n else map[temp] = 1\n }\n var MIN = 0\n var res = \"\"\n for ((key, value) in map) {\n if (MIN < value) {\n MIN = value\n res = key\n }\n }\n System.out.println(res)\n cin.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6cb416d0fe037f815e720f868d6553d7", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args:Array){\n\tvar str = readline()!!;\n var tm = mutableMapOf(); \n for(i in 0..str.length-2){\n var tc = str[i].toString() + str[i+1].toString();\n tm[tc]=tm.getOrDefault(tc,0)+1;\n }\n var r = tm.maxBy({it.value});\n println(r?.key)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1bffb3e75756863297dc3e3a11f91054", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(arguments: Array){\n val length = Integer.parseInt(readline()!!);\n val string = readline()!!;\n \n var best_index = 0;\n var best_count = 0;\n \n var i = 0;\n while(i < (length - 1)){\n var count = 1;\n val reference1 = string.charAt(i);\n val reference2 = string.charAt(i + 1);\n \n var j = i + 1;\n while(j < (length - 1)){\n val char1 = string.charAt(j);\n val char2 = string.charAt(j);\n \n if(reference1 == char1 && reference2 == char2){\n count = count + 1;\n }\n \n j = j + 1;\n }\n \n if(count > best_count){\n best_count = count;\n best_index = i;\n }\n \n i = i + 1;\n }\n \n println(string.substring(best_index, best_index + 2));\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7db7cc7b850cd622dbdacd52bb208cf8", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val str = sc.nextLine()\n\n var mm = mutableMapOf()\n var maxa = 0\n for (i in 0 until n-1) {\n maxa = Math.max(++mm[\"${str[i]}${str[i+1]}\"], maxa)\n }\n println(maxa)\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a430a87811c864a211d46d9ff92c7c44", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\n\ninline fun T.mapK(k: Int, f: (T) -> T): T {\n var res = this\n for (i in 1..k) {\n res = f(res)\n }\n return res\n}\n\nfun solve(s: String): String =\n (s.indices.let { it.first until it.last }).map {\n s.substring(it..it + 1)\n }.groupBy { it }\n .map { it.key to it.value.size }\n .maxBy { it.second }!!\n .first\n\nfunc main() {\n readLine()\n val s = readLine()\n println(solve(s))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "741d9ed9e496d8994ee6228161f8f068", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.company\nimport java.util.*\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val map = HashMap()\n val n = Integer.parseInt(sc.nextLine())\n val str = sc.nextLine()\n for (i in 0 until n - 1)\n {\n val word = str.substring(i, i + 2)\n (map as java.util.Map).merge(word, 1, BiFunction({ p, p1-> Integer.sum(p, p1) }))\n }\n println(Collections.max>(map.entries, Comparator.comparingInt>(ToIntFunction>({ it.value }))).key)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0bf5b4eaef3f910441402129f7bcdd05", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package c1212\n\nfun main() {\n readLine()\n val s = readLine()!!\n val res=s.zipWithNext { a, b -> a.toString() + b }\n .groupingBy { it }\n .eachCount()\n .maxBy { it.value }\n ?.key!!\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "96ee076598a2b7581ae352c32393e176", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str) !!. (return null)\n myMap.minus(str)\n myMap.plus(Pair(str , q+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb72144e5624be5213607dc04ac07f33", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n\n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.subSequence(x-1 ,x+1)\n x++\n if(myMap.containsKey(str)){\n myMap[str] = myMap[str] + 1\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.asIterable()){ \n if(itr1.value > fre){\n fre = ${iter1.value}\n final_str = ${iter1.key}\n }\n }\n print(final_str)\n \n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4b34f7f7406d8aff2f1c406f23782374", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = num2.subString(x-1 , x+1)\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n myMap.minus(str)\n myMap.plus(Pair(str , q.toInt()+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b5cc5abd5e3d86de971aa79ae486aba5", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.company\n\nimport java.util.*\n\nobject Main {\n\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val map = HashMap()\n\n val n = Integer.parseInt(sc.nextLine())\n val str = sc.nextLine()\n\n for (i in 0 until n - 1) {\n val word = str.substring(i, i + 2)\n\n val count = map[word]\n\n if (count == null) {\n map[word] = 1\n } else {\n map[word] = count + 1\n }\n }\n\n println(map.entries.stream().max { entry1, entry2 -> if (entry1.value > entry2.value) 1 else -1 }.get().key)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0868e5f31f11f0bb3495cf423452cf5e", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s.substring(0,2)\n var i = 0\n for(i in 0..n-1)\n {\n var x = s.substring(i,i+2)\n all.add(x)\n }\n all.sort()\n var f = 0\n var x:String; var mx = 0;\n for(i in all)\n {\n if(i==x)\n {\n f++;\n }\n else\n {\n f = 1;\n x = i;\n }\n if(f >mx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "884dadf06e9f59e5625f771f8b5fbb31", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": " fun main(arguments: Array){\n val length = Integer.parseInt(readLine()!!);\n val string = readLine()!!;\n \n var best_index = 0;\n var best_count = 0;\n \n var i = 0;\n while(i < (length - 1)){\n var count = 1;\n val reference1 = string.charAt(i);\n val reference2 = string.charAt(i + 1);\n \n var j = i + 1;\n while(j < (length - 1)){\n val char1 = string.charAt(j);\n val char2 = string.charAt(j);\n \n if(reference1 == char1 && reference2 == char2){\n count = count + 1;\n }\n \n j = j + 1;\n }\n \n if(count > best_count){\n best_count = count;\n best_index = i;\n }\n \n i = i + 1;\n }\n \n println(string.substring(best_index, best_index + 2));\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "52b75e1ecc8fafe284e36854b78acc01", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.happypeople.codeforces.c1212\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n B1212().run()\n } catch (e: Throwable) {\n println(\"\")\n e.printStackTrace()\n }\n}\n\nclass B1212 {\n fun run() {\n val sc = Scanner(systemIn())\n val n=sc.nextInt()\n val str=sc.next()\n val dmap = mutableMapOf()\n for(i in 0..str.length-2) {\n val twogram=str.substring(i..i+1)\n val old=dmap.getOrDefault(twogram, 0);\n dmap.set(twogram, old+1);\n }\n println(dmap.toList().sortedByDescending { (_, value) -> value }.first().first)\n }\n\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca9667bb0aedeb049d714611929c80d8", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n = cin.next()\n val map = HashMap()\n for (i in 0 until len-1) {\n var temp = n.subSequence(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "849bba13830d16de641a99ee1176e546", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q = myMap.get(str)\n myMap.minus(str)\n myMap.plus(Pair(str , q.toInt()+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e0db1db6a0c96bec6300e5296e0607ad", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q: Int = myMap.get(str)?myMap.get(str):1\n myMap.minus(str)\n myMap.plus(Pair(str , q+1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2c732a51591023ecf60e242c5d4feb62", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n = cin.next()\n val map = HashMap()\n for (i in 0 until len-1) {\n var temp = \"\"\n temp += n.charAt(i)\n temp += n.charAt(i + 1)\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n var res = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b47c79f3de16855b1aa9935ac49b908f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject test {\n fun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n:String = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n val temp = n.substring(IntRange(i,i+1))\n if (map.get(temp) != null) {\n map[temp] = map.get(temp)+1;\n } else {\n map[temp] = 1\n }\n }\n var MIN = 0\n var res = \"\"\n for ((key, value) in map) {\n if (MIN < value) {\n MIN = value\n res = key\n }\n }\n System.out.println(res)\n cin.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f66183172b305ed01750a286dd510ecf", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len:int = cin.nextInt()\n val n:String = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n val temp = n.substring(IntRange(i,i+1))\n if (map.get(temp) != null) {\n map[temp] = map.get(temp)+1;\n } else {\n map[temp] = 1\n }\n }\n var MIN = 0\n var res = \"\"\n for ((key, value) in map) {\n if (MIN < value) {\n MIN = value\n res = key\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8d5a15f643e3384650cc9b074c45d962", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: Map = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n myMap.merge(str , 1 , Int::plus)\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7d6a097587eb7ef5aa580a7de0ac47f8", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.company\nimport java.util.*\nobject Main {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val map = HashMap()\n val n = Integer.parseInt(sc.nextLine())\n val str = sc.nextLine()\n for (i in 0 until n - 1)\n {\n val word = str.substring(i, i + 2)\n val count = map.get(word)\n if (count == null)\n {\n map.put(word, 1)\n }\n else\n {\n map.put(word, count + 1)\n }\n }\n println(map.entries.stream().max({ entry1, entry2-> if (entry1.value > entry2.value) 1 else -1 }).get().key)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "de2820ba7c10034dc392614d31dc1d68", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n = cin.next()\n val map = HashMap()\n for (i in 0 until len-1) {\n val temp = n.subSequence(IntRange(i,i+1))\n if (map.get(temp) != null) {\n val t = map.get(temp)\n map.remove(temp, t)\n map.put(temp, t + 1)\n } else {\n map.put(temp, 1)\n }\n }\n var MIN = 0\n val res = \"\"\n for (entry in map.entrySet()) {\n if (MIN < entry.getValue()) {\n MIN = entry.getValue()\n res = entry.getKey()\n }\n }\n System.out.println(res)\n cin.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "96c8d305609214c3b2d389a937d38f46", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject test {\n fun main(argv: Array) {\n val cin = Scanner(System.`in`)\n val len = cin.nextInt()\n val n:String = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n var temp = n.substring(IntRange(i,i+1))\n if(map.containsKey(temp))\n map[temp] = map[temp] + 1\n else map[temp] = 1\n }\n var MIN = 0\n var res = \"\"\n for ((key, value) in map) {\n if (MIN < value) {\n MIN = value\n res = key\n }\n }\n System.out.println(res)\n cin.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "72aa5f84775e3d273e9b202844f46ecd", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n\n \n var num1 = read.nextInt()\n var num2 = readLine()\n val myMap: Map\n var x:Int = 1\n while(x < num1){\n var str = num2.subSequence(x-1 ,x+1)\n x++\n myMap[str]++\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.asIterable()){ \n if(itr1.value > fre){\n fre = iter1.value\n final_str = iter1.key\n }\n }\n print(final_str)\n \n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "849080d4a205347620f7cb9539b4d62f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n //creating Scanner object\n val read = Scanner(System.`in`)\n \n \n var num1 = read.nextInt()\n var num2 = readLine()!!\n val myMap: MutableMap0 = mapOf()\n var x:Int = 1\n while(x < num1){\n var str = \"${num2.get(x-1)}${num2.get(x)}\"\n x++\n if(myMap.containsKey(str)){\n var q = myMap.getValue(str)\n myMap.minus(str)\n myMap.plus(Pair(str , q?q+1:1))\n }else{\n myMap.plus(Pair(str, 1))\n }\n }\n var fre:Int = 0\n var final_str = \"\"\n for(itr in myMap.iterator()){ \n if(itr.value > fre){\n fre = itr.value\n final_str = itr.key\n }\n }\n print(final_str)\n \n \n \n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "47ba649eae77862fcc5954a04d086308", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val s = sc.next()\n val m = hashMapOf()\n for (i in 0 until n - 1) {\n val x = s.substring(i, i + 2)\n m[x] = m.getOrDefault(x, 0) + 1\n }\n var cnt = 0\n var res: String? = null\n for (e in m) {\n if (cnt < e.value) {\n cnt = e.value\n res = e.key\n }\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "668aa3901424a95df79f40c6b5222f4b", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s.substring(0,2)\n var i = 0\n for(i in 0..n-1)\n {\n var x = s.substring(i,i+2)\n all.add(x)\n }\n all.sort()\n var f = 0\n var x; var mx = 0;\n for(i in all)\n {\n if(i==x)\n {\n f++;\n }\n else\n {\n f = 1;\n x = i;\n }\n if(f >mx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ee8309bf666616f3b0f3f3f7ab967e04", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var s = inp.next()\n var all = ArrayList()\n var ans = s.substring(0,2)\n var i = 0\n for(i in 0..n-1)\n {\n var x = s.substring(i,i+2)\n all.add(x)\n }\n all.sort()\n var f = 0\n var x = 0; var mx = 0;\n for(i in all)\n {\n if(i==x)\n {\n f++;\n }\n else\n {\n f = 1;\n x = i;\n }\n if(f >mx)\n {\n ans = i\n mx = f\n }\n \n }\n \n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5bd31afd1365d78401af992e5fb51e9a", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val str = readLine()!!.split(\" \")\n val n = str[0].toLong()\n val k = str[1].toLong()\n val min: Long\n val max: Long\n\n if (k == 0L) {\n min = 0\n max = 0\n }\n else if (n == k) {\n min = 0\n max = 0\n }\n else if ((n.toFloat) / k >= 3F) {\n min = 1\n max = k * 2\n }\n else if ((n.toFloat() / k) > 2F) {\n min = 1\n max = k + 1\n }\n else {\n min = 1\n max = n - k\n }\n\n println(\"$min $max\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b57b6d18c33d5ba0dae77ed31c04368e", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val str = readLine()!!.split(\" \")\n val n = str[0].toLong()\n val k = str[1].toLong()\n val min: Int\n val max: Int\n\n if (k == 0) {\n min = 0\n max = 0\n }\n else if (n == k) {\n min = 0\n max = 0\n }\n else if ((n - k) == 1) {\n min = 1\n max = 1\n }\n else if ((n.toFloat() / k) > 2F) {\n min = 1\n max = k + 1\n }\n else {\n min = 1\n max = n - k\n }\n\n println(\"$min $max\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9e221f2a581571cd0d4ff7c734d8eabb", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "package com.company\n\nimport java.util.*\nimport kotlin.system.exitProcess\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val i = scanner.nextInt()\n val j = scanner.nextInt()\n\n for (x in i..j) {\n val exist = BooleanArray(10) { false }\n var ok = true\n for (c in x.toString()) {\n if (exist[c - '0']) {\n ok = false\n break\n }\n exist[c - '0'] = true\n }\n if (ok) {\n print(x)\n exitProcess(0)\n }\n }\n print(-1)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8f29250d32b31c776b92fd83cd9c26c8", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Kotlin 1.4", "source_code": "import java.util.*\r\nimport java.util.ArrayList\r\nimport java.util.concurrent.ThreadLocalRandom\r\nimport kotlin.collections.*\r\nimport kotlin.math.*\r\n\r\nfun readInts() = readLine()!!.split(\" \").map{i -> i.toInt()}.toMutableList()\r\nfun readInt() = readLine()!!.toInt()\r\nfun readLongs() = readLine()!!.split(\" \").map{i -> i.toLong()}.toMutableList()\r\n\r\nfun main() {\r\n c()\r\n}\r\nfun c() {\r\n val n = readInt()\r\n val a = readInts()\r\n a.sort()\r\n val p = a.prefixSum()\r\n val ans = TreeSet()\r\n var sum = 0L\r\n var i = n - 1\r\n while (sum <= p[i]) {\r\n sum += a[i]\r\n var j = 0\r\n var currentSum = sum\r\n while (currentSum <= p[i] - p[j]) {\r\n if (currentSum == p[i] - p[j]) {\r\n ans.add(i)\r\n }\r\n currentSum += a[j]\r\n j++\r\n }\r\n i--\r\n }\r\n println(ans.size)\r\n if(ans.size > 0) {\r\n println(ans.jointWithWhitespace())\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0e9458efc3bf4a96ce2bf91b25226305", "src_uid": "29063ad54712b4911c6bf871969ee147", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun constructIntegers(n:Int):String{\n var a=n\n var b=n\n if(n > 1) {\n return a.toString()+\" \"+b.toString()\n }\n return \"-1\"\n }\n}\n\nfun main(){\n val sol = Solution()\n println(sol.constructIntegers(readLine()!!.toInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b0fdcb3f898ebc6b1f327baaa31680d8", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.test.asserter\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val inp = InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val solver = TaskB()\n solver.solve(inp, out)\n out.close()\n}\n\nclass TaskB {\n fun solve(inp: InputReader, out: PrintWriter) {\n val t = inp.nextInt()\n for (i in 1..t) {\n val a = inp.nextLong()\n val b = inp.nextLong()\n val d1 = a - b\n val d2 = a + b\n if (d1 == 1L) {\n if (isPrime(d2))\n out.println(\"YES\")\n else\n out.println(\"NO\")\n } else\n out.println(\"NO\")\n }\n }\n\n private fun isPrime(x: Long): Boolean {\n if (x == 1L)\n return false\n var d = 2L\n while (d * d <= x) {\n if (x % d == 0L)\n return false\n d++\n }\n return true\n }\n}\n\nclass InputReader(stream: InputStream) {\n private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return next().toLong()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "05021f8c004d8af7f3207e4ec08e7e6e", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package com.happypeople.codeforces.c1102\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n A().run()\n } catch (e: Throwable) {\n A.log(\"\" + e)\n }\n}\n\nclass A {\n fun run() {\n val sc = Scanner(systemIn())\n val n = sc.nextInt()\n val ans = if (n == 3 || n == 4) 0 else 1\n println(\"$ans\")\n }\n\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "40c4bdac1f7057c566b75f594d0106c9", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "func main() {\n val n = readLine()!!.split(\" \").map { it.toInt() }\n \n \n print(n[0] * n[1] / 2)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9eb16c131c625f4d245873aa6196ca47", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val scanner = Scanner(System.`in`)\nval n = scanner.nextInt()\nval m = scanner.nextInt()\nprint(n * m / 2)\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dc2bdb842a8025e5d5a613988820ae41", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b) = reader.readLine()!!.split(' ').map(String::toLong)\n println(a * b / 2 * 2)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3fd982c5e9234002558bd58bff61d2d5", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "Kotlin 1.5", "source_code": "import java.math.BigInteger\n\nfun run(n: Int): String {\n return BigInteger.valueOf(2).pow(n).minus(BigInteger.valueOf(1)).toLong().toString()\n}\n\n\nfun main() {\n (1..readLine()!!.toInt()).forEach {\n val case = readLine()!!.toInt()\n //println(\"Case #${it}: ${run(case)}\") // Google Code Jam\n println(run(case)) // Codeforces\n }\n}\n\nif (System.getProperty(\"user.name\") == \"jan\")\n main() // needed locally, but comment this out for the judge\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5ac55e9b953f4f5c892ea66603816ae7", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n\nvoid main(){\n var sc = Scanner(System.`in`)\n var a = sc.nextInt()\n if(a % 2 == 0)\n print(\"YES\")\n else\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1b4c6ea8277b0d1ab0fa67f4e320e6fa", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() = readInt().let { println((it > 2 && % 2 == 0) ? \"YES\" : \"NO\") }\n\nprivate fun readInt() = readLine()?.toInt() ?: 0", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8bd2bf64b24cb61bf2eaa5edf6cb7444", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val a = readLine()!!toInt()\n println(if (a % 2 == 0 && a > 3) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "238efdfa5ce1f71f4e850d174b7975ab", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n divideWatermelon(w)\n}\n\nfun divideWatermelon(w:Int):String{\n var res:String = \"NO\"\n if(w % 2 == 0){\n res = \"YES\"\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4aeb2a5961d2b6fc25cec50a2fcc2c79", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "var n = readLine().!!.toInt()\n\nif (n / 2 == 0) {\n print(\"YES\")\n} else {\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ecacceb214648be11e533a61ebd5206c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\tval x = readline()\n\tif (x != null && x.toInt() % 2 == 0) println(\"YES\") else println(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7c80672919fc3b29e061b289bfcd5be9", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(Scanner(System.`in`)) {\n val w = nextInt()\n w > 2 && w & 1 == 0 ? println(\"YES) : println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a995eecd4bc4505f2122314793ad5ff0", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Watermelon {\n\tpublic fun(args: Array) {\n\t\tval w = readLine().toInt()\n\n\t\tif(w>=4) println(\"YES\")\n\t\telse println(\"NO\")\n\t} \t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "79aa2cda71b440aebcb975e75a668444", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nfun main() {\n println(if (readLine()!!.toInt() % 4 == 0) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4169ff049f67c990c4d94b2569ace07a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package problems\n\n/**\n * Created by patrick on 30.08.19.\n * (c) Patrick Scheibe 2019\n */\n\nprivate fun check(n: Int): Boolean {\n return n > 2 && n % 2 == 0\n}\n\npublic fun main() {\n val n = readLine()!!.toInt()\n println(if (check(n)) \"YES\" else \"NO\")\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1911d1be51a3b4322c5fee12676e3974", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val w = readLine()!!.first()\n if (w % 2) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "575b022919d61f8e92641acbf5f5b24a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun isDividable(weight: Int) : Boolean = (weight % 2 == 0)\n\nval weight = readLine()\n\nif (weight != null) {\n val weightInt = Int(weight)\n if (weightInt != null) {\n val result = if (isDividable(weight = weightInt)) \"YES\" else \"NO\"\n print(result)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf8aef5851fad8a99532f1d6d8a0f1b6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var wegiht = readLn().toInt();\n if(wegiht != 2 || wegiht % 2 == 0) \n println(\"YES\");\n else \n println(\"NO\");\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "431827de67bfb59d839e124de9ec1e4a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n\tval i = readInt()!!\n\tprintln(if (i % 4 == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d8c55e2f392bc79d55a2a997a1a790e2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) =\n\twith(readline()!!.toInt()) {\n\t\tif(this==2) print(\"NO\") else\n\t\tif(this % 2 == 0) print(\"YES\")\n\t\telse print(\"NO\")\n\t}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b0b16165ba01d616562b753a24a0927a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.com.tasks.task4A\n\nimport java.nio.ByteBuffer\n\nfun main(args: Array) {\n val weight = args[0].toInt()\n val lastBit = weight shr 32 and 1\n if (lastBit == 0) print(\"YES\") else print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "16f78b0946703e709d6461ee6fafdd25", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val x = nextInt\n println( if (x % 2 == 0 && x != 2) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e687b63488bc42ed94c0a10d22dc85e8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = print(\n\twhen(readline()!!.toInt()) {\n\t\t2 -> \"NO\"\n\t\tit % 2 == 0 -> \"YES\"\n\t\telse -> \"NO\"\n\t}\n)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9ec925d83094793f61db93d4c6eaf027", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n\nobject Main {\n\n @JvmStatic\n fun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val input = InputReader(inputStream)\n val output = PrintWriter(outputStream)\n val solver = Task()\n solver.solve(input, output)\n output.close()\n }\n\n class Task {\n\n private val minWeight = 1\n private val maxWeight = 100\n\n fun solve(input: InputReader, output: PrintWriter) {\n val weight = input.nextInt()\n\n if (weight < minWeight || weight > maxWeight) {\n output.print(\"NO\")\n } else {\n output.print(if (weight % 2 == 0) \"YES\" else \"NO\")\n }\n }\n }\n\n\n class InputReader(stream: InputStream) {\n private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n\n operator fun next(): String {\n while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "14f8a83789c5ff514e69390d20201ff3", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.utils.*\n\nfun main(args: Array){\n val scan = Scanner(System.`in`)\n if((scan.nextInt % 2) == 0) print(\"yes\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b9cdcf4fd318b396e20fe40ec0b2fa37", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = print(\n\twhen(readline()!!.toInt()) {\n\t\t2 -> \"NO\"\n\t\tthis % 2 == 0 -> \"YES\"\n\t\telse -> \"NO\"\n\t}\n)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1f368a6e3b49175a88dc9a8bb266f3a4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nfun main(args: Array) {\n val weight: Int = readLine()!!.toInt()\n if (weight > 2 && weight % 2 == 0) {\n print(\"YES\")\n }\n else {\n print(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bc6c030ce1aebfd0c3ac8bb89aef4d0e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "if (w/2 ==0) {\nprintln(\"YES\")\n}else{\nprintln(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a7f4f0c0f40f6a9f7865fa251bfb7d6e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(Scanner(System.`in`)) {\n \n println(if (nextInt() % 2 == 0) \"Yes\" else \"No\") \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "18c509dd73672ec85a3d5de718f99d47", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val w = readLine()!!.toInt()\n if (w % 2 != 0) {\n println(\"NO\")\n } else {\n if (w / 2 >= 2) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9aee8bed6664bf7dcdd9b291fbe20263", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\tval x = readLine()\n\tif (x != null && (x.toDouble() / 2) % 2 == 0) println(\"YES\") else println(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e45b1ea6160c35b7cd767d80f48bf30c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var w:Int = null\n divideWatermelon(w)\n}\n\nfun divideWatermelon(w:Int):String{\n var res:String = \"NO\"\n if(w % 2 == 0){\n res = \"YES\"\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "606b98ceb1458f8055453ee6645d42c0", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLn().toInt()\nfun main() {\n var wegiht = readInt();\n if(wegiht != 2 || wegiht % 2 == 0) \n println(\"YES\");\n else \n println(\"NO\");\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "262ab9c42e3b000b09e535a378ef3984", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package problems\n\n/**\n * Created by patrick on 30.08.19.\n * (c) Patrick Scheibe 2019\n */\n\nfun check(n: Int) : Boolean {\n return n > 2 && n % 2 ==0\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n println(if(check(n)) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b7f10e04d0a1bf8cc801cebd9760d2b6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.tramsun.codeforces\n\nimport java.util.*\n\nval scan = Scanner(System.`in`)\n\nfun main(args: Array) {\n\n val w = scan.nextInt()\n\n println(if(w%2 ==0) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dba6f085835c64b61b8c768ebfceec9c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nfun main(args: Array) {\n println(if (readLine()!!.toInt() % 4 == 0) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "066e2db51098e00ae7d8d257ef4f5d7e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package problem4A\n\nfun canDivideWatermelon(weight: Int) =\n (weight - 2) % 2 == 0\n\nfun main() {\n val input = readLine()!!.toInt()\n val result = canDivideWatermelon(input)\n println(if (result) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "acb26abd825b1c6344f0650b70a8c8b0", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val v = readLine()!!.toInt()\n return if (v % 2 != 0) {\n \"NO\"\n } else {\n \"YES\"\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3ea89c9282ea579e9600d126e5996390", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val w = nextInt()\n (w > 2) && (w & 1) == 0 ? println(\"YES) : println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4deeeeff3c6f06c12a8d184cba71e339", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " \n\nfun main() { \n \n val scan = Scanner(System.`in`)\n \n val w = scan.nextInt()\n \n if(w < 1 || w > 100) {\n println(\"NO\")\n }\n if (w.mod(2)==0) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "809b303cc18c1b0ae88c3873d32959a4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val w = nextInt()\n (w > 2) && (w and 1 == 0) ? println(\"YES) : println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8e60f94e084d9037d4ce186a144008f6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n var w:Integer\n if(w % 2 == 0 ){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f0f0d637c56efc746cc90d0c16724b2f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun checkWatermelon() {\n val input = Scanner(System.in)\n val weight = input.nextInt()\n\n if (weight % 2 == 0) \n print(\"YES\")\n else \n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3f1d92c1c8ecb7dee2cf76be91e4c66d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\tval line = readLine()!!\n\tval weight = line.toInt()\n\tval isEvenParts = (2 until weight).filter { weight % it == 0 } >= 2\n\tif (isEvenParts) println(\"YES\") else println(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ebd57e37bbcfad29464dada84bbd3f37", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " fun main(){\n var N: Int = readLine()!!.toInt()\n if (N%2==0 && n!=2) println(\"YES\")\n else println(\"NO\")\n }\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "df341bf4cd542ddf2fd645f3487cd6c7", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val w = 0\nif (w/2 ==0){\nprintln(\"YES\")\n}else {\nprintln(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5a8dd664a9ce42519ce561f346c83309", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val w = readLine()!!.first()\n if (w % 2 == 0) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e50796d80e9ee46b404b90c145f506ff", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt()\n if (n%2==0) println(\"YES\");\n else println(\"NO\");\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3ca047d7570111d29e40965ddb126b61", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val scanner = Scanner(System.`in`)\n val w = scanner.nextInt()\n if (w in 1..100) {\n if (w % 2 == 0) {\n println(\"YES\")\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7ca792c8cd7e94275721d682856d1b13", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array){\n var w:Int = readLine()!!.toInt()\n if((w%2 && w/2 > 1) == 1)\n print(\"NO\")\n else\n print(\"YES\")\n}\n ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e36e37864d72f1b1e6269674c7946519", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.com.tasks.task4A\n\nfun main() {\n val weight = readLine()!!.toInt()\n val lastBit = weight shr 32 and 1\n if (lastBit == 0) println(\"YES\") else println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6378ca1f337fb3573b24085807b85a96", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n\n\n print(\"enter number : \")\n var w = readLine()!!.toInt()\n if (w % 2 == 0 && w > 2){\n println(\"OUI\")\n\n }else{\n println(\"NON\")\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0ab315388d0a09a9da068b2e90f39e91", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "Zimport java.util.Scanner\n\nfun main() {\n // Creates an instance which takes input from standard input (keyboard)\n val reader = Scanner(System.`in`)\n // nextInt() reads the next integer from the keyboard\n var integer:Int = reader.nextInt()\n if(integer %2==0 && integer !=2){\n println(\"YES\")\n }else{\n println(\"No\")\n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d10335e9bfc22fa5b6133306f6bf9e31", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fn main() = readInt().let { println((it > 2 && it % 2 == 0) ? \"YES\" : \"NO\") }\n\nprivate fun readInt() = readLine()?.toInt() ?: 0", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a9d49529f10a09ab3dea50e6d5c5466a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val w: Int = readLine()!!.toInt()\nprintln(if (w % 2 == 0) \"YES\" else \"NO\")", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "40176e2ba45685d16cb919b7fc88c559", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\tval x = args[0]\n\tif (x % 2 == 0) println(\"YES\") else println(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6139b2bd182c47cf343b1618dc57de22", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\tval line = readLine()!!\n\tval weight = line.toInt()\n\tval isEvenWeight = weight % 2 == 0 && weight > 2\n\tif () println(\"YES\") else println(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "19be77082d7a8f1c46ba2c38ea03a921", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n print(\"enter number \")\n var n :Int = readLine()!!.toInt()\n return (if (n != 2 && (n % 2) == 0)\n \"YES\"\n else\n \"NO\"\n )\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1925beb7b49f68651238a1e2e5153b68", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array) = new Scanner(System.`\u00ecn`).use { \n if (it.nextInt() % 2 == 0) 'YES' else 'NO' }.let(::println)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d7976651867c8113c57c97d0fc953378", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val nul = readLine()!!.toInt()\n println(\n if (num > 2 && num % 2 == 0) \"YES\" else \"NO\"\n )\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a2d620d7ae1ac6ecee04a47c9592492e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()\n n = n.toInt()\n \n if(n%2 == 0 && n != 2)\n print(\"YES\")\n else\n print(\"NO\")\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "931247233fde217d95fd917fa9852fd1", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package x_4a_watermelon\n\n/**\n * @author Alexander Bolgov on 28.12.2019.\n */\nfun main() {\n val weight = readLine()!!.toInt()\n println(if (solution(weight)) \"YES\" else \"NO\")\n}\n\nfun solution(weight: Int): Boolean {\n //if (weight < 4) return false\n for (piece in 2..weight step 2) {\n if (weight - piece > 0 && (weight - piece) % 2 == 0) {\n println(piece)\n return true\n }\n }\n return false\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8dbf88ae2652da806025e5896e9f564a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val v = readLin()!!.toInt()\n return if (v % 2 != 0) {\n \"NO\"\n } else {\n \"YES\"\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e9cca0737e34e7f43556bc7edef9321f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package dev.tsuki.cf\n\nfun main(){\n val input = readLine()!!.toInt()\n if(input%4==0){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7e77b6b63a5b2d6a7980b1e8503efcfd", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val w = nextInt()\n if ((w > 2) && (w and 1 == 0)) {\n println(\"YES)\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "73db6f7a28486d2909fa081e3fea322f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(val w:Integer){\n if(w % 2 == 0 ){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9cc4edea8675a550cebc9b41dd250dea", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " \n\nfun main() { \n \n val scan = Scanner(System.`in`)\n\n val w = scan.nextLine().trim().toInt()\n \n if(w < 1 || w > 100) {\n println(\"NO\")\n }\n if (w.mod(2)==0) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f94700a7f3bfce43d29f0bf4b9f6e774", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLn().toInt()\nfun main() {\n var wegiht = readLn().toInt();\n if(wegiht != 2 || wegiht % 2 == 0) \n println(\"YES\");\n else \n println(\"NO\");\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9a556f4b38e524a62ec6d49a9ba027fb", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val n = readLine()!!.toInt()\n\nif (n / 2 == 0){\n print(\"YES\")\nelse{\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b4ea1a11f6cf5706e9dc6a321268306c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val sc = Scanner(System.`in`)\n\n var x:Int = readLine()!!.toInt()\n\n if (x%2 == 0 && x > 2)\n println (\"YES\")\n else println (\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5a7767818959abfcb1fb59b0e22927ce", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n val scan = Scanner(System.`in`)\n val w = scan.nextLine().trim().toInt()\n if(w % 2 == 0 ){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b11e433bb28a0c692662b4594b7b1093", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.com.tasks.task4A\n\nfun main(args: Array) {\n val weight = args[0].toInt()\n val lastBit = weight shr 32 and 1\n if (lastBit == 0) print(\"YES\") else print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d593501b3888370743d4efe02ae8ea3a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar (a,b) = readLine()!!.split(' ').map(String::toInt)\n\tvar y = 0\n\twhile (a <= b){\n\t\ta *= 3\n\t\tb *= 2\n\t\ty+=\n\t}\n\tprintln(y)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3ec38521dc34f670eff82f282e83356d", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\n\nobject Problem1A {\n val reader: BufferedReader\n get() = System.`in`.bufferedReader(Charsets.UTF_8)\n\n @JvmStatic\n fun main(args: Array) {\n val problemArguments = Arguments.from(reader.use { readLine() }!!)\n println(solve(problemArguments))\n }\n\n private fun solve(args: Arguments): Int {\n val column = (args.n + args.a - 1) / args.a\n val row = (args.m + args.a - 1) / args.a\n return column * row\n }\n\n data class Arguments(val n: Int, val m: Int, val a: Int) {\n companion object {\n fun from(input: String): Arguments {\n val splitInput = input.split(\"\\\\s+\".toRegex())\n return Arguments(splitInput[0].toInt(),\n splitInput[1].toInt(),\n splitInput[2].toInt())\n }\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2836f074d53026bf81830b355b8174d9", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package com.example.myapplication\n\nfun main(args: Array) {\n\n val line = readLine()!!.split(\" \")\n\n val m = line[0].toInt()\n val n = line[1].toInt()\n val a = line[2].toInt()\n\n val result = findTilesCount(m,n,a)\n\n println(result)\n}\n\nprivate fun findTilesCount(m :Int, n :Int, a :Int) : Long {\n\n var mDiv = m.toDouble() / a\n\n var nDiv = n.toDouble() / a\n\n var result = Math.ceil(mDiv) * Math.ceil(nDiv)\n\n return result.toLong()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fc7248b5b3a8360bc06c5c3f09dad7a1", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package me.sandesh.practice.compete.codeforces\n\nimport java.util.*\n\n\nclass TheatreSquare {\n companion object {\n fun calculateSize(length: Long, width: Long, flagstoneSize: Long): Long {\n var flagstones: Long = 0\n flagstones += ((length / flagstoneSize) * (width / flagstoneSize))\n if (length % flagstoneSize > 0)\n flagstones += width / flagstoneSize\n if (width % flagstoneSize > 0)\n flagstones += length / flagstoneSize\n if ((length % flagstoneSize > 0) && (width % flagstoneSize > 0))\n flagstones += 1\n return flagstones\n }\n }\n}\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val length = scanner.nextLong()\n val width = scanner.nextLong()\n val flagstoneSize = scanner.nextLong()\n\n var flagstones = TheatreSquare.calculateSize(length, width, flagstoneSize)\n println(flagstones)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "407e5668fa887e9b99851d1f78b50016", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (sn, sm, sa) = readLine()!!.split(' ')\n val n = sn.toInt()\n val m = sm.toInt()\n val a = sa.toInt()\n \n println((Math.ceil(n/a) * Math.ceil(m/a)).toInt())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cca5d34f9db64447b98fe3274e16dc02", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\ufeffIF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL\nBEGIN\n CREATE TABLE [__EFMigrationsHistory] (\n [MigrationId] nvarchar(150) NOT NULL,\n [ProductVersion] nvarchar(32) NOT NULL,\n CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])\n );\nEND;\n\nGO\n\nCREATE TABLE [DeviceCodes] (\n [DeviceCode] nvarchar(200) NOT NULL,\n [UserCode] nvarchar(200) NOT NULL,\n [SubjectId] nvarchar(200) NULL,\n [ClientId] nvarchar(200) NOT NULL,\n [CreationTime] datetime2 NOT NULL,\n [Expiration] datetime2 NOT NULL,\n [Data] nvarchar(max) NOT NULL,\n CONSTRAINT [PK_DeviceCodes] PRIMARY KEY ([UserCode])\n);\n\nGO\n\nCREATE TABLE [PersistedGrants] (\n [Key] nvarchar(200) NOT NULL,\n [Type] nvarchar(50) NOT NULL,\n [SubjectId] nvarchar(200) NULL,\n [ClientId] nvarchar(200) NOT NULL,\n [CreationTime] datetime2 NOT NULL,\n [Expiration] datetime2 NULL,\n [Data] nvarchar(max) NOT NULL,\n CONSTRAINT [PK_PersistedGrants] PRIMARY KEY ([Key])\n);\n\nGO\n\nCREATE UNIQUE INDEX [IX_DeviceCodes_DeviceCode] ON [DeviceCodes] ([DeviceCode]);\n\nGO\n\nCREATE UNIQUE INDEX [IX_DeviceCodes_UserCode] ON [DeviceCodes] ([UserCode]);\n\nGO\n\nCREATE INDEX [IX_PersistedGrants_SubjectId_ClientId_Type] ON [PersistedGrants] ([SubjectId], [ClientId], [Type]);\n\nGO\n\nINSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])\nVALUES (N'20181021143709_Grants', N'2.1.4-rtm-31024');\n\nGO\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aee861f4a47d78349a0f93381bd9898c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val i = readLine()!!.split(\" \").map{ it.toLong() }\n if(i[0] % i[2] != 0L) i[0] = i[0] - 1 + i[2]\n if(i[1] % i[2] != 0L) i[1] = i[1] - 1 + i[2]\n var r:Long = (i[0] / i[2]) * (i[1] / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e2a6e359cb6da76ff954fd061d132177", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "By agent-10, contest: Codeforces Beta Round #1, problem: (A) Theatre Square, Compilation error, #\n fun main() {\n val i = readLine()!!.split(\" \").map{ it.toLong() }\n val c1 = if(i[0] % i[2] != 0L) i[0] - 1 + i[2] else i[0]\n val c2 = if(i[1] % i[2] != 0L) i[1] - 1 + i[2] else i[1]\n var r:Long = (c1 / i[2]) * (c2 / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf6034bb5d9ed90caafd97fc3daf99de", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args: Array){\n val scan = Scanner(System.`in`)\n val n = scan.nextDouble()\n val m = scan.nextDouble()\n val a = scan.nextDouble()\n \n print(Math.ceil(n/a)*Math.ceil(m/a))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "85b583440e67c08bb5e7f5c52ca4413e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.roundToInt\nimport kotlin.math.sign\n\nclass Program {\n companion object {\n @JvmStatic fun main(args: Array) {\n val inputAr = readLine()!!.split(\" \")\n\n val n = inputAr[0].toInt()\n val m = inputAr[1].toInt()\n val a = inputAr[2].toInt()\n\n println((n / a + sign(n.toDouble() % a).roundToInt()) * (m / a + sign(m.toDouble() % a).roundToInt()))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d5474f52c9d0d40a9a6a18f54ae53add", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "val input = readLine()!!.split(\" \")\n\nval n = input[0].toInt()\nval m = input[1].toInt()\nval a = input[2].toInt()\n\nprintln((n / a + if (n % a == 0) 0 else 1) * (m / a + if (m % a == 0) 0 else 1))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "72f525ced36b7de2fd11357befe4e811", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package main\n\nfun main(args: Array) {\n println(4)\n}\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d666f0043ea23938309cc8cf11a39219", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.floor\n\nfun main(args: Array) {\n val (n, m, a) = readLine()!!.split(\" \").map { it.toDouble() }\n println(floor(n / a) * floor(n / b))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e8e18c561496306ef2ef6a92e97a119e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n\tval (m, n, a) = readLine()!!.split(\" \").map { it.toInt() }\n\tval aa = a.toDouble()\n\tprintln(Math.ceil(m / aa).roundToInt() * Math.ceil(n / aa).roundToInt())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aaffd04fae7e144e78eeaf44b584ed92", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package me.sandesh.practice.compete.codeforces\n\nimport java.util.*\n\n\nclass TheatreSquare {\n companion object {\n fun calculateSize(length: Long, width: Long, flagstoneSize: Long): Long {\n var flagstones: Long = 0\n flagstones += ((length / flagstoneSize) * (width / flagstoneSize))\n if (length % flagstoneSize > 0)\n flagstones += width / flagstoneSize\n if (width % flagstoneSize > 0)\n flagstones += length / flagstoneSize\n if ((length % flagstoneSize > 0) && (width % flagstoneSize > 0))\n flagstones += 1\n return flagstones\n }\n }\n}\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val length = scanner.nextLong()\n val width = scanner.nextLong()\n val flagstoneSize = scanner.nextLong()\n\n var flagstones = TheatreSquare.calculateSize(length, width, flagstoneSize)\n println(flagstoneSize)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5b0c4920872ccd3fb7d36a477e6ce0e3", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeForces\n\nfun main(args: Array) {\n val (n, m, a) = readLine()!!.split(' ').map(String::toInt)\n\n val res = Math.ceil((n.toDouble() / a)).toLong() * Math.ceil((m.toDouble() / a)).toLong()\n print(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0b14f15b1c3730672a2026d50d3502f8", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.*\n\nval sc = Scanner(System.`in`)\nval pw = PrintWriter(System.out)\n\ntailrec fun check(a: List, i: Int = 2): Boolean =\n when {\n i >= a.size -> true\n a[i] >= a[i - 1] + a[i - 2] -> false\n else -> check(a, i + 1)\n }\n\nfun swap(list: List, ind1: Int, ind2: Int): List {\n val newList = list as MutableList\n val tmp = list[ind1]\n newList[ind1] = list[ind2]\n newList[ind2] = tmp\n return newList\n}\n\nfun sort(a: List): List {\n if (a.size <= 1) return a\n val x = a.first()\n val (left, right) = a.filter { it < x } to a.filter { it > x }\n return sort(left) + listOf(x) + sort(right)\n}\n\nfun divUp(a: Int, b: Int) = (a + b - 1) / b;\nfun main() {\n val n = sc.nextLong()\n val m = sc.nextLong()\n val a = sc.nextLong()\n println(divUp(n, a) * divUp(m, a))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "75edb07b1b3fbb134d3dcbd63ee84b34", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package com.project.codeforces\n\nimport java.io.PrintWriter\nimport java.util.*\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\nfun main() {\n val data = read()\n println(data)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c68896363c2132c9915f32e594c8a241", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package net.imyoyo\n\nimport java.util.*\n\nfun main(args: Array) {\n val input = Scanner(System.`in`);\n val n = input.nextInt()\n val m = input.nextInt()\n val a = input.nextInt()\n println(ceilDivide(n.toLong(), a.toLong()) * ceilDivide(m.toLong(), a.toLong()))\n}\n\nfun ceilDivide(positiveDividend: Long, positiveDivisor: Long): Long {\n return (positiveDividend + positiveDivisor - 1) / positiveDivisor\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c300391f5726f0bda07543e130b3b488", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val scan = Scanner(System.`in`)\n val n = scan.nextDouble()\n val m = scan.nextDouble()\n val a = scan.nextDouble()\n\n print(Math.ceil(n / a) * Math.ceil(m / a))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "409938ee446d4d0f3bd56e81f697339a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.roundToInt\n\nfun main(args: Array) {\n val line = readLine()!!.split(\" \").map(String::toInt)\n\n val n = line[0]\n val m = line[1]\n val a = line[2]\n \n println((m/a).roundToInt() * (((n - a) / a).roundToInt() + 1))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c71354fee4aefadc86716bf6f6cb4783", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package com.project.codeforces\n\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n val data = read()\n println(data)\n}\n\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "92fbb34356d36c25de7a04b465647e64", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.roundToInt\nimport kotlin.math.sign\n\nclass Program {\n companion object {\n @JvmStatic fun main(args: Array) {\n val inputAr = readLine()!!.split(\" \")\n\n val n = inputAr[0].toInt()\n val m = inputAr[1].toInt()\n val a = inputAr[2].toInt()\n\n println((n / a + sign(n.toDouble() % a).roundToInt()) * (m / a + sign(m.toDouble() % a).roundToInt()))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "434d5a980c562dee6c0f8b8b871e5f4c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main() {\n val i = readLine()!!.split(\" \").map{ it.toLong() }\n val t1:Long = abs(i[0] % i[2])*i[1]\n val t2:Long = abs(i[1] % i[2])*i[0]\n \n var r:Long = (t1 + (i[0]) / i[2])) * (t2 + (i[1] + t2) / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "25dd74d8205f3f5730aa213f1e680f5c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val i = readLine()!!.split(\" \").map{ it.toLong() }\n val c1 = if(i[0] % i[2] != 0L) i[0] - 1 + i[2]\n val c2 = if(i[1] % i[2] != 0L) i[1] - 1 + i[2]\n var r:Long = (c1 / i[2]) * (c2 / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "964157965cb3fa56ae4a3be19c7c4957", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main() {\n val i = readLine()!!.split(\" \").map{ it.toLong() }\n if(i[0] % i[2] != 0) i[0] = i[0] - 1 + i[2]\n if(i[1] % i[2] != 0) i[1] = i[1] - 1 + i[2]\n var r:Long = (i[0] / i[2]) * (i[1] / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f7b649bfd2dcbafeb406f45917c967c4", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m, a) = readLine()!!.split(' ').map(String::toLong)\n println(((n + a - 1) / a) * ((n + a - 1) / a) - if (n % a != 0 && m % a !!= 0) 1 else 0)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "06ebb178be75e491448cbf125d24bb39", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforces\n\n/**\n * Created by vashzhong on 2017/5/26.\n */\n\nfun solve(n: Long, m: Long, a: Long) : String{\n return (Math.ceil(n.toDouble() / a) * Math.ceil(m.toDouble() / a)).toInt().toString()\n}\n\nfun main(args: Array) {\n var readLine = readLine()\n while (readLine != null) {\n val input = readLine.split(' ')\n if (input.size >= 3) {\n val n = input[0].toLong()\n val m = input[1].toLong()\n val a = input[2].toLong()\n val result = solve(n, m, a)\n println(result)\n }\n readLine = readLine()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e965c37d0bbb9892fb035b66cf1209cf", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic fun main(args: Array) {\n System.out.println(\"args:\"+args.toList().toString());\n\n val width = args[0].toInt()\n\n val height = args[1].toInt()\n\n val size = args[2].toInt()\n\n\n val a = Math.ceil(height.toDouble()/size.toDouble())\n\n val b = Math.ceil(width.toDouble()/size.toDouble())\n\n System.out.println((a*b).toInt());\n\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3d881f6943cecc18f1e9dd9fde61be03", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val x = nextInt()\n val y = nextInt()\n val z = nextInt()\n val p = Math.ceil(x / z) * Math.ceil(y / z) \n println(p)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6991e9e09f141a59b26b60c93ba2ce27", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport java.util.*\n\n/**\n * Created by rohmanhakim on 3/2/18.\n */\n\nfun leastFlagStones(squareLength: Int, paveLength: Int): Int =\n if((squareLength % paveLength) > 0) (squareLength / paveLength) + 1 else (squareLength / paveLength)\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt()\n val m = nextInt()\n val a = nextInt()\n\n println(leastFlagStones(n,a) * leastFlagStones(m,a))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c8cd22e0b8f56c7994c3c862ef068f60", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "1A_Theatre_Square.kt", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7dad6699ebe593e318526244443dd7af", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "class Program {\n fun main() {\n val input = readLine()!!.split(\" \")\n\n val n = input[0].toInt()\n val m = input[1].toInt()\n val a = input[2].toInt()\n\n println((n / a + if (n % a == 0) 0 else 1) * (m / a + if (m % a == 0) 0 else 1))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f185d11bd5de6bc86fea675d664a5d1f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package default\n\nimport java.util.*\n\nclass Program {\n companion object {\n fun calculateSize(length: Long, width: Long, flagstoneSize: Long): Long {\n var flagstones: Long = 0\n flagstones += ((length / flagstoneSize) * (width / flagstoneSize))\n if (length % flagstoneSize > 0)\n flagstones += width / flagstoneSize\n if (width % flagstoneSize > 0)\n flagstones += length / flagstoneSize\n if ((length % flagstoneSize > 0) && (width % flagstoneSize > 0))\n flagstones += 1\n return flagstones\n }\n }\n}\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val length = scanner.nextLong()\n val width = scanner.nextLong()\n val flagstoneSize = scanner.nextLong()\n\n var flagstones = Program.calculateSize(length, width, flagstoneSize)\n println(flagstones)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cedd9d604686a16bb47b9fb955abc03f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforce\n\nimport java.util.*\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val n = input.nextInt()\n val m = input.nextInt()\n val a = input.nextInt()\n println((if (n % a != 0) (n / a + 1) else (n / a)) * (if (m % a != 0) (m / a + 1) else (m / a)))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3b2b2f4ea25dccf11716f71326a002ac", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m, a) = readLine()!!.split(' ').map(String::toLong)\n println(((n + a - 1) / a) * ((n + a - 1) / a) - if (n % a != 0 && m % a != 0) 1 else 0)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8585f9c64c3fce8bc761914bdb088272", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args:Array){\n var (n, m, a) = readLine()!!.split(' ').map (String::toInt)\n var l:Long = n/a\n var w:Long = m/a\n if(n%a > 0)l = l+1\n if(m%a > 0)w = w+1\n\n print(l*w)\n}\n ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "64546d86f38672b3ebce7fe59aa56836", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\n\nobject Problem1A {\n val reader: BufferedReader\n get() = System.`in`.bufferedReader(Charsets.UTF_8)\n\n @JvmStatic\n fun main(args: Array) {\n val problemArguments = parse(reader.use { readLine() }!!)\n println(solve(problemArguments))\n }\n\n private fun solve(args: Arguments): Int {\n val column = (args.n + args.a - 1) / args.a\n val row = (args.m + args.a - 1) / args.a\n return column * row\n }\n\n private fun parse(input: String): Arguments {\n val splitInput = input.split(\"\\\\s+\".toRegex())\n return Arguments(splitInput[0].toInt(),\n splitInput[1].toInt(),\n splitInput[2].toInt())\n }\n\n data class Arguments(val n: Int, val m: Int, val a: Int)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "615fb80ea9a3ffae570977c831fffd2c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val a = nextInt()\n val b = nextInt()\n val c = nextInt()\n val d = x(a,c) * x(b,c)\n println(d)\n}\n\nfun x(a : Int , b:Int) : Long {\n val x = if (a % b == 0) 0 else 1\n return a / b + x\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0645ab9eb4884ef6bc2a3ecf04c27e85", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package com.keystarr\n\nfun main(args: Array){\n val (n, m, a) = readLine()!!.split(' ').map { it.toDouble() }\n val widthPlates = Math.ceil(m / a).toInt()\n if (n <= a)\n print(widthPlates)\n else{\n val heightPlates = Math.ceil(n / a).toInt()\n print(widthPlates + heightPlates)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "02518104083bfb6c151973afc1de7f1d", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "//problem of codeforces 1A\nimport java.util.*\nfun main(args: Array)\n{\n val sc=Scanner(System.`in`)\n var n=sc.nextLine().toInt()\n var m=sc.nextLine().toInt()\n var a=sc.nextLine().toInt()\n var ans1: Long\n var ans2:Long\n if(n%a==0)\n {\n ans1= (n/a).toLong()\n }\n else\n {\n ans1=1+(n/a).toLong()\n }\n if(m%a==0)\n {\n ans2=(m/a).toLong()\n }\n else\n {\n ans2=1+(m/a).toLong()\n }\nprint(r1*r2)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b076adda1ade65b100fbcf3a2be086ba", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val i = readLine()!!.split(\" \").map{ it.toInt() }\n val t1 = abs(i[0] % i[2])\n val t2 = abs(i[1] % i[2])\n \n println((t1 + i[0] / i[2]) * (t2 + i[1] / i[2]))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a9aa92deb7eefc68513476ec9e4d35cf", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "/*\n* Problem Statement: \n* Author: ganpa\n*/\n#include \n\n#define sz(x) (int)(x).size()\n#define all(v) v.begin(), v.end()\n#define endl '\\n'\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\nusing namespace std;\n\nvoid solve()\n{\n int n;\n cin >> n;\n if (n % 2) {\n int ans = n - 1, a = n / 2, b = n - a, x = 1, y = n - 1;\n while(a) {\n int c = (a * b) / (__gcd(a, b));\n if (c < ans) ans = c, x = a, y = b;\n a--, b++;\n }\n cout << x << \" \" << y << endl;\n }\n else cout << n / 2 << \" \" << n / 2 << endl;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n int tc;\n cin >> tc;\n while (tc--)\n solve();\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "93ac86d740c978eb065a6c239466e688", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(\" \").map{i -> i.toInt()}.toMutableList()\nfun readInt() = readLine()!!.toInt()\nfun readLongs() = readLine()!!.split(\" \").map{i -> i.toLong()}.toMutableList()\n\nfun main() {\n val t = readInt()\n repeat(t) {\n val n = readInt()\n if (n % 2 == 0) {\n println(\"${n / 2} ${n / 2}\")\n } else {\n var a = sqrt(n.toDouble()).toInt()\n var b = n - a\n while(b % a != 0) {\n a--\n b++\n }\n println(\"$a $b\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7511414e96e54001bb30d920725c75c6", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n\n repeat(readLine()!!.toInt()) {\n val num = readLine()!!.toInt()\n val leastPrime = leastPrime(num)\n println(\"${num / leastPrime} ${num / leastPrime * (leastPrime - 1)}\")\n }\n\n}\n\nfun leastPrime(n: Int): Int {\n var num = 2\n if (n % 2 == 0)\n return 2\n num += 1\n while (n % num != 0 && num < sqrt(n.toDouble())) {\n num += 2\n }\n return num\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "17613f1199ce8d58af146f6f52f3aac9", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package com.sabbir\n\nimport java.util.Scanner\n\nobject Main {\n @JvmStatic\n fun main(args: Array) {\n val gameList = takeInput()\n var result = true\n var prevWinner = gameList[0]\n var prevLooser = 3 - gameList[0]\n var prevWatcher = 3\n for(i in 1 until gameList.size) {\n val currentWinner = gameList.get(i)\n var currentLooser: Int;\n if(currentWinner == prevWinner) {\n currentLooser = prevWatcher;\n } else {\n currentLooser = prevWinner;\n }\n var currentWatcher = prevLooser;\n if(currentWinner==prevLooser) {\n result = false\n break\n }\n prevWinner = currentWinner;\n prevLooser = currentLooser;\n prevWatcher = currentWatcher;\n }\n if(result) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }\n\n fun takeInput(): IntArray {\n val scanner = Scanner(System.`in`);\n val numOfGames = scanner.nextInt();\n val gameList = IntArray(numOfGames);\n for(i in 0 until numOfGames) {\n gameList[i] = scanner.nextInt()\n }\n return gameList\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "176758c940a5368496edeed5a2270b68", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun myFunction() { val input = Scanner(System.`in`) val a = input.nextInt() val b = input.nextInt() if (a == b) { System.out.println(\"=\") } else { if (Math.log(a.toDouble()) > Math.log(b.toDouble())) System.out.println(\">\") else System.out.println(\"<\") } }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fcbd7a52b8179c158c2947f251254de9", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun myFunction() {\n val input = Scanner(System.`in`)\n val a = input.nextInt()\n val b = input.nextInt()\n if (a == b) {\n System.out.println(\"=\")\n } else {\n if (Math.log(a.toDouble()) > Math.log(b.toDouble())) System.out.println(\">\") else System.out.println(\"<\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "375c1059591b15bc778260253397c5c4", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n val cardLayout = readLine()!!.split(\" \")\n .sorted()\n\n //koutsu\n val maxTriple = cardLayout.groupBy { it }\n .mapValues { it.value.size }\n .values.max() ?: 1\n\n //shuntsu\n val maxStraigt = findStraight(cardLayout)\n\n println(\"\" + (3 - kotlin.math.max(maxTriple, maxStraigt)))\n}\n\nfun findStraight(cards: List): Int {\n var straigth = 1\n val firstCard = cards[0]\n var numI = firstCard[0]!!.toInt()\n var typeI = firstCard[1]\n\n for (i in 1 until 3) {\n val card = cards[i]\n var numC = card[0]!!.toInt()\n val typeC = card[1]\n\n if (typeC == typeI) {\n if (numC == numI + 1) {\n straigth++\n } else if (numC == numI + 2) {\n return 2\n }\n }\n\n numI = numC\n typeI = typeC\n }\n return straigth\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f00a4cb6613e9ad6c31b9bbc2d136706", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\nimport java.util.*\nimport kotlin.collections.ArrayList\n\nclass Tree (\n private var vertexNumber: Int,\n private var colors: IntArray,\n private var targetColors: IntArray,\n private var edges: ArrayList>\n) {\n private var arcs: Array> = emptyArray()\n\n /**\n * Clears and initializes lists of the adjacency lists for all vertices\n * */\n private fun initArcs() {\n arcs = Array(vertexNumber) { TreeSet() }\n for (v in 0 until vertexNumber) {\n arcs[v].clear()\n }\n for (edge in edges) {\n addEdge(edge.first - 1, edge.second - 1) // 1-index to 0-indexed\n }\n }\n\n /**\n * Adds the undirected edges into the tree\n * @param u is the first vertex of the edge\n * @param v is the second vertex of the edge\n * */\n private fun addEdge(u: Int, v: Int) {\n arcs[u].add(v)\n arcs[v].add(u)\n }\n\n /**\n * Removes the undirected edge from the tree\n * @param u is the first vertex of the edge\n * @param v is the second vertex of the edge\n * */\n private fun removeEdge(u: Int, v: Int) {\n arcs[u].remove(v)\n arcs[v].remove(u)\n }\n\n /**\n * Removes all the leafs which have already satisfied\n * conditions, i.e. such leafs, which has target color at\n * the very beginning will be deleted from the tree. Note\n * that after removing the first layer of satisfied leafs\n * the next layer will be considered and so on\n * */\n private fun removeRealisedLeafs() {\n val queue = LinkedList()\n for (v in 0 until vertexNumber) {\n if (arcs[v].size == 1 && colors[v] == targetColors[v]) {\n queue.add(v)\n }\n }\n while (!queue.isEmpty()) {\n val v = queue.poll()\n if (arcs[v].size == 1) {\n val to = arcs[v].first()\n removeEdge(v, to)\n if (colors[to] == targetColors[to]) {\n queue.add(to)\n }\n }\n }\n }\n\n /**\n * Finds the path from vertex {@code fr} to vertex {@code to}\n *\n * @param fr is the start vertex of the path\n * @param to is the finish vertex of the path\n *\n * @return the path from {@code fr} to {@code to}\n * */\n private fun getPath(fr: Int, to: Int): List {\n initArcs()\n val used = BooleanArray(vertexNumber) { false }\n val from = IntArray(vertexNumber) { -1 }\n val queue = LinkedList()\n used[fr] = true\n queue.add(fr)\n while (!queue.isEmpty()) {\n val v = queue.poll()\n for (u in arcs[v]) {\n if (!used[u]) {\n used[u] = true\n from[u] = v\n queue.add(u)\n }\n }\n }\n val path = LinkedList()\n path.add(to)\n while (path.last() != fr) {\n path.add(from[path.last()])\n }\n path.reverse()\n return path\n }\n\n /**\n * Checks whether {@code path} can recolor vertices correctly\n *\n * @param path is the path to be checked\n * @return {@code true} iff {@code path} can recolor vertices correctly\n * */\n private fun checkPath(path: List): Boolean {\n val tmpColors = colors.copyOf()\n var previous: Int? = null\n for (v in path) {\n if (previous == null) {\n previous = v\n continue\n }\n tmpColors[previous] = tmpColors[v].also { tmpColors[v] = tmpColors[previous!!] }\n previous = v\n }\n return tmpColors.contentEquals(targetColors)\n }\n\n /**\n * Finds such a path, which can recolor vertices correctly\n * @return path itself if such exists. Otherwise {@code null}\n * will be returned\n * */\n fun findKingPath(): List? {\n if (colors.contentEquals(targetColors)) {\n return emptyList()\n }\n initArcs()\n removeRealisedLeafs()\n var firstLeaf: Int? = null\n var secondLeaf: Int? = null\n for (v in 0 until vertexNumber) {\n if (arcs[v].size == 1 && colors[v] != targetColors[v]) {\n when {\n firstLeaf == null -> firstLeaf = v\n secondLeaf == null -> secondLeaf = v\n else -> return null\n }\n }\n }\n if (firstLeaf == null || secondLeaf == null) {\n return null\n }\n val firstPath = getPath(firstLeaf, secondLeaf)\n var resultPath: List? = null\n if (checkPath(firstPath)) {\n resultPath = firstPath\n } else {\n val secondPath = getPath(secondLeaf, firstLeaf)\n if (checkPath(secondPath)) {\n resultPath = secondPath\n }\n }\n return resultPath?.map { v -> v + 1 }\n }\n\n companion object {\n /**\n * Shows the path as the sequence of vertices in it\n **/\n fun showPath(path: List) {\n println(path.size)\n for (v in path) {\n print(\"${v} \")\n }\n println()\n }\n }\n}\n\nfun solve() {\n val vertexNumber = readLine()!!.toInt()\n val colors = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val targetColors = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val edges = ArrayList>()\n for (i in 1 until vertexNumber) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt() }\n edges.add(Pair(u, v))\n }\n\n val tree = Tree(vertexNumber, colors, targetColors, edges)\n val path = tree.findKingPath()\n if (path == null) {\n println(\"No\")\n } else {\n println(\"Yes\")\n Tree.showPath(path)\n }\n}\n\nfun main() {\n val testNumber = readLine()!!.toInt()\n for (test in 0 until testNumber) {\n solve()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b3074dc518a5e8db90fed1b71e7d00c0", "src_uid": "78f839ac8cd0a716a0f0211fe3219520", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.util.ArrayList\nimport java.util.Comparator\nimport java.util.HashSet\nimport java.util.Scanner\n\n @JvmStatic fun main(args:Array) {\n var `in` = Scanner(System.`in`)\n var n = `in`.nextInt()\n var k = `in`.nextInt()\n for (i in 0 until k)\n {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "63d38f79910198804b02b2931f6bac3d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val (n, k) = readInts()\n\n for(do_this in 1..k)\n {\n if(n%10 == 0) n = n/10\n else n = n-1\n }\n\n print(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "10bdf9fe1ae15b223f00c9942cdf312a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package practice2.a\n\nimport java.util.stream.IntStream\n\nobject WrongSubtraction {\n\n fun subtract(_number: Int, times: Int): Int {\n var number = _number\n\n IntStream.range(0, times).forEach {\n if (number % 10 == 0) {\n number /= 10\n } else {\n number--\n }\n }\n\n return number\n }\n\n}\n\nfun main(args: Array) {\n println(WrongSubtraction.subtract(args[0].toInt(), args[1].toInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b8ab16dd77f4e7623b7fdec33658ad3c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n // Creates a reader instance which takes\n // input from standard input - keyboard\n val reader = Scanner(System.`in`)\n // nextInt() reads the next integer from the keyboard\n var n:Int = reader.nextInt()\n // println() prints the following line to the output screen\n var k:Int = reader.nextInt()\n for(i in 1..k)\n {\n if(n%10)\n n--\n else\n n=n/10\n }\n println(result)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "74590085264b561429f6f22ba817bb13", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/**\n * You can edit, run, and share this code. \n * play.kotlinlang.org \n */\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n println(readLine())\n val nums = readInts()\n var n = nums[0]\n val k = nums[1]\n while (k > 0) {\n if (n % 2 == 0) {\n n /= 10\n } else {\n n--\n }\n k--\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1b5f50ff4e3fb84fa063006e510ef717", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n\tint n, k;\n\tcin >> n >> k;\n\tfor(int i = 1; i<=k; i++)\n\t{\n\t\tif(n % 10) n-=1;\n\t\telse n /= 10;\n\t}\n\tcout << n << endl;\n\treturn 0;\n } \n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1223a42cc86fa693d8ccbef5107a5be7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// 02.09.2019\n\n\nimport java.util.*\nimport kotlin.system.exitProcess\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { x: String -> x.toInt() } // list of ints\n\nfun main ()\n{\n val (n, k) = readInts ();\n while( k != 0 )\n {\n k--;\n if ( n % 10 == 0 )\n n /= 10;\n else\n n --;\n println (\"$n\");\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "10efc67e8fb432793bb1da2790ace094", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b) = readLine()!!.split(' ')\n var n = a.toInt(), k = b.toInt()\n for (i in 1..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aa1cc24a4dabe596843000981595db53", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\n\nfun main() {\n val input = readLine()!!\n var i = input.indexOf(' ') - 1\n var k = input.substring(i + 2).toInt()\n var digit = input[i].toInt() - 48\n\n while (k > digit) {\n k -= digit + 1\n digit = input[--i].toInt() - 48\n }\n\n val output = parseInt(input, 0, i + 1, 10) - k\n println(output)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "59afb9d5a64324c3d03e9a18548524e0", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.sequences.*\n\nfun main() {\n val scan = Scanner(System.in)\n val orig = scan.nextInt()\n val count = scan.nextInt()\n generateSequence(orig) {\n if (it % 10 == 0)\n it / 10\n else\n it - 1\n }.drop(count).first().apply(::println)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "24b1d732a81ead11f40334f6dc0cd3d4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, k) = readInts()\n\n var result = n.toString()\n\n repeat(k) {\n result = if(result.last().toString().toInt() == 0) {\n (result.toInt()/10).toString()\n } else {\n (result.toInt() - 1).toString()\n }\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1aede2a582d1ec735c14a50d39d73a27", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(): Unit {\n var (n, k) = readLine()!!.split(\" \")!!.let { Pair(it[0].toInt(), it[1].toInt()) }\n repeat(k) {\n if (n.toString().last() == \"0\") {\n n = n / 10\n } else {\n n = n -1\n }\n }\n return n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fc3ef0dbedcd10f01925f1e6ad629374", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun getSub(s: Long): Long{\n val n = s%10\n return if(n != 0L)\n s-1\n else s/10\n\n}\n\nfun wrongSub(x: Long, y: Int){\n while(true){\n val s1 = getSub(x)\n if( y == 1) {\n print(s1)\n break\n }\n wrongSub(s1, y-1)\n }\n}\nfun main() {\n val x = readLine()?.toLong()\n val y = readLine()?.toInt()\n wrongSub(x, y)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "801cf7fe598d8203d52688db8dc4e79f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package platforms.codeforces.problemset\n\nfun main() {\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var r = a[0];\n for (i in 1..a[1]) {\n if (r % 10 != 0) {\n r--\n } else {\n r /= 10\n }\n }\n print(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f156c65249628ec9faef0057ba0f1036", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n val input = readLine()!!\n var i = input.indexOf(' ') - 1\n var k = input.substring(i + 2).toInt()\n var digit = input[i].toInt() - 48\n\n while (k > digit) {\n k -= digit + 1\n digit = input[--i].toInt() - 48\n }\n\n val output = Integer.parseInt(input, 0, i + 1, 10) - k\n println(output)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d45e2a817431bcf905f288db129c9cfd", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nimport java.util.Scanner\nimport java.io.*\n \nfun main() {\n val input = Scanner(System.`in`)\n val a = input.nextInt();\n var b = input.nextInt();\n print(\"$a,$b)\n \n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "33bdfc4effa46d8b16b089db281f11f9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\n \nprivate val OUTPUT_LINES = mutableListOf()\nprivate fun outputLn(s: String) { OUTPUT_LINES += s }\n \nfun go() {\n var (n , k) = readLongs()\n for(i in 1..k){\n if(n%10 == 0)\n n/=10;\n else\n n-=1;\n }\n outputLn(\"${n+1}\")\n}\n \nfun main() {\n val T = readInt()\n for (t in 1..T) { go() }\n println(OUTPUT_LINES.joinToString(\"\\n\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cfe4643c5085b31b0dd3f3d9703a6901", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n var integer:Int = reader.nextint()\n var integer1:Int = reader.nextint()\n while(integer1!=0)\n {\n if(integer%10==0){integer/=10}\n else{\n integer--\n }\n integer1--\n }\n println(integer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b4e2e1ab1cb289c15a1104cde006efb1", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package artemser.contest\n\nfun main(args: Array) {\n println(args.toString())\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "89aa7586e59743a1eaaaffd886638a6d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.test\n\nfun main(args: Array) {\n val result = decrease(args[0].toInt(),args[1].toInt())\n println(result)\n}\n\nfun decrease(number: Int, times: Int): Int {\n var numberStr = number.toString()\n var lastChar = numberStr.takeLast(1)\n var lastCharAsNumber = lastChar.toInt()\n var newNumber = number\n\n for(j in 1..times) {\n if(lastCharAsNumber!=0) {\n newNumber= newNumber-1;\n }\n else {\n newNumber=newNumber/10;\n }\n\n numberStr = newNumber.toString()\n lastChar = numberStr.takeLast(1)\n lastCharAsNumber = lastChar.toInt()\n }\n return newNumber\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e4ef902d3b202625d116f29cf025f4c0", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint main()\n{\n int x,y;\n scanf(\"%d %d\",&x,&y);\n while(y--)\n {\n if(x%10==0) x=x/10;\n else x--;\n }\n printf(\"%d\\n\",x);\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3ec5cebaf4d7b1e95ef694961b33225c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(): Unit {\n var (n, k) = readLine()!!.split(\" \")!!.let { Pair(it[0].toInt(), it[1].toInt()) }\n repeat(k) {\n if (n.toString().last() == '0') {\n n = n / 10\n } else {\n n = n -1\n }\n }\n return n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "94042e19299d2e543be01878c6598621", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport java.util.*\n\nfun main() {\n val s = Scanner(System.`in`)\n var n = s.nextInt()\n val k = s.nextInt()\n\n for(i in k downTo 1) {\n if(n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c73849f8b165c2f584999b0d6d170b64", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsValue(1)){\n\t\tprintln(\"HARD\")\n\t}\n\telse{\n\t\tprintln(\"EASY\")\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "720134c9ea09919c29100120f19823a5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Application {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n val parts = readLine()!!.split(' ')\n val n = parts.first().toMutableList()\n val k = parts.last().toInt()\n\n repeat(k) {\n val lastChar = n.last()\n if (lastChar == '0') {\n n.removeAt(n.lastIndex)\n } else {\n n[n.lastIndex] = lastChar.toInt().dec().toChar()\n }\n }\n \n println(n.joinToString(separator = \"\"))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "307eb84fd7960cece0b143eef3b35d38", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package platforms.codeforces.problemset\n\nclass WrongSubtraction {\n fun main() {\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var r = a[0];\n for (i in 1..a[1]) {\n if (r % 10 != 0) {\n r--\n } else {\n r /= 10\n }\n }\n print(r)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "71478bd207f0fde0d132b7519c7900fc", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package Codes\n\nfun main() {\n var (n, k) = readLine()!!.split(' ').map { it.toInt() }\n while (k-- > 0) {\n if ((n % 10) == 0) {\n n /= 10;\n } else {\n n--;\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fbb34badb94e1dce068cfab61486c24e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine!!.trim().split().map({y -> y.toULong()})\n println(subtractResult(x[0],x[1]))\n}\n\nfun subtractResult(value: ULong, subOp: ULong): ULong {\n if (subOp == 0) {\n return value\n } else {\n if ((value % 10UL) == 0UL) {\n return subtractResult((value/10UL),subOp-1)\n } else {\n return subtractResult((value-1UL),subOp-1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a83984dd4deb206c12e1028101917fb9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.vjgarcia.kotlinheroespractice\n\nimport java.util.*\n\nfun main() {\n Scanner(System.`in`).use { scanner ->\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n println(solve(n, k))\n }\n}\n\nprivate fun solve(n: Int, k: Int): Int {\n var number = n\n\n for (index in 0 until k) {\n number = decrease(number)\n }\n\n return number\n}\n\nprivate fun decrease(number: Int): Int =\n when (number % 10) {\n 0 -> number / 10\n else -> number - 1\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c4d5e201928e844568a8a44c3e47146b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package artemser.practice\nfun main(args: Array) {\n val input = readLine()\n if (input != null) {\n val numbers = input.split(\" \")\n print(calcWrong(numbers))\n }\n}\n\nfun calcWrong(numbers: List): Int{\n var value = numbers[0].toInt()\n val amount = numbers[1].toInt()\n for (x in amount downTo 1){\n value = calc(value);\n }\n return value;\n}\n\nfun calc(value: Int): Int {\n return if (value % 10 == 0) value/10\n else value-1\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d7cea841b858f751c658a8798d8be83", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine()!!.trim().split().map({y -> y.toULong()})\n println(subtractResult(x[0],x[1]))\n}\n\nfun subtractResult(value: ULong, subOp: ULong): ULong {\n if (subOp == 0) {\n return value\n } else {\n if ((value % 10UL) == 0UL) {\n return subtractResult((value/10UL),subOp-1)\n } else {\n return subtractResult((value-1UL),subOp-1)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dc828ed92655c1d9455a0121ad170707", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n var integer:Int = reader.nextInt()\n var integer1:Int1 = reader.nextInt()\n while(Int1)\n {\n if(Int%10==0){Int/=10}\n else{\n Int--\n }\n Int1--\n }\n println(integer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e26687349ae614355031e17c005249e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package pratice\n\nfun main() {\n var (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n for (i in 1..k) {\n if (n % 10 == 0 && n > 9) {\n n /= 10\n } else {\n n -= 1\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "afd50d2dbd1d5b4f375e2a29ca16d9df", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main() {\n val input = Scanner(System.`in`)\n \n val n = input.nextLine().toInt()\n val k = input.nextLine().toInt()\n\n while (k > 0) {\n if (n % 10 != 0) {\n n--\n } else {\n n /= 10\n }\n k--\n }\n print(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0bb9351777f3957aee0af48e906db1c0", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\t fun main(args: Array) {\n\t val n = readLine()!!.toInt()\n\t val k = readLine()!!.toInt()\n\t for (i in 1 until k) {\n\t \tif( !(n % 10)) n = n / 10\n\t else n = n-1\n\t }\n\t println(n)\n\t}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "01a72e0c2e9b0c6dac090b071481503d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine()!!.trim().split().map({y:String -> y.toULong()})\n println(subtractResult(x[0],x[1]))\n}\n\nfun subtractResult(value: ULong, subOp: ULong): ULong {\n if (subOp == 0UL) {\n return value\n } else {\n if ((value % 10UL) == 0UL) {\n return subtractResult((value/10UL),subOp-1UL)\n } else {\n return subtractResult((value-1UL),subOp-1UL)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9fae7bd8970125e8140b8daf3bd6e58c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n for (var i in 1..k) {\n \tif( n % 10 == 0) n = n / 10\n else n = n-1\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c963e7d50adaecbedb843a992acfc252", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n var n:Int=Integer.valueOf(readLine())\n var k=Integer.valueOf(readLine())\n var i:Int=1\n while(i<=k)\n {\n if(n%10==0)\n {\n n=n/10\n }\n else if(n%10!=0)\n {\n n=n-1\n }\n i++\n }\n println(num)\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aa629abe26e0ec493f600e17f015687f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "typealias TanyaInt = Int\n\ndata class Operators(val minuend: Int, val subtrahend: Int)\n\nfun TanyaInt.decrement(): Int =\n if (this % 10 == 0) {\n this / 10\n } else {\n this - 1\n }\n\ninfix fun TanyaInt.subtract(subtrahend: Int): Int =\n (1..subtrahend).fold(this) { acc, _ ->\n acc.decrement()\n }\n\nfun StringTokenizer.nextInt(): Int = this.nextToken().toInt()\n\nfun readInput(inputStream: InputStream): Operators {\n val inputStreamReader = InputStreamReader(inputStream)\n val bufferedReader = BufferedReader(inputStreamReader)\n\n val inputLine = bufferedReader.readLine()\n val tokenizer = StringTokenizer(inputLine, \" \")\n\n return Operators(\n minuend = tokenizer.nextInt(),\n subtrahend = tokenizer.nextInt()\n )\n}\n\nfun main() {\n\n val (minuend, subtrahend) = readInput(System.`in`)\n\n val result = minuend subtract subtrahend\n\n print(result)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "38f33f471a3297b8d677a66dd695d1be", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n var n = readInts()\n while (n[1] != 0) {\n n.set(1, n[1]-1)\n if (n[0] % 10 == 0)\n n.set(0, n[0]/ 10)\n else\n n.set(0, n[0]-1)\n }\n print(n)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "af5500f60ebd97a14588824625b1d368", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "from collections import deque\n\nn_k = [int(i) for i in input().split()]\n\nn=n_k[0]\nk=n_k[1]\n\nd = deque([ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , ]) \n\nfor j in range(k):\n if n == 0 :\n break\n rts=str(n);\n units=rts[-1]\n if units == '0':\n n=int(rts[:-1]) \n else :\n pos=d.index(int(units))\n d.rotate(1)\t\n n=int(rts[:-1]+str(d[pos]))\n\n\nprint(n)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67705d29f33b2c24f87c5142747c0375", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{\n val sc = Scanner(System.`in`)\n\n var n = sc.nextInt() \n var k = sc.nextInt() \n\n for(i in 1..k)\n {\n n = if(n % 10 == 0) {\n n / 10\n } else {\n n - 1\n }\n }\n println(n)\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "92d976198e8ee622a48664b45c7e71f4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package programkt\n\nfun main(){\n var input: List = readLine()!!.split(\" \").map { it.toInt() }\n var retVar = input[0]\n for(i in 1..input[1].toInt()){\n retVar = if(retVar % 10 == 0) retVar / 10 else retVar - 1\n }\n println(retVar)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4bba79cef326280c80f853c587ea35dc", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val input = readLine()!!\nval (nStr, kStr) = input.split(\" \")\n\nval zero = '0'.toInt()\nval k = kStr.toInt()\n\nval (restK, restN) = nStr\n .foldRight(k to \"\") { c, (accK, accS) ->\n if (accK == 0) {\n accK to (c + accS)\n } else {\n val digit = c.toInt() - zero\n val newDigit = digit - accK\n val subs = accK - digit\n if (newDigit < 0) {\n (subs - 1) to accS\n } else {\n subs to ((newDigit.toChar() + zero) + accS)\n }\n }\n }\n\nprintln(restN)\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4c5e0f12f73e0f16aca1fa1d46b06fc8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\nobject TaskA {\n @Throws(IOException::class)\n @JvmStatic\n fun main(args: Array) {\n var n: Int\n val k: Int\n val br = BufferedReader(InputStreamReader(System.`in`))\n val zer = StringTokenizer(br.readLine())\n n = Integer.parseInt(zer.nextToken())\n k = Integer.parseInt(zer.nextToken())\n for (i in 0 until k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "58abf1dd396c43c453ea7d74a9aab5ca", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\nimport java.lang.Long.parseLong\nimport java.lang.System.exit\n\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\n\nobject A {\n\n internal var `in`: BufferedReader? = null\n internal var out: PrintWriter? = null\n internal var tok: StringTokenizer? = null\n\n @Throws(Exception::class)\n internal fun solve() {\n var n = scanInt()\n val k = scanInt()\n for (i in 0 until k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n --n\n }\n }\n out!!.print(n)\n }\n\n @Throws(IOException::class)\n internal fun scanInt(): Int {\n return parseInt(scanString())\n }\n\n @Throws(IOException::class)\n internal fun scanLong(): Long {\n return parseLong(scanString())\n }\n\n @Throws(IOException::class)\n internal fun scanString(): String {\n while (tok == null || !tok!!.hasMoreTokens()) {\n tok = StringTokenizer(`in`!!.readLine())\n }\n return tok!!.nextToken()\n }\n\n @JvmStatic\n fun main(args: Array) {\n try {\n `in` = BufferedReader(InputStreamReader(System.`in`))\n out = PrintWriter(System.out)\n solve()\n `in`!!.close()\n out!!.close()\n } catch (e: Throwable) {\n e.printStackTrace()\n exit(1)\n }\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "46eed18db646ea2ed7168d9b4c5262f2", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject WrongSubtraction {\n @JvmStatic\n fun main(args: Array) {\n var n: Int\n var k: Int\n val sc = Scanner(System.`in`)\n n = sc.nextInt()\n k = sc.nextInt()\n while (k > 0) {\n if (n % 10 != 0 && n % 10 <= k) {\n val tmp = n % 10\n n = n - tmp\n k -= tmp\n } else if (n % 10 != 0 && n % 10 > k) {\n n = n - k\n k = 0\n } else {\n while (n % 10 == 0) {\n n = n / 10\n k -= 1\n }\n }\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0c9cfc0d6e431d716ca3806c36878ffd", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, k) = readLine()!!.split(' ')\n n = n.toInt()\n k = k.toInt()\n for (i in 0..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n -= 1\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "507b73202e4948a0c8741c0d71e62c61", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author maxkibble\n */\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = Scanner(inputStream)\n val out = PrintWriter(outputStream)\n val solver = TaskA()\n solver.solve(1, `in`, out)\n out.close()\n}\n\nfun solve(testNumber: Int, `in`: Scanner, out: PrintWriter) {\n var n = `in`.nextInt()\n var k = `in`.nextInt()\n while (k > 0) {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n k--\n }\n out.println(n)\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e10dc2e2d8fd1c611f877796cf3d61ca", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n var integer:Int = reader.nextInt()\n var integer1:Int1 = reader.nextInt()\n while(Int)\n {\n if(Int%10==0){Int/=10}\n else{\n Int--\n }\n Int1--\n }\n println(integer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "91cb9f76fceb06de4db88e5343dc9e09", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val (n, k) = readInts()\n println(50);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2c9554553b1cf0bf940adbd1e24f6db4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package playground\n\nimport java.util.*\n\nfun main() {\n val input = Scanner(System.`in`)\n\n var n = input.nextInt()\n val k = input.nextInt()\n\n repeat(k) {\n if (n % 10 == 0) {\n n /= 10\n }\n else {\n n -= 1\n }\n }\n\n println(n)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "63a8766d550ba6669c1861042cf201be", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nobject Solution {\n @JvmStatic fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val str = sc.nextLine().split((\" \").toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()\n var number = Integer.parseInt(str[0])\n var k = Integer.parseInt(str[1])\n while (k > 0)\n {\n var rem = number % 10\n if (rem != 0)\n {\n number = number - 1\n }\n else\n {\n number = number / 10\n }\n k--\n }\n println(number)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "19411f1643aec127672309e2d15df47f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " import java.util.*\n import kotlin.sequences.*\n \n fun main() {\n val (orig, count) = readLine().split(\" \").map { it.toInt() }\n generateSequence(orig) {\n if (it % 10 == 0)\n it / 10\n else\n it - 1\n }.drop(count).first().apply(::println)\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8601fe842469b6582d5961b2216e1953", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n var integer:Int = reader.nextInt()\n var integer1:Int = reader.nextInt()\n while(integer1)\n {\n if(integer%10==0){integer/=10}\n else{\n integer--\n }\n integer1--\n }\n println(integer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a1fed39aca5d96acd8aec00eee6f9c89", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport java.io.*\n \nfun main() {\n val input = Scanner(System.`in`)\n val a = input.nextInt();\n var b = input.nextInt();\n repeat(b){\n if(a%10==0){\n a=a/10\n print(a)\n }\n else{\n a=a-1\n print(a)\n }\n }\n \n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0514d43952a151aec46855673afef946", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\n/**\n * Created: Saturday 5/25/2019, 1:16 PM Eastern Time\n *\n * @author Sergey Chuykov\n */\nobject CodeForceIncorrectMinus {\n\n fun execute(n: String, k: String): String {\n\n val na = n.toCharArray().mapTo(LinkedList()) { it.toString().toInt() }\n\n for (ki in 1..k.toInt()) {\n\n if (na.isEmpty()) {\n break\n }\n\n val last = na.last\n if (last == 0) {\n na.removeLast()\n } else {\n val lastIndex = na.lastIndex\n na[lastIndex] = last - 1\n }\n\n }\n\n return na.fold(StringBuilder()) { sb, i -> sb.append(i.toString()) }.toString()\n }\n\n @JvmStatic\n fun main(args: Array) {\n\n val scan = Scanner(System.`in`)\n\n val tokens = scan.nextLine().trim().split(' ')\n\n val n = tokens[0]\n val k = tokens[1]\n\n val result = execute(n, k)\n\n println(\"result=$result\")\n\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "85d495bd384279a90af8ebe6d86c6777", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar t = readInts()\n var n = readLine()!!.toInt()\n var d = readLine()\n var p = readLine()!!.split(' ').map(String::toInt)\n var m = -2\n for (i in 0..(n - 2)) {\n if (d!!.get(i) == 'R' && d!!.get(i + 1) == 'L' && (m == -2 || p.get(i + 1) - p.get(i) < m)) {\n m = (p.get(i + 1) - p.get(i))\n }\n }\n println(m / 2)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "04f871c6b1fbd117f08c882e583660a4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val (n, k) = readLine()!!.split(' ').toInt();\n println(n + k);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67fd6821ded2180105c376e47922a5c7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n var Input = (readLine() + \"\").split(\" \")\n var n = Integer.parseInt(Input[0])\n var b = Integer.parseInt(Input[1])\n\n while (b --) {\n if (n % 10 == 0) {\n n /= 10\n }\n else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "00d5d99aad990727dee67e3fd47c744d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.sys1yagi.codeforces.wrong_subtraction\n\nfun main() {\n val numbers = readLine()?.split(' ') ?: return\n if (numbers.size != 2) {\n return\n }\n var result = numbers[0].toInt()\n val count = numbers[1].toInt()\n for (i in 0.until(count)) {\n if (result % 10 == 0) {\n result /= 10\n } else {\n result--\n }\n }\n println(result)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "395c6ef6192f2623fc459407ac275d2f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package random.walk\n\nimport java.util.*\n\n/**\n * Created: Saturday 5/25/2019, 1:16 PM Eastern Time\n */\nobject CodeForceIncorrectMinus {\n\n fun execute(n: String, k: String): String {\n\n val na = n.toCharArray().mapTo(LinkedList()) { it.toString().toInt() }\n\n for (ki in 1..k.toInt()) {\n\n if (na.isEmpty()) {\n break\n }\n\n val last = na.last\n if (last == 0) {\n na.removeLast()\n } else {\n val lastIndex = na.lastIndex\n na[lastIndex] = last - 1\n }\n\n }\n\n return na.fold(StringBuilder()) { sb, i -> sb.append(i.toString()) }.toString()\n }\n\n @JvmStatic\n fun main(args: Array) {\n\n val scan = Scanner(System.`in`)\n\n val tokens = scan.nextLine().trim().split(' ')\n\n val n = tokens[0]\n val k = tokens[1]\n\n val result = execute(n, k)\n\n println(\"result=$result\")\n\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0d3a8d6b2a61ba489135a35497abe71f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main() {\n val input = Scanner(System.`in`)\n \n val line = input.nextLine()\n val values = line.split(' ')\n var n = values[0].toLong()\n val k = values[1].toInt()\n \n while (k > 0) {\n if (n % 10 != 0) {\n n--\n } else {\n n /= 10\n }\n k--\n }\n print(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8803080618f35b57d0f6612a6e31ef5c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (total, num) = readLine()!!.split().map { it.toInt() }\n println(\n generateSequence { if (total % 10 == 0) total / 10 else total -1 }.take(num)\n )\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5630754f46fb322a601159d68e376ab8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package drigor.multipart\n\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`, \"UTF-8\")\n var n = scanner.nextInt()\n var k = scanner.nextInt()\n\n while (k > 0) {\n val last = n % 10\n if (last == 0) {\n n /= 10\n k--\n } else {\n n -= last\n k -= last\n }\n }\n println(n)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fe26d748071b1e25dbb1d3013778bd87", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\nusing namespace std;\nint main() {fio;\nlong long n,k;cin>>n>>k;\n\t while(k--)\n\t{\n\t if((n%10)==0)n/=10;else n--; \n\t}cout<) {\n\t val n = readLine()!!.toInt()\n\t val k = readLine()!!.toInt()\n\t for (i in 1 until k) {\n\t \tval IntE:Int = n % 10\n\t \tif( IntE <= 0) n = n / 10\n\t else n = n-1\n\t }\n\t println(n)\n\t}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "28f91db55019d583049a625f2a97e783", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nvar arr = readLine()!!.split(' ')\nvar iter = arr[1].toInt()\nvar chislo = arr[0].toInt()\nwhile (iter > 0) {\n if (chislo % 10 != 0) chislo -= 1\n else chislo /= 10\n iter -= 1\n}\nprint(chislo)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e8ebd100c24bb65bf54d3563edecde73", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val data = readLine()?.split(' ')\n\n if (data?.size == 2) {\n var num = data[0].toInt()\n var minusTimes = data[1].toInt()\n\n while (minusTimes > 0) {\n if (num % 10 == 0)\n num /= 10\n else\n num--\n minusTimes--\n }\n print(num)\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "05d700a08103bb523e279f857973eaca", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun printResult() {\n val input = Scanner(System.`in`)\n fun wrongSub(n: Long, k: Int): Long {\n return when {\n k==0 -> n\n n % 10!=0L -> wrongSub(n - 1, k - 1)\n else -> wrongSub(n / 10, k - 1)\n }\n }\n\n println(\n wrongSub(\n input.nextLong(),\n input.nextInt()\n )\n )\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7b86bd888824a77a4286dffe9e9a5b9c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package KoKoKotlin\nimport java.util.ArrayList\nimport java.util.Comparator\nimport java.util.HashSet\nimport java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n let `in` = Scanner(System.`in`)\n let n = `in`.nextInt()\n let k = `in`.nextInt()\n for (i in 0 until k)\n {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8dd1d4bb4edb91ddc9f17df1e241a17d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package main\n\nfun main(args:Array){\n var retVar: Int = args[0].toInt()\n for(i in 1..args[1].toInt()){\n retVar = if(retVar % 10 == 0) retVar / 10 else retVar - 1\n }\n println(retVar)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a9144b09e1543d1e15188b0e8c0e7c39", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val parts = readLine()!!.split(' ')\nval n = parts.first().toMutableList()\nval k = parts.last().toInt()\n\nrepeat(k) {\n val lastChar = n.last()\n if (lastChar == '0') {\n n.removeAt(n.lastIndex)\n } else {\n n[n.lastIndex] = lastChar.toInt().dec().toChar()\n }\n}\n\nprintln(n.joinToString(separator = \"\"))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eb30d2802cd58b6fbe870be5ec2080d8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass Main {\n\n private fun solve() {\n var (n, k) = readInts();\n for (i in 1..k) {\n n = if (n % 10 == 0) n / 10 else n - 1;\n }\n out.print(n);\n }\n\n private fun readLn() = nextLine() // string line\n private fun readInt() = readLn().toInt() // single int\n private fun readLong() = readLn().toLong() // single long\n private fun readDouble() = readLn().toDouble() // single double\n private fun readStrings() = readLn().split(\" \") // list of strings\n private fun readInts() = readStrings().map { it.toInt() } // list of ints\n private fun readLongs() = readStrings().map { it.toLong() } // list of longs\n private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\n private var br: BufferedReader? = null\n\n @Throws(IOException::class)\n private fun nextLine(): String {\n return br!!.readLine()\n }\n\n @Throws(IOException::class)\n private fun run() {\n var input = System.`in`\n var output = System.out\n try {\n val f = File(\"input.txt\")\n if (f.exists() && f.canRead()) {\n input = FileInputStream(f)\n output = PrintStream(\"output.txt\")\n }\n } catch (ignored: Throwable) {\n }\n\n br = BufferedReader(InputStreamReader(input))\n out = PrintWriter(PrintWriter(output))\n solve()\n br!!.close()\n out.close()\n }\n\n class Node constructor(var key: Int) {\n var prior: Int = 0\n var cnt: Int = 0\n var pushing: Boolean = false\n var left: Node? = null\n var right: Node? = null\n\n init {\n this.prior = rnd.nextInt()\n right = null\n left = right\n this.cnt = 1\n this.pushing = false\n }\n }\n\n companion object {\n private var out: PrintWriter = PrintWriter(System.out);\n\n @Throws(IOException::class)\n @JvmStatic\n fun main(args: Array) {\n Main().run()\n }\n\n private val rnd = Random()\n\n fun getCnt(t: Node?): Int {\n return t?.cnt ?: 0\n }\n\n fun update(t: Node?) {\n if (t != null) {\n t.cnt = 1 + getCnt(t.left) + getCnt(t.right)\n }\n }\n\n fun push(t: Node?) {\n if (t != null && t.pushing) {\n\n t.pushing = false\n }\n }\n\n fun pushAll(t: Node?) {\n if (t != null) {\n push(t)\n if (t.left != null) {\n pushAll(t.left)\n }\n if (t.right != null) {\n pushAll(t.right)\n }\n }\n }\n\n // [0,K),[K,N)\n fun split(t: Node?, key: Int): Pair {\n if (t == null) return Pair(null, null)\n push(t)\n if (key > t.key) {\n val p = split(t.right, key)\n t.right = p.first\n update(t)\n return Pair(t, p.second)\n } else {\n val p = split(t.left, key)\n t.left = p.second\n update(t)\n return Pair(p.first, t)\n }\n }\n\n //SPLIT \u041f\u041e \u041d\u0415\u042f\u0412\u041d\u041e\u041c\u0423 \u041a\u041b\u042e\u0427\u0423\n // [0,K),[K,N)\n fun split(t: Node?, key: Int, add: Int = 0): Pair {\n if (t == null) return Pair(null, null);\n push(t)\n val curKey = add + getCnt(t.left)\n if (key > curKey) { //\u0438\u0434\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e\n val p = split(t.right, key, curKey + 1)\n t.right = p.first\n update(t)\n return Pair(t, p.second)\n } else { //\u0438\u0434\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e\n val p = split(t.left, key, add)\n t.left = p.second\n update(t)\n return Pair(p.first, t)\n }\n }\n\n //\u0412\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c\n fun merge(t1: Node?, t2: Node?): Node? {\n push(t1)\n push(t2)\n if (t1 == null) return t2\n if (t2 == null) return t1\n if (t1.prior > t2.prior) {\n t1.right = merge(t1.right, t2)\n update(t1)\n return t1\n } else {\n t2.left = merge(t1, t2.left)\n update(t2)\n return t2\n }\n }\n\n fun insert(t: Node?, newNode: Node): Node? {\n var t = t\n push(t)\n if (t == null) {\n t = newNode\n } else {\n val p = split(t, newNode.key, 0)\n t = merge(p.first, newNode)\n t = merge(t, p.second)\n }\n update(t)\n return t\n }\n\n //\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 2 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0435\u0440\u0435\u0432\u0430\n fun unite(t1: Node?, t2: Node?): Node? {\n var t1 = t1\n var t2 = t2\n if (t1 == null) return t2\n if (t2 == null) return t1\n push(t1)\n push(t2)\n if (t1.prior < t2.prior) {\n val c = t1\n t1 = t2\n t2 = c\n }\n val split1 = split(t2, t1.key)\n t1.left = unite(t1.left, split1.first)\n t1.right = unite(t1.right, split1.second)\n return t1\n }\n\n fun remove(t: Node?, key: Int): Node? {\n var t: Node? = t ?: return null\n if (t!!.key == key) {\n t = merge(t.left, t.right)\n } else {\n if (key < t.key) {\n t.left = remove(t.left, key)\n } else {\n t.right = remove(t.right, key)\n }\n }\n update(t)\n return t\n }\n\n fun find(t: Node?, key: Int): Node? {\n push(t)\n if (t == null) return null\n if (t.key == key) return t\n return if (t.key < key) {\n find(t.right, key)\n } else {\n find(t.left, key)\n }\n }\n\n fun get(t: Node?, key: Int, add: Int = 0): Node? {\n push(t)\n if (t == null) return null\n val curKey = add + getCnt(t.left)\n if (curKey == key) return t\n return if (key > curKey) { //\u0438\u0434\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e\n get(t.right, key, curKey + 1)\n } else {\n get(t.left, key, add)\n }\n }\n\n /**\n * \u0412\u044b\u0440\u0435\u0437\u0430\u0435\u0442 \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u043e\u0442 i \u0434\u043e j \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u044e k \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n * (\u043f\u0440\u0438 k = 0 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043d\u0430\u0447\u0430\u043b\u043e)\n *\n * @param t \u041a\u043e\u0440\u0435\u043d\u044c \u0434\u0435\u0440\u0435\u0432\u0430\n * @param i \u041d\u0430\u0447\u0430\u043b\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u0430 (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e)\n * @param j \u041a\u043e\u043d\u0435\u0446 \u043e\u0442\u0440\u0435\u0437\u043a\u0430 (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e)\n * @param k \u041f\u043e\u0437\u0438\u0446\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438\n * @return \u041d\u043e\u0432\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e\n */\n fun replaceSegment(t: Node, i: Int, j: Int, k: Int): Node? {\n //\u0412\u044b\u0440\u0435\u0437\u0430\u0435\u043c \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u043c\n val split1 = split(t, i, 0)\n val split2 = split(split1.second, j - i + 1, 0)\n val merge1 = merge(split1.first, split2.second)\n val removedSegment = split2.first\n\n // out.println(\"Array without removed:\" + getString(merge1));\n // out.println(\"Removed Segment:\" + getString(removedSegment));\n\n //\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\n val split3 = split(merge1, k, 0)\n val merge2 = merge(split3.first, removedSegment)\n\n return merge(merge2, split3.second)\n }\n\n fun getKeysString(t: Node?): StringBuilder {\n if (t == null) return StringBuilder()\n val ans = StringBuilder()\n if (t.left != null) ans.append(getKeysString(t.left))\n ans.append(t.key)\n ans.append(\" \")\n if (t.right != null) ans.append(getKeysString(t.right))\n return ans\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e4983b379288de17d0eaf1cada9d3913", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class WrongSubtraction {\n\n fun subtract(_number: Int, times: Int): Int {\n var number = _number\n\n for (i in 0 until times) {\n if (number % 10 == 0)\n number /= 10\n else\n number--\n }\n\n return number\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "06cef68d3fa8ae2ed0b7ea7c008558ea", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " * You can edit, run, and share this code. \n * play.kotlinlang.org \n */\nimport java.util.Scanner\nimport java.io.*\n \nfun main() {\n val input = Scanner(System.`in`)\n val a = input.nextInt();\n var b = input.nextInt();\n print(\"$a,$b\")\n \n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "10d5743876c8fe3da7cdc540138b96fb", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.*\nimport java.util.*\n\nobject Test1 {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var numberEnter = sc.nextLong()\n val subNum = sc.nextInt()\n for (counter in 1..subNum) {\n if (numberEnter % 10 != 0L)\n numberEnter--\n else\n numberEnter = numberEnter / 10\n }\n println(numberEnter)\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bdca5d18f448b0c47e76c9b05ff0d79e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\t val n = readLine()!!.toInt()\n\t val k = readLine()!!.toInt()\n\t for (i in 1 until k) {\n\t \tval IntE:Int = n % 10\n\t \tif( IntE == 0) n = n / 10\n\t else n = n-1\n\t }\n\t println(n)\n\t}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "92f84f3b46460c1141adc32710781388", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b) = readLine()!!.split(' ')\n var n = a.toInt(); k = b.toInt()\n for (i in 1..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "385798f290ff03c0496f3948d3c80fb5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// if the last digit of the number is non-zero, she decreases the number by one;\n// if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).\n\nfun main(args: Array) {\n println(readLine().split(\" \").map { it.toInt() }.let { dec(it[0], it[1]) })\n}\n\nfun dec(n: Int, k: Int): Int = if (k == 0) n else dec(if (n % 10 == 0) n / 10 else n - 1, k - 1)\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5f0c8e9fd4c4f9800c79825ea07ce95d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "kjn", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5ed7347f194b5a90fc4fda864ea3e0e5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, k) = readLine()!!.split(' ')\n n = n.toInt()\n k = k.toInt()\n\n while (k>0) {\n if (n%10 == 0) {\n n = (n/10).toInt()\n } \n else {\n n -= 1\n } \n k-- \n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e37d68faa572754f7ce2c29ae7eb4a14", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsKey(1)){\n\t\treturn \"HARD\"\n\t}\n\telse{\n\t\treturn \"EASY\"\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b41c80d2da1fb88b06e3b04850e0a692", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsKey(1)){\n\t\tprintln(\"HARD\")\n\t}\n\telse{\n\t\tprintln(\"EASY\")\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "87c69e74f8f93e5aa730f7d352fa347a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package foo\n\nfun main(args: Array) {\n var n = args[0].toInt()\n val k = args[1].toInt()\n\n for (i in 0 until k) {\n if (n.lastDigitIsZero()) {\n n /= 10\n } else {\n n -= 1\n }\n }\n\n print(n)\n}\n\nfun Int.lastDigitIsZero(): Boolean {\n return this.lastDigit() == 0\n}\n\nfun Int.lastDigit(): Int {\n return this % 10\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "107543d440765185753c756dd66cc301", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine!!.trim().split().map({y:String -> y.toULong()})\n println(subtractResult(x[0],x[1]))\n}\n\nfun subtractResult(value: ULong, subOp: ULong): ULong {\n if (subOp == 0UL) {\n return value\n } else {\n if ((value % 10UL) == 0UL) {\n return subtractResult((value/10UL),subOp-1UL)\n } else {\n return subtractResult((value-1UL),subOp-1UL)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a6b1a8e48c9e8656efaa882b28a462e7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/**\n * You can edit, run, and share this code. \n * play.kotlinlang.org \n */\nimport java.util.Scanner\nimport java.io.*\n\nfun main() {\n val input = Scanner(System.`in`)\n val a = input.nextInt();\n var b = input.nextInt();\n print(\"$a,$b)\n \n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "45e2d0e8a471d4ae48052299d0a9fb61", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\t val n = readLine()!!.toInt()\n\t val k = readLine()!!.toInt()\n\t for (i in 1 until k) {\n\t \tif( n % 10 == 0) n = n % 10\n\t else n = n-1\n\t }\n\t println(n)\n\t}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0c75aa72b2bb24d75fb46673b4b3538e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject WrongSubtraction {\n @JvmStatic\n fun main(args: Array) {\n var n: Int\n var k: Int\n val sc = Scanner(System.`in`)\n n = sc.nextInt()\n k = sc.nextInt()\n while (k > 0) {\n if (n % 10 != 0 && n % 10 <= k) {\n val tmp = n % 10\n n = n - tmp\n k -= tmp\n } else if (n % 10 != 0 && n % 10 > k) {\n n = n - k\n k = 0\n } else {\n while (n % 10 == 0) {\n n = n / 10\n k -= 1\n }\n }\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "75390118e6011bd1f9fa6cc8a0c93556", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package KoKoKotlin\nimport java.util.ArrayList\nimport java.util.Comparator\nimport java.util.HashSet\nimport java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n val k = `in`.nextInt()\n for (i in 0 until k)\n {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "049012ddba9a2e15a2a9111791812e81", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " package com.my.stuff\n\n class MyApp {\n companion object {\n @JvmStatic fun main(args: Array) {\n while (true) {\n print(\" Enter text: \")\n print(run(readLine()!!))\n }\n }\n fun parseInts(input: String) = input.split(\" \").map{it->it.toInt()}\n fun run(input: String):Int {\n val pars = parseInts(input)\n var numb = pars[0] // input validation goes somewhere else\n val iter = pars[1]\n for (i in 1..iter) numb = if (numb%10==0) numb/10 else numb-1\n return numb\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a9cb81295244c9defd04f42a614a90d4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n \nfun main(args: Array) {\n val inp = Scanner(System.`in`)\n var n = inp.nextInt()\n var k = inp.nextInt()\n while(k-->0){\n if(n%10)\n n--;\n else\n n = n/10;\n }\n println(n)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a39175e103fe0a7e8d4fcbdd0c2f9bba", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar (n, k) = readLine()!!.split(' ').map(String::toInt)\n\tprintln(a + b)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d7f2d87fa7f176a6806d1ca2cf29ea4c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n,k,i;\n cin>>n>>k;\n while(k--){\n if(n%10==0)\n n/=10;\n else\n n--;\n }\n cout<) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsKey(\"1\".toInt())){\n\t\tprintln(\"HARD\")\n\t}\n\telse{\n\t\tprintln(\"EASY\")\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6d542a822cad2be7d5f16855dd78250b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val line = readLine()\n val strs = line.split(' ')\n var num = strs[0].toInt()\n var count = strs[1].toInt()\n \n while(count != 0) {\n --count\n val lastDigit = num % 10\n if(lastDigit == 0) {\n num /= 10\n } else {\n --num\n }\n }\n \n return num\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e9381348b37cc07957e2c957ae53830d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.test\n\nfun main(args: Array) {\n val result = decrease(512,4)\n println(result)\n}\n\nfun decrease(number: Int, times: Int): Int {\n var numberStr = number.toString()\n var lastChar = numberStr.takeLast(1)\n var lastCharAsNumber = lastChar.toInt()\n var newNumber = number\n for(j in 1..times) {\n if(lastCharAsNumber!=0) {\n newNumber = newNumber-1;\n }\n else {\n newNumber = newNumber/10;\n }\n\n numberStr = newNumber.toString()\n lastChar = numberStr.takeLast(1)\n lastCharAsNumber = lastChar.toInt()\n }\n return newNumber\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "72af297149cdced1c85c47526c0de04a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "object Main {\n\n @JvmStatic\n fun main(args: Array) {\n val a = readLine()!!.split(\" \").map{ it.toInt() }.toMutableList()\n for (i in 1..a[1]) {\n if (a[0] % 10 == 0) {\n a[0] /= 10\n } else {\n a[0]--\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9381705d67e6003a8793e8e54cfa6afc", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,k;\n cin>>n>>k;\n for(int i=0;i){\n var (n , k) = readLine()!!.split(' ').map{it.toInt()}\n while(k-->0){\n if(n%10 == 0 ){\n n /=10\n }\n else n-=1\n }\n println(n)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7e70c7ba5859091cde3958b3bf4aa077", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = Long.valueOf(readLine())\n var k = Integer.valueOf(readLine())\n while(k>0)\n {\n var lastDigit = n % 10\n if(lastDigit > k)\n {\n n = n - k\n k = 0\n }\n else\n {\n n = (n / 10)*10\n k = k - lastDigit\n }\n if(n % 10 == 0 && k > 0)\n {\n k--;\n n = n / 10\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "03f56245ed3b2d1e27f5e4678dc5eb77", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n,k) = readLine()!!.split(' ').toInt()\n println(n+k)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d97cc50e78d77b1a464ec691e658eaeb", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package kotlinheroes.episode2.practice.a\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\n\ntypealias TanyaInt = Int\n\ndata class Operators(val minuend: Int, val subtrahend: Int)\n\nfun TanyaInt.decrement(): Int =\n if (this % 10 == 0) {\n this / 10\n } else {\n this - 1\n }\n\ninfix fun TanyaInt.subtract(subtrahend: Int): Int =\n (1..subtrahend).fold(this) { acc, _ ->\n acc.decrement()\n }\n\nfun List.minuend(): Int = this.first().toInt()\nfun List.subtrahend(): Int = this.last().toInt()\n\nfun readInput(): Operators {\n val inputStreamReader = InputStreamReader(System.`in`)\n val bufferedReader = BufferedReader(inputStreamReader)\n\n val inputLine = bufferedReader.readLine()\n val input = inputLine.split(\" \")\n\n return Operators(\n minuend = input.minuend(),\n subtrahend = input.subtrahend()\n )\n}\n\nfun main() {\n\n val (minuend, subtrahend) = readInput()\n\n val result = minuend subtract subtrahend\n\n print(result)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5ad6bc7e4645ea792d6b2dd516911211", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val line = readLine()\nval strs = line.split(' ')\nvar num = strs[0].toInt()\nvar count = strs[1].toInt()\n\nwhile(count != 0) {\n --count\n val lastDigit = num % 10\n if(lastDigit == 0) {\n num /= 10\n } else {\n --num\n }\n}\n\nreturn num", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "92d8fcc5336aad17e35dc1c04c5f6ab3", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(args: Array) {\n\n val reader = Scanner(System.`in`)\n\n var x:Int = reader.nextInt()\n var k:Int = reader.nextInt()\n\n for (var i in 0 until k)\n {\n var mod = x % 10\n if(mod == 0)\n {\n x/=10;\n }\n else x--\n }\n println(x)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca5fb18dff1861e307916c9e99e7d95e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example.kotlinheroes\n\nimport kotlin.math.max\n\nfun main(args: Array) {\n if(args.size != 2) return\n\n var number = args[0].toInt()\n val subtractions = args[1].toInt()\n\n for (i in 1..subtractions) {\n number = number.wrongSubtraction()\n }\n\n println(max(0, number))\n}\n\nprivate fun Int.wrongSubtraction(): Int =\n if (this % 10 == 0) this / 10 else this - 1\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9b97c649057422558ef87b3bbf839f67", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val line = readLine()\n val strs = line.split(' ')\n var num = strs[0]!!.toInt()\n var count = strs[1]!!.toInt()\n \n while(count != 0) {\n --count\n val lastDigit = num % 10\n if(lastDigit == 0) {\n num /= 10\n } else {\n --num\n }\n }\n \n println(num)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e2392d608b1f357d5bbd5a00524f7553", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " package com.my.stuff\n\n class programkt {\n companion object {\n @JvmStatic fun main(args: Array) {\n while (true) {\n print(\" Enter text: \")\n print(run(readLine()!!))\n }\n }\n fun parseInts(input: String) = input.split(\" \").map{it->it.toInt()}\n fun run(input: String):Int {\n val pars = parseInts(input)\n var numb = pars[0] // input validation goes somewhere else\n val iter = pars[1]\n for (i in 1..iter) numb = if (numb%10==0) numb/10 else numb-1\n return numb\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7094b596325f92dea523294cea53f7e6", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " \n fun main(args: Array) {\n var (a, j) = readLine()!!.split(' ').map(String::toInt)\n for (i in 1..j)\n {\n if (a%10 == 0)\n n /= 10\n else\n a--\n }\n \n println(a)\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7d35c0fb506d29c346b05c8f6ca9abb8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package drigor.multipart\n\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`, \"UTF-8\")\n var n = scanner.nextInt()\n var k = scanner.nextInt()\n\n while (k > 0) {\n val last = n % 10\n if (last == 0) {\n n /= 10\n k--\n } else {\n n -= last\n k -= last\n }\n }\n println(n)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6b147e6488fce3e79c54d5fa13a1facf", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//utilities\nfun readLn() = readLine()!! // string line\nfun readInt() = readLn().toInt() // single int\nfun readStrings() = readLn().split(\" \") // list of strings\nfun readInts() = readStrings().map { it.toInt() }\n\n//production code\nfun subtractOne(value: Int): Int {\n if (value.rem(10) == 0) {\n return value / 10\n } else {\n return value - 1\n }\n}\n\nval (n, k) = readInts()\n\nvar answer = n\nfor (idx in 1..k) {\n answer = subtractOne(answer)\n}\nprintln(answer) //50\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e2ec5b7d7572acc62c81c7d28fa0aca", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n,k,i;\n cin>>n>>k;\n while(k--){\n if(n%10==0)\n n/=10;\n else\n n--;\n }\n cout< 9) {\n n /= 10\n } else {\n n -= 1\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fa35f43fbcc8049f21a28f54255fa52e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b) = readLine()!!.split(' ')\n var (n = a.toInt(), k = b.toInt())\n for (i in 1..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dff04c93fd72c31f0698f973bf2315f2", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package heroes2.practice\n\nfun main() {\n var (n, k) = readLine()!!.split(\" \").map(String::toInt)\n\n for (i in 1..k) {\n n = substract(n)\n }\n\n println(n)\n}\n\nfun substract(n: Int): Int = if (n % 10 == 0) {\n n / 10\n} else {\n n - 1\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "694d50c55c8de5375042f18320e91313", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package foo\n\nimport java.util.*\n\nfun main() {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextInt()\n val k = scanner.nextInt()\n\n for (i in 0 until k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n -= 1\n }\n }\n\n print(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0a7f9c519b1c34396eb406cd28cf8d59", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package kotlinheroes\n\nfun Int.lastChar(): Int {\n return this.toString().last().toInt()-48\n}\n\nfun substruct(num: Int): Int {\n return when {\n num.lastChar() > 0 -> num-1\n else -> num/10\n }\n}\n\n\nfun substructMultiple(num: Int, div: Int) : Int {\n var current = num\n for (count in 1..div) {\n current = substruct(current)\n }\n\n return current\n}\n\n\nfun main() {\n val num = readLine()\n val div = readLine()\n\n require(num != null && div != null)\n\n print(substructMultiple(num.toInt(), div.toInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d3dc3ec9440f846eef8611baa4fdab95", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package app\n\nfun main(args: Array) {\n println(Decreasing().decrease(args[0].toInt(), args[1].toInt()))\n}\n\nclass Decreasing {\n\n fun decrease(source: Int, times: Int): Int {\n var result = source\n 1.rangeTo(times).map {\n result = decreaseWithRules(result)\n }\n return result\n }\n\n\n\n private fun decreaseWithRules(number: Int) =\n when(lastDigit(number)) {\n 0 -> number / 10\n else -> number - 1\n }\n\n private fun lastDigit(number: Int) = number % 10\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2c17b7c8b0c3750b70601b7094108f79", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint main(){\n\tint n,k;\n\tcin>>n>>k;\n\tfor(int i=1;i<=k;i++){\n\t\tif(n%10)n--;\n\t\telse n/=10;\n\t}\n\tcout<){\n val inputs = readLine().split(\" \");\n val number = Integer.parseInt(inputs[0]);\n val count = Integer.parseInt(inputs[1]);\n \n while(count > 0){\n if(number % 10 == 0){\n number = number / 10;\n } else {\n number = number - 1;\n }\n \n count = count - 1;\n }\n \n println(number);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e857e247c9c070562c05a2e4991be8bf", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example.kotlinheroes\n\nimport kotlin.math.max\n\nclass ProblemA {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n require(args.size == 2)\n\n var number = args[0].toInt()\n val subtractions = args[1].toInt()\n\n for (i in 1..subtractions) {\n number = number.wrongSubtraction()\n }\n\n println(max(0, number))\n }\n }\n}\n\nprivate fun Int.wrongSubtraction(): Int =\n if (this % 10 == 0) this / 10 else this - 1\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7d8eef2a8927d45b27fa05f8c5f1d745", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine()!!.toInt()\n\tvar A = readLine()!!.split(' ').map(String::toInt)\n\tif (A.containsKey(1) == true){\n\t\tprintln(\"HARD\")\n\t}\n\telse{\n\t\tprintln(\"EASY\")\n\t}\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6321afee9149cce5680b37a0909fe0d5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package practice2.a\n\nimport java.util.stream.IntStream\n\nclass WrongSubtraction {\n\n fun subtract(_number: Int, times: Int): Int {\n var number = _number\n\n for (i in 0 until times) {\n if (number % 10 == 0)\n number /= 10\n else\n number--\n }\n\n return number\n }\n\n}\n\nfun main(args: Array) {\n val wrongSubtraction = WrongSubtraction()\n println(wrongSubtraction.subtract(args[0].toInt(), args[1].toInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "66eebed04169ebe4dc883a0ec3ba9c73", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val n = nextInt()\n val k = nextInt()\n println(50);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "30a4a0d4590b4eb7b5a445a6ad6360e7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\n \nint main()\n \n{\n int i,n,k;\n \n \n scanf(\"%d \",&n);\n \n scanf(\"%d\",&k);\nfor(i=0;i BufferedReader(InputStreamReader(System.`in`), 32768)\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nvar output = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\nfun main(args: Array) {\n val start = System.currentTimeMillis()\n solve()\n\n output.close()\n input.close()\n\n if (!ONLINE_JUDGE) {\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fb4e9d6c8968caf28f64f8e9417ff1aa", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package test\n\nimport java.util.Scanner\n\nobject WrongSubtraction {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var k = sc.nextInt()\n while (k-- > 0) {\n if (n % 10 > 0)\n n--\n else\n n /= 10\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "94b1b948db4916cc5b23316b6766616d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " fun main(arguments: Array){\n val input : String? = readLine();\n val inputs = input.split(\" \");\n val number = Integer.parseInt(inputs[0]);\n val count = Integer.parseInt(inputs[1]);\n \n while(count > 0){\n if(number % 10 == 0){\n number = number / 10;\n } else {\n number = number - 1;\n }\n \n count = count - 1;\n }\n \n println(number);\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "99ce09acd1c77c28be0304f50e756f4c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n for (i in [1,k]) {\n \tif( n % 10 == 0) n = n / 10\n else n = n-1\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "57c245edadd0c5589ed5d19f6be230a9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n val input = Scanner(System.`in`)\n val n = input.nextLine()\n val k = input.nextLine()\n\n var nextNumberToSubstract = n.toInt()\n\n for (i in 1..k.toInt()) {\n nextNumberToSubstract = if (nextNumberToSubstract % 10 == 0) nextNumberToSubstract/10 else nextNumberToSubstract - 1\n println(nextNumberToSubstract)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "171aed1a02a0374093b123eacf939062", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun substract(numberToSubstract: Int, steps: Int): Int {\n var nextNumber = numberToSubstract\n\n for (i in 1..steps) {\n nextNumber = if (nextNumber % 10 == 0) nextNumber/10 else nextNumber-1\n }\n return nextNumber\n}\n \nfun main(args: Array) {\n var substracts = substracts(512, 4)\n println substracts\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "82f7fcbb202105af793c19234e0a682c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n for (i in 1 until k) {\n \tif( n % 10 != 0) n = n-1\n else n = n % 10\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2e075fdcdf23cb8369cfcf7653bba8d4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main( args: Array) {\n val scan = Scanner( System.`in`)\n \n var num:Int = scan.nextInt()\n var k:Int = scan.nextInt()\n\n println(\"Read val=$val k=$k)\n for( i in 1..k) {\n \tif ( num % 10 > 0 ) {\n num = num - 1\n } else {\n num = num / 10\n }\n }\n println(num)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f21235d520630bea90e3d50d97f75a23", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tlong long n;\n\tcin>>n;\n\tlong long k;\n\tcin>>k;\n\tfor(int i=0;i) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val solver = AWrongSubtraction()\n solver.solve(1, `in`, out)\n out.close()\n }\n\n internal class AWrongSubtraction {\n fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {\n var n = `in`.nextInt()\n var k = `in`.nextInt()\n\n while (k-- > 0) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n --n\n }\n }\n out.println(n)\n }\n\n }\n\n internal class InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: InputReader.SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1) {\n throw InputMismatchException()\n }\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0) {\n return -1\n }\n }\n return buf[curChar++].toInt()\n }\n\n fun nextInt(): Int {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt()) {\n throw InputMismatchException()\n }\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c) ?: isWhitespace(c)\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n\n }\n\n companion object {\n\n fun isWhitespace(c: Int): Boolean {\n return c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1\n }\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "303265092dc05ed75978f4276672a4a7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n var (n, k) = readLine()!!.split(' ')\n // n = n.toInt()\n // k = k.toInt()\n\n while (k>0) {\n if (n%10 == 0) {\n n = (n/10).toInt()\n } \n else {\n n -= 1\n } \n k-- \n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c6528df4a4429efb0dc4d8b8f9524769", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package app\n\nfun main(args: Array) {\n println(args)\n println(Decreasing().decrease(args[0].toInt(), args[1].toInt()))\n}\n\nclass Decreasing {\n\n fun decrease(source: Int, times: Int): Int {\n var result = source\n 1.rangeTo(times).map {\n result = decreaseWithRules(result)\n }\n return result\n }\n\n private fun decreaseWithRules(number: Int) =\n when(lastDigit(number)) {\n 0 -> number / 10\n else -> number - 1\n }\n\n private fun lastDigit(number: Int) = number % 10\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e30037f69a08be274f38cbbbaf9f4f7d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val readIn = readLine() ?: throw RuntimeException(\"Expected a line from readIn, got null\")\nval (n, k) = readIn.split(\" \").map { it.toInt() }\nvar tmp = n\nrepeat(k) {\n if (tmp % 10 == 0)\n tmp -= 1\n else\n tmp /= 10\n}\nreturn tmp", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4b19d7bc94c756b83840b8257f255108", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cp\n\nobject April1120 {\nfun april1120(){\n var(a,b) = readLine()!!.split(\" \").map{it.toInt()}\n for(i in 1..b){\n if(a % 10 == 0){\n a /= 10\n }else{\n a -= 1\n }\n }\n println(a)\n}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ae1534e815508be507b1938a286ef4f1", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n: Int, k: Int) = readLine()!!.split(' ')\n for (i in 0..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e8cbcaad97d671f4dca061f35cfa6099", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.test\n\nfun main() {\n val number = readLine()!!.toInt()\n val times = readLine()!!.toInt()\n val result = decrease(number, times)\n println(result)\n}\n\nfun decrease(number: Int, times: Int): Int {\n var lastChar = number.toString().takeLast(1)\n var lastCharAsNumber = lastChar.toInt()\n var newNumber = number\n\n for(j in 1..times) {\n if(lastCharAsNumber!=0) {\n newNumber= newNumber-1;\n }\n else {\n newNumber=newNumber/10;\n }\n\n lastChar = newNumber.toString().takeLast(1)\n lastCharAsNumber = lastChar.toInt()\n }\n return newNumber\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d73020334b480a7e1eb70a0113fd0cac", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nimport java.io.*;\nimport java.text.*;\npublic class Main{\n //SOLUTION BEGIN\n //Into the Hardware Mode\n void pre() throws Exception{}\n void solve(int TC)throws Exception{\n long n = nl(), k = nl();\n for(int i=0;i0){s/=10;ans++;}return ans;}\n long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}\n int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}\n void p(Object o){out.print(o);}\n void pn(Object o){out.println(o);}\n void pni(Object o){out.println(o);out.flush();}\n String n()throws Exception{return in.next();}\n String nln()throws Exception{return in.nextLine();}\n int ni()throws Exception{return Integer.parseInt(in.next());}\n long nl()throws Exception{return Long.parseLong(in.next());}\n double nd()throws Exception{return Double.parseDouble(in.next());}\n \n class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n \n public FastReader(String s) throws Exception{\n br = new BufferedReader(new FileReader(s));\n }\n \n String next() throws Exception{\n while (st == null || !st.hasMoreElements()){\n try{\n st = new StringTokenizer(br.readLine());\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n }\n return st.nextToken();\n }\n \n String nextLine() throws Exception{\n String str = \"\";\n try{ \n str = br.readLine();\n }catch (IOException e){\n throw new Exception(e.toString());\n } \n return str;\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ad1097db96913ac99f594a0aac3b7e68", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package foo\n\nimport java.util.*\n\nfun main() {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextInt()\n val k = scanner.nextInt()\n\n for (i in 0 until k) {\n if (n.lastDigitIsZero()) {\n n /= 10\n } else {\n n -= 1\n }\n }\n\n print(n)\n}\n\nprivate fun Int.lastDigitIsZero(): Boolean {\n return this.lastDigit() == 0\n}\n\nprivate fun Int.lastDigit(): Int {\n return this % 10\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "652b9ae357ca3f00982a8d9b446b9b09", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = Long.valueOf(readLine())\n val k = Integer.valueOf(readLine())\n while(k>0)\n {\n val lastDigit = n % 10\n if(lastDigit > k)\n {\n n = n - k\n k = 0\n }\n else\n {\n n = (n / 10)*10\n k = k - lastDigit\n }\n if(n % 10 == 0 && k > 0)\n {\n k--;\n n = n / 10\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "17d351ad8ec385ea4c8b2e75a0be7274", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.ArrayList\nimport java.util.Comparator\nimport java.util.HashSet\nimport java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n var `in` = Scanner(System.`in`)\n var n = `in`.nextInt()\n var k = `in`.nextInt()\n for (i in 0 until k)\n {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "62ca78ca70f7bcb6e5cbc5c68d94a652", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject WrongSubtraction {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var k = sc.nextInt()\n while (k-- > 0) {\n if (n % 10 > 0)\n n--\n else\n n /= 10\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0edcada36d0e57bb7714f54562d64927", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner \nfun main(args: Array) { \n val read = Scanner(System.`in`) \n \n var n = read.nextInt() \n var k = read.nextInt()\n for(var i=0;i) {\n var n: Int\n val k: Int\n val br = BufferedReader(InputStreamReader(System.`in`))\n val zer = StringTokenizer(br.readLine())\n n = Integer.parseInt(zer.nextToken())\n k = Integer.parseInt(zer.nextToken())\n for (i in 0 until k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c3a8da615d0aab85d05cfa0fa695435d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n, k: Int\n (n, k) = readLine()!!.split(' ')\n for (i in 0..k) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "30bd117e79d932bf385dca87eca61019", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n var (n, k) = readLine()!!.split(' ')\n n = n.toInt()\n k = k.toInt()\n\n while (k>0) {\n if (n%10 == 0) {\n n = (n/10).toInt()\n } \n else {\n n -= 1\n } \n k-- \n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b760910fd08e3a0480ff4bf29c6c10f3", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package KoKoKotlin\nimport java.util.ArrayList\nimport java.util.Comparator\nimport java.util.HashSet\nimport java.util.Scanner\nobject Main {\n @JvmStatic fun main(args:Array) {\n var `in` = Scanner(System.`in`)\n var n = `in`.nextInt()\n var k = `in`.nextInt()\n for (i in 0 until k)\n {\n if (n % 10 == 0)\n n /= 10\n else\n n--\n }\n println(n)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67d5a5e132aa9e267aa6ce6dd3ab41e7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codes\n\nimport java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(Scanner(System.`in`))\n}\n\nfun solve(scanner: Scanner) {\n val num = scanner.nextInt()\n\n if (num % 2 == 0) {\n print(0)\n } else {\n print(1)\n }\n}\n\nclass Scanner(`in`: InputStream) {\n val reader: BufferedReader = BufferedReader(InputStreamReader(`in`), 32768)\n var tokenizer: StringTokenizer = StringTokenizer(\"\")\n\n fun next(): String {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9de98ff1f855f3c224ec2008248c1316", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codes\n\nimport java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(Scanner(System.`in`))\n}\n\nfun solve(scanner: Scanner) {\n val num = scanner.nextInt()\n\n if (num % 2 == 0) {\n print(0)\n } else {\n print(1)\n }\n}\n\nclass Scanner(`in`: InputStream) {\n val reader: BufferedReader = BufferedReader(InputStreamReader(`in`), 32768)\n var tokenizer: StringTokenizer = StringTokenizer(\"\")\n\n fun next(): String {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "920a1d6628583ed99b3b16047d7e7e37", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n val x = BigInteger(\"2\").pow(n).minus(BigInteger(\"1\"))\n val b = BigInteger(readLine()!!.map { if (it == 'R') '1' else '0' }.joinToString(\"\"), 2)\n val ans = x.minus(b)\n println(ans.toString())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "382622d0b6040632e6db0ec87241536e", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.util.*\nimport kotlin.system.measureTimeMillis\n\nclass Solver : SolverBase() {\n\n fun solve() {\n for (i in 1..4) {\n val a = readIntArray(4)\n if (a[3] == 1 && a.sum() > 1) {\n print(\"YES\")\n return\n }\n }\n print(\"NO\")\n }\n\n}\n\nobject Algorithms {\n\n tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\n tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n\n fun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b\n fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\n\n}\n\nopen class SolverBase {\n private val bufferedReader: BufferedReader = System.`in`.bufferedReader()\n private var stringTokenizer: StringTokenizer = StringTokenizer(\"\")\n\n fun nextLine(): String = bufferedReader.readLine()\n fun next(): String {\n while (!stringTokenizer.hasMoreTokens())\n stringTokenizer = StringTokenizer(nextLine())\n return stringTokenizer.nextToken()\n }\n\n fun readInt(): Int = next().toInt()\n fun readLong(): Long = next().toLong()\n fun readDouble(): Double = next().toDouble()\n\n fun readIntArray(size: Int): IntArray = IntArray(size, { readInt() })\n fun readLongArray(size: Int): LongArray = LongArray(size, { readLong() })\n fun readStringArray(size: Int): Array = Array(size, { next() })\n inline fun readTArray(size: Int, convert: (Int, String) -> T): Array = Array(size, { convert(it, next()) })\n inline fun readTArray(size: Int, convert: (String) -> T): Array = Array(size, { convert(next()) })\n}\n\nfun main(args: Array) {\n val millis = measureTimeMillis(Solver()::solve)\n System.err.println(\"Time spent: $millis\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "745856b8e4791caa8db51ba50737a958", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun f(x: Int): Int {\n var y = x + 1\n while (y.rem(10) == 0) {\n y = y.div(10)\n }\n return y\n}\n\nfun reachableNums(n: Int): Int {\n val results: MutableSet = mutableSetOf()\n var m = n\n while (!results.contains(m)) {\n results.add(m)\n m = f(m)\n }\n// println(results)x\n return results.size\n}\nval a = readLine()!!.toInt()\nprintln(reachableNums(a))\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "17923db1e953a9002c92d921da495b5b", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun f(x:Int):Int\n{\n\tvar ss = x + 1\n\twhile(ss % 10 == 0)\n\t\tss /= 10\n\treturn ss\n}\n\nfun main(args:Array)\n{\n\tvar t = readLine()!!.toInt()\n\tvar hs = HashSet()\n\tvar cnt = 0\n\twhile(hs.add(x))\n\t{\n\t\tx = f(x)\n\t\tcnt++\n\t}\n\tprintln(cnt);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c1def6060e38332ed8cd2bb92dd71696", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package contest555\n\n/**\n * Reachable numbers\n *\n * http://codeforces.com/contest/1157/problem/A\n */\n\nfun reachableNumbers(n: Int, f: (Int) -> Int): List {\n tailrec fun reachableNumbersAcc(n: Int, f: (Int) -> Int, acc: List): List {\n if (f(n) in acc) return acc\n val m = f(n)\n return reachableNumbersAcc(m, f, acc + listOf(m))\n }\n return reachableNumbersAcc(n, f, listOf(n)).sorted()\n}\n\n/**\n * apply addition of 1 to n.\n * as long as the result is divisible to 10, keep dividing by 10\n */\nval f: (Int) -> Int = { n -> f(n) }\n\nfun f(n: Int): Int =\n removeTrailingZero(n + 1)\n\ntailrec fun removeTrailingZero(n: Int): Int =\n if ((n % 10) != 0) n else removeTrailingZero(n / 10)\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c5022d6e70817b35dec492cc78e76575", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashSet\n\npublic fun f(n : Int): Int {\n var x = n + 1\n while (x % 10 == 0) x /= 10\n return x\n}\npublic fun main() {\n var n = readLine()!!.toInt()\n val st = HashSet()\n while (st.add(n)) \n n = f(n)\n ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f8c800b6d5e60fcfe6c7fd8a27afabc3", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "/**\n * You can edit, run, and share this code. \n * play.kotlinlang.org \n */\nfun toDo(n:Int):Int{\n var value1 = n\n var s = n.toString()\n var counter = 1\n var arrayList = ArrayList()\n while(true){\n value1 = value1 + 1\n s = value1.toString()\n while (s[s.length-1]=='0') {\n \ts = s.substring(0,s.length-1)\n value1 = s.toInt()\n }\n if (value1 in arrayList){\n break\n }\n else{\n arrayList.add(value1)\n counter+=1\n }\n }\n return counter\n}\n\n\nfun main() {\n var n = readLine()!1.toInt()\n print(toDo(n))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a12279481ee121f220aa48376c73f138", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n \n var inputNum = readLine()!!.toInt()\n \n val resultList = ArrayList()\n resultList.add(inputNum)\n \n while(true) {\n inputNum += 1\n inputNum = reachableNumbers(inputNum)\n if (inputNum in resultList) break\n else resultList.add(inputNum)\n }\n \n println(resultList.size)\n}\n \nfun reachableNumbers(inputNumber: Int): Int {\n if (inputNumber % 10 == 0) reachableNumbers(inputNumber/10)\n else inputNumber\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "640927c8e3c48efeb41e5c5e51907e76", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\n\nfun f(x: Int): Int = generateSequence(x + 1) { y -> y / 10 }\n.dropWhile{ y -> y % 10 == 0 && y!= 0}\n.first()\n\nfun ff(x: Int) = generateSequence(x, ::f)\n\nfun r(x: Int) = ff(x)\n .takeWhile(HashSet()::add)\n .count()\n\nfun main() {\n \n println(r(readInt()));\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d12449b4cfd6c9aa81d987a725978fe4", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun f(x : int): int {\n var cur = x+1\n while (cur % 10 == 0)\n {cur/=10}\nreturn cur }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fe3bbfbc6470fd8bb7e114d7b85067e9", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun f(x: Int): Int {\n var y = x + 1\n while (y.rem(10) == 0) {\n y = y.div(10)\n }\n return y\n}\n\nfun reachableNums(n: Int): Int {\n val results: MutableSet = mutableSetOf()\n var m = n\n while (!results.contains(m)) {\n results.add(m)\n m = f(m)\n }\n// println(results)x\n return results.size\n}\nval a = input()\nprint(reachableNums(a))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6cf2c044515bfaa70370e5c9d5c37455", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun f(x: Int) {\n var cur = x + 1\n while(cur % 10 == 0) cur /= 10\n return cur\n}\n\nfun main() {\n var n = readLine()!!.toInt()\n val reached = HashSet()\n while (reached.add(n)) n = f(n)\n println(reached.size)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "df90cbf9b104830629e2a8efa0ee0192", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package com.rakeshpillai.kotlin\n\nfun main() {\n val num = readLine()!!.toInt()\n val output = getReachableNumberCount(num)\n println(output)\n}\n\nfun getReachableNumberCount(num: Int): Int {\n var count = 1\n var nextReachableNum = num\n\n while (nextReachableNum != 1) {\n nextReachableNum = nextReachableNumber(nextReachableNum)\n count++\n }\n\n return count\n}\n\nfun nextReachableNumber(num: Int): Int {\n var nextNum = num + 1\n while (nextNum % 10 == 0) {\n nextNum = nextNum / 10\n }\n\n return nextNum\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8eff5264b051dc865f1d5db5c81989f0", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (x) = readLine()!!.map(String::toInt)\n println(x)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eee63aa305fe4928032a26325f4fa7b6", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package contest555\n\nimport org.junit.Assert.assertEquals\nimport org.junit.Test\n\n/**\n * Reachable numbers\n *\n * http://codeforces.com/contest/1157/problem/A\n */\nclass A {\n\n fun reachableNumbers(n: Int, f: (Int) -> Int): List {\n tailrec fun reachableNumbersAcc(n: Int, f: (Int) -> Int, acc: List): List {\n if (f(n) in acc) return acc\n val m = f(n)\n return reachableNumbersAcc(m, f, acc + listOf(m))\n }\n return reachableNumbersAcc(n, f, listOf(n)).sorted()\n }\n\n /**\n * apply addition of 1 to n.\n * as long as the result is divisible to 10, keep dividing by 10\n */\n val f: (Int) -> Int = { n -> f(n) }\n\n fun f(n: Int): Int =\n removeTrailingZero(n + 1)\n\n tailrec fun removeTrailingZero(n: Int): Int =\n if ((n % 10) != 0) n else removeTrailingZero(n / 10)\n\n\n @Test\n fun removeTrailingZeroTest() {\n assertEquals(1, removeTrailingZero(1))\n assertEquals(1, removeTrailingZero(10))\n assertEquals(1, removeTrailingZero(100))\n }\n\n @Test\n fun addOneAndRemoveTrailingZerosTest() {\n assertEquals(1, f(99))\n assertEquals(101, f(100))\n }\n\n @Test\n fun reachableNumbersTest() {\n assertEquals(\n listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099),\n reachableNumbers(1098, f))\n }\n\n @Test\n fun reachableNumbersCountTest() {\n assertEquals(20, reachableNumbers(1098, f).size)\n assertEquals(19, reachableNumbers(10, f).size)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a5cf461715751889202e3299a4608e22", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": " 1 import java.util.Scanner\n 2 \n 3 fun main() {\n 4 val reader = Scanner(System.`in`)\n 5 var x =reader.nextInt()\n 6 var cnt = 0\n 7 while(x>9)\n 8 {\n 9 x+=1\n 10 while(x%10==0)\n 11 x/=10\n 12 cnt+=1 \n 13 } \n 14 println(cnt+9)\n 15 }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6f23d3e7361a19ecfb5c59b8e0a0e0d1", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "#include \n\nusing namespace std;\n\nint removeZeroes(int x) {\n return x % 10 == 0 ? removeZeroes(x / 10) : x;\n}\n\nint f(int x) {\n return removeZeroes(x + 1);\n}\n\nint main() {\n int n;\n while (scanf(\"%d\", &n) != EOF) {\n unordered_set reached;\n while (reached.insert(n).second) {\n n = f(n);\n }\n printf(\"%d\\n\", reached.size());\n }\n return 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "04c3734a08f6fef4ea678acb9da728d7", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\n fun main(args: Array) {\n \n var inputNum = readLine()!!.toInt()\n \n val resultSet = mutableSetOf(inputNum)\n \n while(true) {\n inputNum += 1\n inputNum = reachableNumbers(inputNum)\n resultSet.add(inputNum)\n if(inputNum == 1) break\n }\n \n return resultSet.size\n}\n \nfun reachableNumbers(inputNumber: Int): Int {\n if (inputNumber % 10 == 0) return reachableNumbers(inputNumber/10)\n else return inputNumber\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d7948d5a7a219dfc2f5eeea350dd5a96", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: String) {\n\n // converting the parameter to an int\n var inputNum = args[0].toInt()\n\n // declaring the result list\n val resultList = ArrayList()\n\n while(true) {\n inputNum += 1\n resultList.add(reachableNumbers(inputNum))\n if(inputNum == 1) break\n }\n\n val result = resultList.size\n\n println(result)\n}\n\nfun reachableNumbers(inputNumber: Int): Int {\n if (inputNumber % 10 == 0) reachableNumbers(inputNumber/10)\n else inputNumber\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3358a8473d9d42f93a2382d7f1882c74", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "tailrec fun removeZeroesRecursion(number: Int): Int =\n if (number % 10 == 0) removeZeroesRecursion(number / 10) else number\n\nfun removeZeroesByRecursion(x: Int) = removeZeroesRecursion(x + 1)\n\nfun removeZeroes(number: Int): Int {\n var cur = number + 1\n while (cur % 10 == 0) cur /= 10\n return cur\n}\n\nfun main() {\n var n = readLine()!!.toInt()\n var reached = HashSet()\n // while (reached.add(n)) n = removeZeroes(n)\n while (reached.add(n)) n = removeZeroesByRecursion(n)\n println(reached.size)\n}\n\n// val number = 3232199\n// println(removeZeroesByRecursion(number))\n// println(removeZeroes(number))\n\nmain()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d4d835a067afcf9eb37af29656df9930", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package com.dishan.example.solutions\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\n\nfun f(x: Int): Int {\n var cur = x + 1\n while ( cur % 10 == 0)\n cur /= 10\n return cur\n}\n\nfun reachableCount(n: Int): Int {\n var x = n\n val reached = HashSet()\n while (reached.add(x))\n x = f(x)\n return reached.size\n}\n\nfun main() {\n val n = readInt()\n val count = reachableCount(n)\n println(count)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "daa1c4397ff44d655e7ae19d5d83679a", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toInt() // read integer from the input\n val reached = HashSet() // a mutable hash set \n while (reached.add(n)) n = f(n) // iterate function f\n println(reached.size) // print answer to the output\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "58f3af2b3bf6b4cf5880e9bf351fb5a0", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n\tval `in` = InputReader(System.`in`)\n\tval out = PrintWriter(System.out)\n\tval n = `in`.nextInt()\n\tval m = `in`.nextInt()\n\tval k = `in`.nextInt()\n\tval a = LongArray(n)\n\tfor (i in 0 until n) {\n\t\ta[i] = `in`.nextInt().toLong()\n\t}\n\tval b = LongArray(m)\n\tfor (i in 0 until m) {\n\t\tb[i] = `in`.nextInt().toLong()\n\t}\n\tval c = Array(n) { IntArray(m) }\n\tfor (i in 0 until n) {\n\t\tfor (j in 0 until m) {\n\t\t\tc[i][j] = `in`.nextInt()\n\t\t}\n\t}\n\tc[0][0] += k\n\tval open = PriorityQueue(n * m, Collections.reverseOrder())\n\tvar sum: Long = 0\n\tvar row = 0\n\twhile (row < n && a[row] <= sum) {\n\t\t++row\n\t}\n\tvar col = 0\n\twhile (col < m && b[col] <= sum) {\n\t\tfor (i in 0 until row) {\n\t\t\topen.offer(c[i][col])\n\t\t}\n\t\t++col\n\t}\n\tvar ans = 0\n\twhile (row < n || col < m) {\n\t\tsum += open.poll()\n\t\t++ans\n\t\twhile (row < n && a[row] <= sum) {\n\t\t\tfor (i in 0 until col) {\n\t\t\t\topen.offer(c[row][i])\n\t\t\t}\n\t\t\t++row\n\t\t}\n\t\twhile (col < m && b[col] <= sum) {\n\t\t\tfor (i in 0 until row) {\n\t\t\t\topen.offer(c[i][col])\n\t\t\t}\n\t\t\t++col\n\t\t}\n\t}\n\tout.println(ans)\n\tout.close()\n}\n\ninternal class Pair(var a: Int, var b: Int) : Comparable {\n\toverride operator fun compareTo(oth: Pair): Int {\n\t\treturn if (a == oth.a) {\n\t\t\tb - oth.b\n\t\t} else a - oth.a\n\t}\n\n}\n\ninternal class InputReader(str: InputStream?) {\n\tvar reader: BufferedReader\n\tvar tokenizer: StringTokenizer? = null\n\toperator fun next(): String {\n\t\twhile (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n\t\t\ttokenizer = try {\n\t\t\t\tStringTokenizer(reader.readLine())\n\t\t\t} catch (e: IOException) {\n\t\t\t\tthrow RuntimeException(e)\n\t\t\t}\n\t\t}\n\t\treturn tokenizer!!.nextToken()\n\t}\n\n\tfun nextInt(): Int {\n\t\treturn next().toInt()\n\t}\n\n\tfun nextLong(): Long {\n\t\treturn next().toLong()\n\t}\n\n\tinit {\n\t\treader = BufferedReader(InputStreamReader(str), 1 shl 15)\n\t}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "76ca23b62f96748b5d35201c3157f00a", "src_uid": "309d0bc338fafcef050f336a7fa804c7", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "package kotlinheroes\n\nimport java.lang.Long.min\nimport java.util.*\nimport kotlin.math.max\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\nfun divRoundUp(num : Long, denom: Long) : Long {\n return (num + denom - 1)/denom\n}\n\nprivate fun myAssert(x: Boolean) {\n if (!x) {\n throw AssertionError()\n }\n}\n\nfun main() {\n val n = readInt()\n val m = readInt()\n val k = readInt()\n\n val a = LongArray(n)\n val b = LongArray(m)\n\n for (i in 0 until n) a[i] = readLong()\n for (i in 0 until m) b[i] = readLong()\n\n // sorted unlock thresholds\n val events = (a + b).distinct().sorted()\n\n // unlock threshold -> index of events\n val eventIndicesMap = hashMapOf()\n for (i in events.indices) {\n eventIndicesMap[events[i]] = i\n }\n\n // max points among characters unlocked at event i\n val mxPointsPerEvent = LongArray(events.size)\n\n for (i in 0 until n) {\n for (j in 0 until m) {\n val cij = readLong()\n val mxab = max(a[i], b[j])\n val eventInd = eventIndicesMap[mxab]\n mxPointsPerEvent[eventInd!!] = max(mxPointsPerEvent[eventInd], cij)\n }\n }\n\n myAssert(events[0] == 0L)\n\n val evaluate : (Int) -> Long = { guideIndex ->\n mxPointsPerEvent[guideIndex] = mxPointsPerEvent[guideIndex] + k\n\n var round = 0L\n var score = 0L\n var bestOption = mxPointsPerEvent[0]\n var nextEventIndex = 1\n\n while (nextEventIndex < mxPointsPerEvent.size) {\n val nextThreshold = events[nextEventIndex]\n val diff = nextThreshold - score\n if (diff > 0) {\n round += divRoundUp(diff, bestOption)\n score = divRoundUp(diff, bestOption) * bestOption\n }\n bestOption = max(bestOption, mxPointsPerEvent[nextEventIndex++])\n }\n mxPointsPerEvent[guideIndex] = mxPointsPerEvent[guideIndex] - k\n round\n }\n\n var mn = Long.MAX_VALUE\n for (i in mxPointsPerEvent.indices) {\n mn = min(mn, evaluate(i))\n }\n println(mn)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b3178c48a8478b8152f799d2ba915a80", "src_uid": "309d0bc338fafcef050f336a7fa804c7", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.util.Scanner\n\nfun sum(a: Int, b: Int): Int {\n return a + b\n}\n \nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val l = input.nextInt()\n val r = input.nextInt()\n val ans = 0\n val x: IntArray = intArrayOf(0, 326\n1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632 )\n for (i in x){\n \tif (i in l..r) { // equivalent of 1 <= i && i <= 10\n \t\tx[0]=1+x[0]\n\t}\n }\n println(x[0])\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ad43278260bc0035e6bbb8e840abac84", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\nclass Main {\n\n private fun readLn() = readLine()!!\n private fun readStrings() = readLn().split(\" \") // list of strings\n private fun readInts() = readStrings().map { it.toInt() }\n\n fun main(args: Array): Int {\n val yellow = readLn().toInt()\n val blue = readLn().toInt()\n val red = readLn().toInt()\n\n if (yellow < blue){\n if(blue < red){\n //yellow < blue < red\n println(yellow*3+3)\n }else{\n //yellow < blue >= red\n println(red*3-2)\n }\n }else{\n //blue <= yellow\n if(blue < red){\n //blue < red && blue < yellow\n println(blue*3)\n }else{\n //red <= blue && blue <= yellow\n println(red*3 - 2)\n }\n }\n\n return 0\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "930be73f65dfd320195376c3c42296ce", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val (y, b, r) = readInts()\n \n var a = 6\n \n y -= 1\n b -= 2\n r -= 3\n \n while (!(y == 0 || b == 0 || r == 0))\n {\n y--\n b--\n r--\n \n a += 3\n }\n \n println(a)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "89b5ee5c82212caababb29502d21185c", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nobject cf {\n @JvmStatic fun main(args:Array) {\n val s = Scanner(System.`in`)\n val a:Long\n val b:Long\n val i:Long\n val j:Long\n val c:Long\n a = s.nextLong()\n b = s.nextLong()\n c = s.nextLong()\n i = Math.min(b, Math.min(a + 1, c - 1))\n System.out.println(3 * x)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b15c50bb55e64be48942f33fbe75d900", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array ){\n val (x, y, z) = readLine()!!.split(' ').map(String::toInt)\n while (x > y - 1 || x > z - 2){\n x = x - 1\n }\n println(3 * x + 3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b9200a356c70c2732ca756c60670dfd3", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nval rgb = readLine()!!.split(' ').map(String::toInt).take(3)\n println(min(min(rgb[0], rgb[1] - 1), rgb[2] - 2))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a6e27a585f4ce38c3b9a6572d9066ad1", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(){\n var y : Int = 0\n var b : Int = 0\n var r : Int = 0\n\n (y b r) = readInts()\n\n var ans : Int = 0 \n\n if( y+1 <= b && y+2 <= r && 3*y+3 > ans ) ans = 3*y+3\n\n if( b-1 <= y && b+1 <= r && 3*b > ans ) ans = 3*b\n\n if( r-2 <= y && r-1 <= b && 3*r-3 > ans ) ans = 3*r-3\n\n println(\"$ans\") \n\n \n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0f1958ccdce21eda921fab5b087f15a6", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.File\nimport kotlin.test.todo\n\nclass MyReader(fileName: String) {\n val file = File(fileName)\n\n\n val contents : List?\n\n init {\n contents = try {\n file.readLines()\n } catch (e : Throwable) {\n null\n }\n }\n\n\n val line : String\n get() {\n return if (contents != null) {\n contents[pointer++]\n } else {\n readLine()!!\n }\n }\n\n var pointer = 0\n}\n\nvar reader : MyReader = MyReader(\"src/input.txt\")\n\nfun getLine() = reader.line\nfun readInt() = getLine().toInt()\nfun readInts() = getLine().split(\" \").map { it.toInt() }\n\nfun RE() : Nothing {\n throw RuntimeException()\n}\n\nfun main() {\n val (y, b, r) = readInts()\n val ans = when {\n b >= r-1 && y >= r-2 -> 3*r - 3\n r >= b + 1 && y >= b - 1 -> b*3\n b >= y + 1 && r >= y + 2 -> 3*y + 3\n else -> RE()\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7eb1fd175b0a5116201b181485f29ceb", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(){\n var y : Int = 0\n var b : Int = 0\n var r : Int = 0\n\n val(y, b, r) = readInts()\n\n var ans : Int = 0 \n\n if( y+1 <= b && y+2 <= r && 3*y+3 > ans ) ans = 3*y+3\n\n if( b-1 <= y && b+1 <= r && 3*b > ans ) ans = 3*b\n\n if( r-2 <= y && r-1 <= b && 3*r-3 > ans ) ans = 3*r-3\n\n println(\"$ans\") \n\n \n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f6a21c43f9be0f5fee6add82df8033ad", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nfun main()\n{\n var sc = Scanner(System.`in`)\n var y:Int = sc.nextInt()\n var b:Int = sc.nextInt()\n var r:Int = sc.nextInt()\n y += 2\n b += 1\n var lol:Int = maxOf(y: Int, b: Int, r:Int)\n if ( lol < 2)\n println(\"0\")\n else\n println(\"${lol*3 - 3} \")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9b4629bb8b9eb00ac5688e259387336b", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val nn = readLine()!!.split(\" \").map { it.toInt() }\n val mini = 999\n for (i in 0..2)\n {\n val m = nn[i]\n if (m - i < mini) mini = m - i\n }\n mini += 1\n println(mini * 3)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b01ed57c17d782b1888e674c1e61d864", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args: Array) {\n \tvar s = 6\n val input = Scanner(System.`in`)\n val A=input.nextInt()\n val B=input.nextInt()\n val B=input.nextInt()\n for (i in 2..999){\n if(I <= A && I + 1 <= B && I + 2 <= C)\n \ts = s+3\n else break\n }\n println(score)\n}\n/*import java.util.Scanner\n\nfun main(args: Array) {\n \tvar score = 6\n val input = Scanner(System.`in`)\n val a = input.nextInt()\n val b = input.nextInt()\n val c = input.nextInt()\n for (i in 2..999){\n if(i <= a && i+1 <= b && i+2 <= c)\n \tscore = score+3\n else break\n }\n println(score)\n}*/", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c2d1663223b0880b779bdef78ca02d29", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n var (y,b,r) = readInts();\n println(max(y,max(b-1,r-2))*3+3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "359b48bfa4a4b006e1bc5de304898961", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readLong() = readLn().toLong()\nfun readBigInt(radix: Int = 10) = readLn().toBigInteger(radix)\nfun readBigDecimal() = readLn().toBigDecimal()\nfun readLinesSeq(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.take(limit)\nfun readStrings(delim: Char = ' ') = readLn().split(delim)\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun readIntArray() = readInts().toIntArray()\nfun readLnIntArray(n: Int) = IntArray(n) { readInt() }\nfun readLongArray() = readLongs().toLongArray()\nfun readLnLongArray(n: Int) = LongArray(n) { readLong() } \n\n\nfun main(){\n\tval (x, y, z) = readLine()!!.split(\" \").map { it.toInt() }\n while (x > y - 1 || x > z - 2){\n x = x - 1\n }\n println(3 * x + 3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8480b4f18528ed3bebef54389dfe0f7c", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "data class Ornament(val ornament: Int, val offset: Int) {\n fun get() = ornament - offset\n}\n\n// red > blue > yellow exactly 1 is great christmas ornament\nclass ChristmasOrnament : ProblemSolver() {\n var totalRed: Int = 0\n var totalBlue: Int = 0\n var totalYellow: Int = 0\n\n override fun input() {\n val args = mutableListOf()\n val ornaments = readLine()!!.split(\" \").map { it.toInt() }\n totalYellow = ornaments[0]\n totalBlue = ornaments[1]\n totalRed = ornaments[2]\n args.add(Ornament(totalRed, 0))\n args.add(Ornament(totalRed, 1))\n args.add(Ornament(totalRed, 2))\n output(args)\n }\n\n override fun output(args: List) {\n val ornaments = args.map { it as Ornament }\n val christmasOrnaments = decrease(ornaments[0], ornaments[1], ornaments[2])\n val totalOrnaments = christmasOrnaments.reduce { acc, i -> acc + i }\n println(totalOrnaments)\n }\n\n private fun decrease(red: Ornament, blue: Ornament, yellow: Ornament): List {\n return if (blue.get() < totalBlue && yellow.get() < totalYellow) listOf(red.get(), blue.get(), yellow.get())\n else decrease(\n Ornament(red.get() - 1, offset = 0),\n Ornament(blue.get() - 1, offset = 1),\n Ornament(yellow.get() - 1, offset = 2)\n )\n }\n}\n\nfun main() {\n ChristmasOrnament().input()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3e7447c9dfe07715fe93a5da563585d5", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Math.min\nimport java.util.Scanner\n\nfun main()\n{\n val reader = Scanner(System.`in`)\n\n var y = reader.nextInt()\n var b = reader.nextInt()\n var r = reader.nextInt()\n var ans = min(y,b-1)\n ans = min(r-28 1,ans)\n ans = ans*3 + 3;8\n println(ans)\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e81e3aa3ebf529c7a3ebd8c0521f4223", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (y, b, r) = readLine()!!.split(' ').map(String::toInt)\n println(3 * min(min(b, y + 1), r - 1))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d81853e40ae724296fb8c91907ac8750", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (y, b, r) = readLine()!!.split(' ').map(String::toInt)\n println(\"${3 * minOf(y, minOf(b, r))}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "da0e002d5c6fa25d2214e323f3303ad8", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import javax.swing.text.MutableAttributeSet\n\nclass Main {\n\n companion object {\n @JvmStatic\n fun main(args: Array) {\n\n var inputList =readLine()!!.split(\" \").toList()\n\n var beginList = mutableListOf(1, 2, 3)\n while (true) {\n\n if (beginList.count { b -> inputList.count { b <= it.toString().toInt() } == 3} != 3)\n break\n else\n beginList.replaceAll { it + 1 }\n\n }\n// beginList.replaceAll { it - 1 }\n println(beginList.sum())\n\n\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "afe783ee8f15e3c239acf4a50f57efcc", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package higherOrderFunKotlin\n\nimport java.util.Scanner\n\n\n fun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n\n\n val y = sc.nextInt()\n val b = sc.nextInt() - 1\n val r = sc.nextInt() - 2\n\n val result = Math.min(Math.min(y, b), r) * 3 + 3\n\n println(result)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "58544b777f7366ddd5563ad4143083aa", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.minOf\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n var y:Int = scanner.nextInt()\n var b:Int = scanner.nextInt()\n var r:Int = scanner.nextInt()\n y-=1;b-=2;r-=3\n //var ans:Int=min(y,b);\n //ans=min(ans,r);\n //println(\"$y $b $r\")\n //println(ans);\n var ans=minOf(y,b,r);\n println(3*ans+6);\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "64d7ff35c8c849997137758010f5f5a4", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package koitlin_heroes_practice\n\nfun main() {\n val (y, b, r) = readLine()!!.split(\" \").map { it.toInt() }\n val min = minOf(y, b, r)\n if (min == r) {\n println(3 * r - 3)\n return\n }\n\n if (min == b) {\n println(3 * (b))\n return\n }\n\n if (min == y) {\n if (r > b) {\n println((3 * y) + 3)\n } else {\n println(y + 2 * r - 2)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "abb912df5cebc3851d4f6e3f78c7f44f", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val input = Scanner(System.`in`).nextLine().split(\" \").map { Integer.parseInt(it) }.toList()\n\n fun isValid(yellow: Int, blue: Int, red: Int): Boolean {\n return yellow <= input[0] && blue <= input[1] && red <= input[2] && yellow == blue + blue - red\n }\n\n var yellow = input[0]\n var blue = yellow + 1\n var red = blue + 1\n\n while (!isValid(yellow, blue, red)) {\n yellow--\n blue--\n red--\n }\n\n print(yellow + blue + red)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6b40ce22ff491e80214b7e904c0b8d68", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(){\n var y : Int\n var b : Int \n var r : Int \n\n (y, b, r) = readInts()\n\n var ans : Int = 0 \n\n if( y+1 <= b && y+2 <= r && 3*y+3 > ans ) ans = 3*y+3\n\n if( b-1 <= y && b+1 <= r && 3*b > ans ) ans = 3*b\n\n if( r-2 <= y && r-1 <= b && 3*r-3 > ans ) ans = 3*r-3\n\n println(\"$ans\") \n\n \n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "592bb0f62597e1e36473eaf441ab2de8", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun getMin(a, b, c)\n{\n if (a <= b && a <= c) return a\n if (b <= c) return b\n return c\n}\n\nfun main()\n{\n val nn = readLine()!!.split(\" \").map { it.toInt() }\n val mini = getMin(nn[0], nn[1] - 1, nn[2] - 2) + 1\n println(mini * 3)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3dbbe6d12dd61cde0dd275ac8a968e9e", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class ChristmasOrnament {\n var totalRed: Int = 0\n var totalBlue: Int = 0\n var totalYellow: Int = 0\n\n fun input() {\n val args = mutableListOf()\n val ornaments = readLine()!!.split(\" \").map { it.toInt() }\n totalYellow = ornaments[0]\n totalBlue = ornaments[1]\n totalRed = ornaments[2]\n args.add(Ornament(totalRed, 0))\n args.add(Ornament(totalRed, 1))\n args.add(Ornament(totalRed, 2))\n output(args)\n }\n\n fun output(args: List) {\n val ornaments = args.map { it as Ornament }\n val christmasOrnaments = decrease(ornaments[0], ornaments[1], ornaments[2])\n val totalOrnaments = christmasOrnaments.reduce { acc, i -> acc + i }\n println(totalOrnaments)\n }\n\n private fun decrease(red: Ornament, blue: Ornament, yellow: Ornament): List {\n return if (blue.get() < totalBlue && yellow.get() < totalYellow) listOf(red.get(), blue.get(), yellow.get())\n else decrease(\n Ornament(red.get() - 1, offset = 0),\n Ornament(blue.get() - 1, offset = 1),\n Ornament(yellow.get() - 1, offset = 2)\n )\n }\n}\n\nfun main() {\n ChristmasOrnament().input()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7014b050a5a3b98789c264e91e620a7b", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n var (y, b, r) = readInts()\n \n var a = 6\n \n y -= 1\n b -= 2\n r -= 3\n \n while (!(y == 0 || b == 0 || r == 0))\n {\n y--\n b--\n r--\n \n a += 3\n }\n \n println(a)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ba65550d87e0b227dcb61e99217149e3", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readLong() = readLn().toLong()\nfun readBigInt(radix: Int = 10) = readLn().toBigInteger(radix)\nfun readBigDecimal() = readLn().toBigDecimal()\nfun readLinesSeq(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.take(limit)\nfun readStrings(delim: Char = ' ') = readLn().split(delim)\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun readIntArray() = readInts().toIntArray()\nfun readLnIntArray(n: Int) = IntArray(n) { readInt() }\nfun readLongArray() = readLongs().toLongArray()\nfun readLnLongArray(n: Int) = LongArray(n) { readLong() } \n\n\nfun main(args: Array ){\n// val (x, y) = readLine()!!.split(' ').map(String::toInt)\n// val x = Scanner(System.`in`)\n// val y = Scanner(System.`in`)\n\tval (x, y, z) = readInts()\n while (x > y - 1 || x > z - 2){\n --x\n }\n println(3 * x + 3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b7caa55e714c93d9ef79281b2930534d", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n#define ll long long\n#define S second\n#define F first\n#define pii pair\n#define pb push_back\n#define pob pop_back\n\nusing namespace std;\n\n\nint main()\n{\n ios::sync_with_stdio(false), cin.tie(), cout.tie();\n\n int y, b, r;\n cin >> y >> b >> r;\n if(r > b && b > y)\n cout << y * 3 + 3;\n else if(r > b && b <= y)\n cout << b * 3;\n else if (r <= b && r <= y)\n cout << r * 3 - 3;\n else if(r <= b && r > y + 1)\n cout << y * 3 + 3;\n else if(r <= b && r == y + 1)\n cout << y - 1 + y + 1 + y;\n\n return 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2836e4257c20d80c9ef8935e2a012224", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.io.*\n\nfun main() {\n var temp = readLine()\n \n val tokens = temp.split(\" \")\n var list = mutableListOf()\n for (token in tokens) {\n list.add(token.toInt())\n }\n val min = list.min()\n var total = 0\n when {\n list[2] == min -> total = list[2] + (list[2]-1) + (list[2]-2)\n list[1] == min -> total = list[1] + (list[1]-1) + (list[1]+1)\n else -> total = list[0] + (list[0]+1) + (list[0]+2)\n }\n println(total)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "53e6ba8441b78337aedb94147db5d8a6", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example.circleprogressbar\n\nimport java.lang.Math.min\n\nfun main(args : Array) {\n val (y,b,r) = readInts()\n var c = min(min(y +2, b + 1), r)\n println(c*3-3)\n}\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0b6aeacb063766c24bfdf40a668a506b", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val s = readLine()\n val s2 = s.split(' ')\n var yellows = s2[0].toInt()\n var blues = s2[1].toInt()\n var reds = s2[2].toInt()\n\n if (yellows >= blues) {\n yellows -= (yellows - blues) + 1\n }\n if (blues != yellows + 1) {\n blues = yellows + 1\n }\n if (blues >= reds) {\n blues -= (blues - reds) + 1\n yellows -= (blues - reds) + 2\n }\n if (reds != blues + 1) {\n reds = blues + 1\n }\n print(yellows + blues + reds)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f90a5176761c1c57349e46fe8d0af6b6", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main( args : Array) {\n\n val str= readLine()!!\n val str = \"13 3 6\"\n val ar = str.split(\" \")\n val y = ar[0].toInt()\n val b = ar[1].toInt()\n val r = ar[2].toInt()\n val n = minOf(y + 1, b, r - 1)\n println(n*3)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a0e3624f4211852043fef5e1cc8113e3", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val br = Scanner(System.`in`)\n val a = br.nextInt()\n val b = br.nextInt()\n val c = br.nextInt()\n for (i in c downTo 3) {\n if (a >= i - 2 && b >= i - 1) {\n println(i + (i - 1) + (i - 2))\n break\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e5f501faddeaeb5c2649824c9bd7a746", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n//#include \n\n#define all(x) (x.begin(), x.end())\n#define sor(x) sort(all(x))\n#define rev(x) reverse(all(x))\n#define pb push_back\n#define pp pop_back\n#define sqr(x) (x) * (x)\n#define F first\n#define S second\n#define N 222222\n#define INF 1000000021\n#define MOD 1000000007\n#define Z size()\n#define I insert\n#define M(a, b) make_pair(a,b)\n#define T(a, b, c) make_pair(a, make_pair(b, c))\n#define forn(x) for (int i = 1; i <= n; i ++)\n\nusing namespace std;\n//using namespace __gnu_pbds;\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vll;\ntypedef set sl;\n//typedef tree, rb_tree_tag,tree_order_statistics_node_update> indexed_set;\n\n//int yil[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\nint main()\n{\n\tint a, b, c; \n\tcin >> a >> b >> c;\n\tcout << min(a, min(b - 1, c - 2)) * 3 + 3;\n\n\n\tgetchar();\n\tgetchar();\n\treturn 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d7bc893f435d1873a8726cb67ea66835", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.io.*\n\nfun main() {\n var temp = readLine()\n \n val tokens = temp!!.split(\" \")\n var min = \"\";\n if (tokens[0] <= tokens[1] && tokens[1] <= tokens[2]) {\n min = tokens[0]\n } else if (tokens[1] <= tokens[0] && tokens[0] <= tokens[2]) {\n min = tokens[1]\n } else {\n min = tokens[2]\n }\n \n \n /*\n var list = mutableListOf()\n for (token in tokens) {\n list.add(token.toInt())\n }\n val min = list.min()\n */\n var total = 0\n when {\n tokens[2] == min -> total = tokens[2].toInt() + (tokens[2].toInt()-1) + (tokens[2].toInt()-2)\n tokens[1] == min -> total = tokens[1].toInt() + (tokens[1].toInt()-1) + (tokens[1].toInt()+1)\n tokens[0] + 2 > tokens[2].toInt() -> total = (tokens[0].toInt()-1) + tokens[0].toInt() + (tokens[0].toInt()+1)\n else -> total = tokens[0].toInt() + (tokens[0].toInt()+1) + (tokens[0].toInt()+2)\n }\n println(total)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a3d095cb16cc96d6d6a69ac5cfdfcd19", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val reader = BufferedReader(InputStreamReader(System.`in`))\n val readString = reader.readLine().split(\" \")\n val y = readString[0].toInt()\n val b = readString[1].toInt()\n val r = readString[2].toInt()\n println(getMaxOrnaments(y, b, r))\n}\n\nfun getMaxOrnaments(y: Int, b: Int, r: Int): Int {\n val input = arrayOf(y, b - 1, r - 2)\n val x = input[input.indices.minBy { input[it] }!!]\n return 3 * x + 3\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8184a5bcbfcceb7d362f97e5d3d72e76", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(Scanner(System.`in`)) {\n val y = nextInt()\n val b = nextInt()\n val r = nextInt()\n println(getMaxOrnaments(y, b, r))\n}\n\nfun getMaxOrnaments(y: Int, b: Int, r: Int): Int {\n val input = arrayOf(y, b - 1, r - 2)\n val x = input[input.indices.minBy { input[it] }!!]\n return 3 * x + 3\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "660186b9e9d16aaecedbed30cfc604c0", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.io.*\n\nfun main() {\n var temp = readLine()\n \n val tokens = temp!!.split(\" \")\n var min = 0;\n if (tokens[0] <= tokens[1] && tokens[1] <= tokens[2]) {\n min = tokens[0].toInt()\n } else if (tokens[1] <= tokens[0] && tokens[0] <= tokens[2]) {\n min = tokens[1].toInt()\n } else {\n min = tokens[2].toInt()\n }\n \n \n /*\n var list = mutableListOf()\n for (token in tokens) {\n list.add(token.toInt())\n }\n val min = list.min()\n */\n var total = 0\n when {\n list[2] == min -> total = list[2] + (list[2]-1) + (list[2]-2)\n list[1] == min -> total = list[1] + (list[1]-1) + (list[1]+1)\n list[0] + 2 > list[2] -> total = (list[0]-1) + list[0] + (list[0]+1)\n else -> total = list[0] + (list[0]+1) + (list[0]+2)\n }\n println(total)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23486a6379dbf68f7435bb26dadb5aac", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val rgb = readLine()!!.split(' ').map(String::toInt).take(3)\nprintln(min(min(rgb[0], rgb[1] - 1), rgb[2] - 2))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6a923c6386291062756354867a2c4b56", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array ){\n val (x, y, z) = readLine()!!.split(' ').map(String::toInt)\n while (x > y - 1 || x > z - 2){\n x--\n }\n println(3 * x + 3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7848b83e0b33c3b2c6fc352030e5d931", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (y, b, r) = readLine()?.split(\" \").map { it.toInt() }\n\n val base = listOf(y - 2, b - 1, r).min()!!\n\n val result = base * 3 - 3\n \n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ae44bce0231fdcaebb53a21c191720fe", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n\n val (a,b,c) = readInts()\n println((6 + 3*minOf(a,b-1,c-2)))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8053ab77156451b16faf6aaf048a3a53", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val c = scanner.nextInt()\n\n val case1 = (a + b) * c\n val case6 = a * b + c\n\n val case2 = a + b + c\n val case3 = a * b * c\n\n val case4 = a * b + c\n val case5 = a * (b + c)\n\n val result = arrayOf(case1, case2, case3, case4, case5, case6)\n\n\n println(result.max())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "14d3cc561c8b9c11d642cf9f791caf5c", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(args: Array) {\n val n = args.component1().toInt()\n val p = args.component2().toInt()\n val k = args.component3().toInt()\n val items = mutableListOf()\n if (p - k > 1)\n items.add(\"<<\")\n val start = if (p - k > 0) p - k else 1\n val end = if (n - p > k) p + k else n\n for (i in start..end) {\n if (i == p)\n items.add(\"($i)\")\n else\n items.add(\"$i\")\n }\n if (n - p > k)\n items.add(\">>\")\n print(items.joinToString(separator = \" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "81c730b3fb2644740f5c13955c1386dd", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(args: Array) {\n println(\"ew\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b381adec29238c7756d2c84ab9f07514", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(arg: ArrayList) {\n val problem399 = Problem399()\n problem399.solve(arg)\n}\n\nopen class Problem399 {\n fun solve(arg: ArrayList) {\n val n = arg.component1().toInt()\n val p = arg.component2().toInt()\n val k = arg.component3().toInt()\n val items = mutableListOf()\n if (p - k > 1)\n items.add(\"<<\")\n val start = if (p - k > 0) p - k else 1\n val end = if (n - p > k) p + k else n\n for (i in start..end) {\n if (i == p)\n items.add(\"($i)\")\n else\n items.add(\"$i\")\n }\n if (n - p > k)\n items.add(\">>\")\n print(items.joinToString(separator = \" \"))\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f86b46fb6361f915f93ff385466478ab", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(args: Array) {\n val n = args[0].toInt()\n val p = args[1].toInt()\n val k = args[2].toInt()\n val items = mutableListOf()\n if (p - k > 1)\n items.add(\"<<\")\n val start = if (p - k > 0) p - k else 1\n val end = if (n - p > k) p + k else n\n for (i in start..end) {\n if (i == p)\n items.add(\"($i)\")\n else\n items.add(\"$i\")\n }\n if (n - p > k)\n items.add(\">>\")\n print(items.joinToString(separator = \" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "91b881faf9df8fe0828ef1c4085a4caa", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.stream.IntStream;\nimport java.io.PrintStream;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskA solver = new TaskA();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskA {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n String s = in.next().toLowerCase().replaceAll(\"[aoyeui]\", \"\");\n s.chars().forEach(c -> System.out.print(\".\" + (char) c));\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb181f1bd935fc8d0ec5c018b09b982e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine()!!.toLowerCase()\n println(x.replaceAll(\"[aoyeui]+\".toRegex(), \".\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "288d048100f5c2e6e062604da32dfff5", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main()\n val x = readLine()!!.toLowerCase()\n println(x.replaceAll(\"[aoyeui]+\".toRegex(), \".\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8695448fe7cd659c6add8f97384df0ff", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n val vowels = \"aAoOyYeEuUiI\"\n val str = readLine()!!\n var newStr = \"\"\n for (c: Char in str) {\n if (!(c in vowels)) {\n newStr += \".\" + c.toLowerCase()\n }\n }\n println(newStr)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "88673d585308888266539ae2140053bd", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "var x = readLine()\n x = x!!.toLowerCase()\n var a : String = \"\"\n for (c in x)\n {\n if (c!='o' && c!='i' && c!='u'&&c!='e'&&c!='y' && c!='a')\n {\n a+=\".$c\"\n }\n }\n println(a)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "153504346e7b7fb62ff77d229714b112", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main() {\n\n val x: Int = nextInt()\n if (x % 5 == 0) {\n \n println((x/5))\n } else {\n \n println((x/5)+1)\n }\n\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "489761a344ecb1dbf9bda680d1c799b0", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val In = BufferedReader(InputStreamReader(System.`in`))\n val name = In.readLine()!!.toSet()\n if(name.size % 2 ==0)\n println(\"IGNORE HIM!\")\n else\n println(\"CHAT WITH HER!\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3126f77e648bf8bc5470b34e7a142109", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val sol = Solution()\n if(sol.checkGender(readLine().toString())) {\n println(\"CHAT WITH HER!\")\n }\n else {\n println(\"IGNORE HIM!\")\n }\n}\n\nfun checkGender(hello:String):Boolean {\n val map: HashMap = HashMap()\n for(c in hello){\n if(!map.containsKey(c)){\n map[c] = 1\n }\n }\n return map.size%2==0\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9cd1eec8e8b7320ea62b3a3b7705d899", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val a = mutableListOf()\n while (scanner.hasNextInt()) {\n a.add(scanner.nextInt())\n }\n\n a.sortByDescending { it }\n val firstValue = a[0] + m\n for (i in 0 until m) {\n a.sortBy { it }\n a[0]++\n }\n print(a[0])\n print(\" \")\n print(firstValue)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b2481910d6b6d17b9601932843f09940", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var n = scan.nextLong()\n var m = scan.nextLong()\n var a = scan.nextLong()\n var b = scan.nextLong()\n if (n%m==0) print(0)\n else {\n val p=(n+m-1)/m\n if ((n-(m*(p-1)))*b<(m*p-n)*a) print ((n-(m*(p-1)))*b)\n else print ((m*p-n)*a)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "03a7c44a50d5ea202ccd7e54d3de9f05", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val reader = Scanner(System.`in`)\n var m = 0\n var n = 0\n var a = 0\n var b = 0\n\n reader.nextLine().split(\" \").forEachIndexed { index, s ->\n when(index){\n 0 -> n = s.toInt()\n 1 -> m = s.toInt()\n 2 -> a = s.toInt()\n 3 -> b = s.toInt()\n }\n }\n\n var build = 0\n var decrease = 0\n var buildDiff = 0\n var decreaseDiff = 0\n\n while ((n + buildDiff) % m != 0){\n buildDiff++\n build += a\n\n }\n\n while ((n - decreaseDiff) % m != 0){\n decreaseDiff++\n decrease += b\n }\n\n if (build < decrease){\n println(build)\n } else {\n println(decrease)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fdc003a6f586f93a2cf37d33f24a1ac8", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package cf435\n\nimport java.util.*\n\nfun main(args: Array) {\n val tokenizer = StringTokenizer(readLine())\n val n = tokenizer.nextToken().toInt()\n val x = tokenizer.nextToken().toInt()\n val arrayTokenizer = StringTokenizer(readLine())\n var steps = x\n generateSequence { arrayTokenizer.takeIf { it.hasMoreTokens() }?.nextToken()?.toInt() }.forEach {\n if (it < x) {\n steps--\n } else if (it == x) {\n steps++\n }\n }\n println(steps)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "311b48acf7e1328dac077427e7ca1a28", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n\tval input = readLine()!!.split(' ')\n\tval n = input[0]\n\tval k = input[1]\n\t\n\tvar r = 0\n\n\tfor (i in 0 until k) {\n\t\tval a = readLine()!!.toInt()\n\t\tif (a >= k) r++\n\t\telse break\n\t}\n\n\tprintln(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bd38340b0648e2bddac3ad368653e5ed", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package olimpiad.codeforce\n\n\nfun main(){\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n val arr = readLine()!!.split(' ').map { it.toInt() }\n\n if (arr[b]>0){\n var f = false\n for (i in b until a){\n if (arr[i]0){\n println(i+1)\n f=true\n break\n }\n }\n if (!f) println(0)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8423d8b90389372e162fdf75a2e9ecf4", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n\tval input = readLine()!!.split(' ')\n\tval a = readLine()!!.split(' ')\n\n\tval n = input[0].toInt()\n\tval k = input[1].toInt()\n\t\n\tvar r = 0\n\n\tfor (i in 0 until k) {\n\t\tif (a[i] >= k) r++\n\t\telse break\n\t}\n\n\tprintln(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "836221047924176fb1d5c25fbec880dd", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include \n\nusing namespace std;\n\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\ntypedef vector vvi;\ntypedef vector vvii;\ntypedef vector vs;\n\ntemplate\npair operator+(pair a, pair b) {\n return make_pair(a.first + b.first, a.second + b.second);\n}\n\ntemplate\npair operator-(pair a, pair b) {\n return make_pair(a.first - b.first, a.second - b.second);\n}\n\ntemplate\nostream& operator<<(ostream& out, pair p) {\n out << p.first << \" \" << p.second;\n return out;\n}\n\ntemplate\nistream& operator>>(istream& in, pair& p) {\n in >> p.first >> p.second;\n return in;\n}\n\ntemplate\nostream& operator<<(ostream& out, vector v) {\n for (auto a: v)\n out << a << \" \";\n\n return out;\n}\n\ntemplate\nistream& operator>>(istream& in, vector& v) {\n for (auto &a: v)\n in >> a;\n\n return in;\n}\n\ntemplate\nostream& operator<<(ostream& out, multiset S) {\n for (auto a: S)\n out << a << \" \";\n\n return out;\n}\n\ntemplate\nostream& operator<<(ostream& out, set S) {\n for (auto a: S)\n out << a << \" \";\n\n return out;\n}\n\ntemplate\nostream& operator<<(ostream& out, unordered_set S) {\n for (auto a: S)\n out << a << \" \";\n\n return out;\n}\n\ntemplate\nostream& operator<<(ostream& out, map& M) {\n for (auto m: M)\n out << \"[\" << m.first << \"]=\" << m.second << \" \" ; \n\n return out;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n int n, k;\n vi v;\n cin >> n >> k;\n v.resize(n);\n cin >> v;\n sort(v.begin(), v.end());\n int val = max(v[n-1-k], 1);\n auto first = lower_bound(v.begin(), v.end(), val);\n cout << distance(first, v.end()) << endl;\n return 0;\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8546c8e6a856bb14e77bfcde94e20a89", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val line = readLine() ?: \"\"\n val ints = line.split(\" \").map { it.toInt() }\n val k = ints[0]\n val n = ints[1]\n val scores = (readLine() ?: \"\").split(\" \").map { it.toInt() }.sorted().reversed()\n var last = 1\n var min = scores[n-last]\n while (min ==0 && n - last > 0){\n last+=1\n min = scores[n-last]\n }\n if(min!=0) println(scores.lastIndexOf(min)+1)\n else println(0)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e810558efb4574768d90224cd425423", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nclass Solution {\n fun main(args : Array){\n var input = Scanner(System.`in`)\n var n = input.nextInt()\n var k = input.nextInt()\n var sum =0;\n input.nextLine()\n var arrayInput = input.nextLine()\n var results = arrayInput.split(\" \").map { it.toInt() }.let { values ->\n sum =values.filter { it >= values[k-1] && values[k-1] > 0 }.size\n }\n System.out.println(\"${sum}\")\n\n }\n}\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "48605d640650a44f181211511fb3a8b1", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val (n, k) = r.readLine()!!.split(\" \").map { it.toInt() }\n val v2 = List(n) {\n val a = r.readInt()\n Pair(a, it)\n }.sortedBy { it.first }\n //val v1 = r.readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val v = v2.map { it.first }.toIntArray()\n (1..n - 1).forEach { v[it] += v[it - 1] }\n fun f(intArray: IntArray, x: Int): Int {\n var le = 0\n var ri = intArray.size\n while (le < ri) {\n val mi = le + (ri - le) / 2\n when {\n intArray[mi] <= x -> le = mi + 1\n intArray[mi] > x -> ri = mi\n }\n }\n return le - 1\n }\n\n val i = f(v, k)\n println(i + 1)\n println(v2.subList(0, i + 1).map { it.second+1 }.joinToString(\" \"))\n //val n = r.readLine()!!.toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f0a25bb859c52cedbcbd81e532652db8", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package A\n\nimport java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\n\nfun solve() {\n\n val n = nextInt()\n val k = nextInt()\n val array = nextArray(n)\n\n val ans = ArrayList()\n val s = mutableSetOf()\n var count = 0\n for ((index, a) in array.withIndex()) {\n if (!s.contains(a)) {\n s.add(a)\n ans.add(index+1)\n count++\n }\n if (count == k) {\n println(\"YES\")\n println(ans.joinToString(separator = \" \"))\n return\n }\n }\n\n println(\"NO\")\n}\n\n\n\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens()) {\n st = StringTokenizer(input.readLine() ?: return false)\n }\n return true\n}\n\nfun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextDouble() = next().toDouble()\n\nfun nextLine() = if (hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n, { nextInt() })\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nvar input = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`), 32768)\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nvar output = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\nfun main(args: Array) {\n val start = System.currentTimeMillis()\n solve()\n\n output.close()\n input.close()\n\n if (!ONLINE_JUDGE) {\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ebec236367d9702a8ab41d43aee39355", "src_uid": "5de6574d57ab04ca195143e08d28d0ad", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package ru.ak.tochki\n\nfun main(args: Array){\n\tval string1: String = readLine().toString()\n\tvar mnozh: List = readLine().toString().split(\" \").map{x -> x.toInt()}\n\tval N = string1.split(\" \")[0].toInt()\n\tval expD = string1.split(\" \")[1].toInt()\n\tmnozh = mnozh.sorted()\n\tval D = mnozh.last() - mnozh.first()\n\tif (D <= expD){\n\t\tprintln(0)\n\t}else{\n\t\t//println(\"Expected: $expD, real: $D\")\n\t\tvar realD: Int = 101\n\t\tvar minDropped = 101\n\t\tvar dropped = 101\n\t\tfor (i in 0..N-2){\n\t\t\tfor (j in i+1..N-1){\n\t\t\t\trealD = mnozh[j]-mnozh[i]\n\t\t\t\tdropped = N - (j - i + 1)\n\t\t\t\tif((realD <= expD) and (dropped <= minDropped)){\n\t\t\t\t\tminDropped = dropped\n\t\t\t\t\t//println(\"i: $i, j: $j, Distance: $realD, dropped: $dropped\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintln(minDropped)\t\t\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "57c9aee93b6f79c678287d1dd8ac06ff", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "package ru.ak.cf940A\n\nfun main(args: Array){\n\tval string1: String = readLine().toString()\n\tvar mnozh: List = readLine().toString().split(\" \").map{x -> x.toInt()}\n\tval N = string1.split(\" \")[0].toInt()\n\tval expD = string1.split(\" \")[1].toInt()\n\tmnozh = mnozh.sorted()\n\tval D = mnozh.last() - mnozh.first()\n\tif (D <= expD){\n\t\tprintln(0)\n\t}else{\n\t\t//println(\"Expected: $expD, real: $D\")\n\t\tvar solution = listOf()\n\t\tvar realD: Int = 101\n\t\tvar minDropped = 101\n\t\tvar dropped = 101\n\t\tfor (i in 0..N-2){\n\t\t\tfor (j in i+1..N-1){\n\t\t\t\trealD = mnozh[j]-mnozh[i]\n\t\t\t\tdropped = N - (j - i + 1)\n\t\t\t\tif((realD <= expD) and (dropped <= minDropped)){\n\t\t\t\t\tminDropped = dropped\n\t\t\t\t\t//println(\"i: $i, j: $j, Distance: $realD, dropped: $dropped\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintln(minDropped)\t\t\n\t}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f8985a0d844d16c73fbff2e5b2288636", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nclass Main {\n fun main(): String {\n val (x, y, z) = readLine()!!.split(' ').map { it.toInt() }\n val xy = x - y\n\n return when {\n z >= abs(xy) -> \"?\"\n xy < 0 -> \"-\"\n xy > 0 ->\"+\"\n else -> \"0\"\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1fa4e710c07648d2a0d30e0e32f88323", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var ligne = readLine()!!.toString().split(\" \")\n var x = Integer.parseInt(ligne.elementAt(0))\n var y = Integer.parseInt(ligne.elementAt(1))\n var z = Integer.parseInt(ligne.elementAt(2))\n var res =\"\"\n\n if( x > y && abs(x-y) > z) res = \"+\"\n if( x < y && abs(x-y) > z ) res= \"-\"\n if( x > y && abs(x-y) <= z) res = \"?\"\n if( x < y && abs(x-y) <= z ) res= \"?\"\n if( x==y && z==0) res=\"0\"\n if( x==y && z!=0) res=\"?\"\n println(\"$res\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "13dbe51dbf1b787bda3fa908dcd53cfb", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nimport com.sun.org.apache.xpath.internal.operations.Bool\nimport dfs\nimport dfs1\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.max\nimport kotlin.math.min\nimport java.io.IOException\nimport jdk.nashorn.internal.runtime.ScriptingFunctions.readLine\nimport java.util.StringTokenizer\nimport java.io.InputStreamReader\nimport java.io.BufferedReader\nimport java.io.InputStream\nimport kotlin.math.abs\n\nfun main(args: Array) {\n Thread { solve() }.start()\n}\n\nfun solve() {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n var k1 = -2\n var k2 = -1\n val arr = IntArray(n / 2) { scanner.nextInt() - 1 }.sorted()\n print(min(arr.sumBy { k1 += 2; abs(it - k1) }, arr.sumBy { k2 += 2; abs(it - k2) }))\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\n//class Pair(val a: Int, val b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return a - other.a\n//", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e55d3c71e2255cac6a88a6fcabc6f37f", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package greedy\n\n// https://codeforces.com/problemset/problem/996/A\n\nfun bills(n: Int) : Int {\n var remainder = n\n var bills = 0\n while (remainder > 0) {\n if (remainder >= 100) {\n remainder -= 100\n bills++\n } else if (remainder >= 20) {\n remainder -= 20\n bills++\n } else if (remainder >= 10) {\n remainder -= 10\n bills++\n } else if (remainder >= 5) {\n remainder -= 5\n bills++\n } else if (remainder >= 1) {\n remainder -= 1\n bills++\n }\n }\n return bills\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "976dee6c4c6b2a68de373f776d8bade9", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package problem996\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n println(numOfPapers(n))\n}\n\nfun numOfPapers(n: Int): Int {\n var papers = 0\n var remain = n\n val nominals = intArrayOf(100, 20, 10, 5 , 1)\n for (nominal in nominals) {\n papers += remain / nominal\n remain %= nominal\n }\n return papers\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8ecaa3d2708e5e603482ea2e1905f2f3", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package greedy\n\n// https://codeforces.com/problemset/problem/996/A\n\nfun bills(n: Int) : Int {\n var remainder = n\n var bills = 0\n while (remainder > 0) {\n if (remainder >= 100) {\n remainder -= 100\n bills++\n } else if (remainder >= 20) {\n remainder -= 20\n bills++\n } else if (remainder >= 10) {\n remainder -= 10\n bills++\n } else if (remainder >= 5) {\n remainder -= 5\n bills++\n } else if (remainder >= 1) {\n remainder -= 1\n bills++\n }\n }\n return bills\n}\n\nfun main(args: Array) {\n val amount = readLine()!!.toInt()\n println(bills(amount))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1051768792e66010827ff094df428231", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.nio.charset.IllegalCharsetNameException;\nimport java.util.*;\n\npublic class Main {\n\n\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static PrintWriter out = new PrintWriter(System.out);\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) {\n st = new StringTokenizer(br.readLine());\n }\n return st.nextToken();\n }\n\n static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n static void solve() throws IOException {\n int n = nextInt(), m = nextInt(), k = nextInt();\n int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n Arrays.sort(a);\n long pr[] = new long[n + 1];\n for (int i= 0; i < n; i++) pr[i + 1] = pr[i] + a[i];\n long ans = pr[n];\n for (int i = 0; i + m - 1 < n; i++) {\n int l = i, r = i + m - 1;\n int mid = (l + r) / 2;\n long sum = (mid - l) * (long) a[mid] - (pr[mid] - pr[l]);\n if (sum <= k) {\n sum += (pr[r + 1] - pr[mid]) - (r + 1 - mid) * (long) a[mid];\n ans = Math.min(ans, sum);\n } else {\n int vl = l, vr = r;\n while (vl < vr - 1) {\n int vm = (vl + vr) / 2;\n long sm = (vm + 1 - l) * (long) a[vm] - (pr[vm + 1] - pr[l]);\n if (sm <= k) {\n vl = vm;\n } else {\n vr = vm;\n }\n }\n long ret = (vl + 1 - l) * (long) a[vl] - (pr[vl + 1] - pr[l]);\n long val = a[vl];\n val += (k - ret) / (vl - l + 1);\n ret = (vl - l + 1) * val - (pr[vl + 1] - pr[l]);\n ret += (pr[r + 1] - pr[vl + 1]) - (r + 1 - (vl + 1)) * val;\n ans = Math.min(ans, ret);\n }\n }\n out.println(ans);\n }\n\n public static void main(String[] args) throws IOException {\n solve();\n out.close();\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a3e70b5ac29918626e3ea9d691cd2fbd", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport java.util.Arrays.*\nimport kotlin.Comparator\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\nimport kotlin.math.*\n\nfun read() = readLine()!!\nfun getStr() = read()\nfun getInt() = read().toInt()\nfun getInts() = read().splitToIntArray()\nfun yes() = print(\"YES\\n\")\nfun no() = print(\"NO\\n\")\n\nfun main() {\n val (n, m, k) = getInts()\n var a = getInts().toMutableList()\n a.sort()\n var b = Array(n + 1) {0L}\n for (i in 1..n) {\n b[i] = b[i - 1] + a[i - 1]\n }\n var aa: Long = 1000L * 1000 * 1000 * 1000 * 1000 * 1000 * 8\n for (start in 0 until n - m + 1) {\n var l = a[start]\n var r = a[start + (m - 1) / 2] + 1\n var mid = 0\n while (r - l > 1) {\n mid = (r + l) / 2\n if (can(mid.toLong(), a, b, start, k, m)) {\n l = mid\n } else {\n r = mid\n }\n }\n aa = min(aa, ans(l.toLong(), a, b, start, k, m))\n }\n println(aa)\n}\n\nfun ans(x: Long, a: IntArray, b: Array, start: Int, k: Int, m: Int): Long {\n var i = a.binarySearch(x.toInt(), start)\n if (i < 0) {\n i = -i - 1\n }\n val have = b[i] - b[start]\n val need: Long = x * (i - start) - have\n return need + (b[start + m] - b[i]) - x * (start + m - i)\n}\n\nfun can(x: Long, a: IntArray, b: Array, start: Int, k: Int, m: Int): Boolean {\n var i = a.binarySearch(x.toInt(), start)\n if (i < 0) {\n i = -i - 1\n }\n val have = b[i] - b[start]\n val need = x * (i - start) - have\n return need <= k\n}\n\n\nprivate fun dfs(x: Int, g: MutableList>, ans: MutableList>, used: MutableList, p: MutableList): Int {\n while(g[x].isNotEmpty()) {\n used[x] = true\n val to = g[x].first()\n if (used[to]) {\n ans.add(ArrayList())\n ans[ans.size - 1].add(to)\n ans[ans.size - 1].add(x)\n g[x].remove(to)\n g[to].remove(x)\n used[x] = false\n return to\n } else {\n g[x].remove(to)\n g[to].remove(x)\n val ret = dfs(to, g, ans, used, p)\n used[x] = false\n if (ret < 0) {\n return ret - 1\n }\n ans[ans.size - 1].add(x)\n used[x] = false\n if (ret != x)\n return ret\n }\n }\n used[x] = false\n return -1\n}\n\nprivate fun String.splitToIntArray(): IntArray {\n val n = length\n if (n == 0) return IntArray(0) // EMPTY\n var res = IntArray(4)\n var m = 0\n var i = 0\n while (true) {\n var cur = 0\n var neg = false\n var c = get(i) // expecting number, IOOB if there is no number\n if (c == '-') {\n neg = true\n i++\n c = get(i) // expecting number, IOOB if there is no number\n }\n while (true) {\n val d = c.toInt() - '0'.toInt()\n require(d in 0..9) { \"Unexpected character '$c' at $i\" }\n require(cur >= Integer.MIN_VALUE / 10) { \"Overflow at $i\" }\n cur = cur * 10 - d\n require(cur <= 0) { \"Overflow at $i\" }\n i++\n if (i >= n) break\n c = get(i)\n if (c == ' ') break\n }\n if (m >= res.size) res = res.copyOf(res.size * 2)\n res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { \"Overflow at $i\" } }\n if (i >= n) break\n i++\n }\n if (m < res.size) res = res.copyOf(m)\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6cd43640d665a00d23a8605b70e85cb5", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Comparator\nimport java.util.Scanner\n\n fun main(args:Array) {\n // TODO Auto-generated method stub\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n val m = `in`.nextInt()\n val k = `in`.nextLong()\n val v = ArrayList()\n val pr = ArrayList()\n for (i in 0 until n)\n {\n val x = `in`.nextInt()\n v.add(x)\n }\n v.sort(object:Comparator {\n public override fun compare(a:Int, b:Int):Int {\n if (a < b) return -1\n if (a > b) return 1\n return 0\n }\n })\n var sm = 0.toLong()\n for (i in 0 until n)\n {\n sm += v.get(i).toLong()\n pr.add(sm)\n }\n var rez = 1e18.toLong()\n var it = 0\n var S:Long = 0\n var cnt:Long = 0\n for (st in 0 until n - m + 1)\n {\n var all = pr.get(st + m - 1)\n if (st != 0) all -= pr.get(st - 1)\n while (2 * cnt < m && it < n && v.get(it) * (cnt) - S <= k)\n {\n S += v.get(it).toLong()\n cnt++\n it++\n }\n var up:Long = 0\n if (2 * cnt < m)\n {\n up = (k - (v.get(it - 1) * cnt - S)) / cnt\n }\n val meet = Math.min(v.get(it - 1) + up, v.get(st + m / 2).toLong())\n rez = Math.min(rez, meet * cnt - S + (all - S) - (meet) * (m - cnt))\n S -= v.get(st).toLong()\n cnt--\n }\n println(rez)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1b4033aefdf9a6a66cb150148b934bae", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.lang.StringBuilder\nimport java.util.*\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val (n, m, k) = readInts()\n if(m == 1) {\n println(\"0\")\n return;\n }\n var A = readLongs().sorted().toLongArray()\n var Pref = Array(A.size+1){0}\n for(x in 1..n) {\n Pref[x] = Pref[x-1]+A[x-1]\n //println(A[x-1])\n }\n var sum: Long = 0\n for(x in 0..m-1) {\n sum += A[x]\n }\n var lft = 0;\n var rgt = m;\n var ans: Long = Long.MAX_VALUE\n for(posun in 0..n-m) {\n if(posun > 0) {\n sum += A[m+posun-1]\n sum -= A[posun-1]\n lft++\n rgt++\n }\n var l1 = lft\n var r1 = rgt\n while(l1+1 < r1) {\n var mid = (l1+r1)/2\n if(A[mid]*(mid-lft)-(Pref[mid]-Pref[lft]) <= k) {\n l1 = mid;\n } else {\n r1 = mid;\n }\n }\n //println(\"start: $lft konec $rgt, max muzu vzit pozici $l1\")\n var center = (lft+rgt+1)/2\n if(l1 < center) {\n var zvetseni = A[l1]*(l1-lft)-(Pref[l1]-Pref[lft]);\n var zmenseni = (Pref[rgt]-Pref[l1])-A[l1]*(rgt-l1);\n var rezerva1: Long = k-zvetseni;\n var needForOne: Long = (l1-lft.toLong())+1;\n var enlargements: Long = rezerva1/needForOne\n if(A[l1]+enlargements >= A[l1+1]) {\n throw Exception(\"WTF\");\n }\n var cans = zvetseni+zmenseni\n ans = Math.min(ans, cans);\n cans -= enlargements*needForOne\n cans -= enlargements*(m-needForOne)\n ans = Math.min(ans, cans);\n if(cans == 99442292919397) {\n println(\"L1: center == $center, l1 = $l1, zvetseni = $zvetseni, zmenseni = $zmenseni, rezerva1 = $rezerva1, lft=$lft, needForOne=$needForOne\")\n println(\"L1: A[$l1] = ${A[l1]}, A[${l1+1}] = ${A[$l1+1]}, enlargements = $enlargements\")\n }\n } else {\n var zvetseni = A[center]*(center-lft)-(Pref[center]-Pref[lft]);\n var zmenseni = (Pref[rgt]-Pref[center])-A[center]*(rgt-center);\n //println(\"$zvetseni $zmenseni\")\n ans = Math.min(ans, zvetseni+zmenseni);\n if(zvetseni+zmenseni == 99442292919397) {\n println(\"L1: center == $center\")\n }\n }\n }\n\n println(Math.max(ans, 0))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "14174f4c4555d82af6e41cb4557ae6ab", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.test.assertTrue\n\nfun lowerBound(x: Int, a: IntArray): Int {\n var left = 0\n var right = a.size\n while (left + 1 < right) {\n val ave = (left + right) / 2\n if (a[ave] < x) {\n left = ave\n } else {\n right = ave\n }\n }\n return right\n}\n\nfun main() {\n val (n, m, k) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n a.sort()\n val b = LongArray(a.size + 1) { 0 }\n for (i in a.indices) {\n b[i + 1] = b[i] + a[i]\n }\n// println(a.toList())\n var res = Long.MAX_VALUE\n for (i in 0..(n - m)) {\n var left = a[i]\n var right = a[i + m - 1] + 1\n val t = a[i + m / 2]\n// println(\"t = $t\")\n while (left + 1 < right) {\n val ave = (left + right) / 2\n val j = Math.max(Math.min(lowerBound(ave, a), i + m - 1), i)\n assertTrue(a[j] >= ave)\n val s = ave.toLong() * (j - i) - (b[j] - b[i])\n// println(\"ave = $ave s = $s j = $j\")\n// println(\"b[j] - b[i] = ${b[j] - b[i]}\")\n if (s <= k) {\n left = ave\n } else {\n right = ave\n }\n }\n// println(\"i = $i, left = $left\")\n val ans = Math.min(t, left)\n// println(\"ans = $ans\")\n var cur = 0.toLong()\n val j = Math.max(Math.min(lowerBound(ans, a), i + m), i)\n cur += ans.toLong() * (j - i) - (b[j] - b[i])\n cur += (b[i + m] - b[j]) - ans.toLong() * (i + m - j)\n res = Math.min(res, cur)\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "db661c36505fe585e60f5cd0335c2dbb", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashMap\n\nvar scanner = Scanner(System.`in`)\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun main() {\n val (n, m, k) = readInts()\n var A = readLongs()\n var a = arrayListOf ()\n \n a.addAll(A)\n a.sort()\n \n var ans = (1e18).toLong()\n var ans = (1e18).toLong()\n var ind = 0\n var above:Long = 0\n var below:Long = 0\n for (i in 0..m-1) above += a[i]-a[0]\n for (i in 0..n-m) {\n val des = i+(m-1)/2\n while (ind < des) { // try to get closer to median if possible\n if (below+(a[ind+1]-a[ind])*(ind+1-i) <= k) {\n below += (a[ind+1]-a[ind])*(ind+1-i)\n above -= (a[ind+1]-a[ind])*(i+m-1-ind) // ind+1 to i+m-1\n ind ++\n } else break\n }\n assert (k >= below)\n if (ind < des) {\n var oops: Long = (k-below)/(ind+1-i)\n ans = minOf(ans,below+above-(i+m-1-ind)*oops+(ind+1-i)*oops)\n assert(i+m-1-ind >= ind+1-i)\n } else ans = minOf(ans,above+below)\n if (i < n-m) {\n below -= a[ind]-a[i]\n above += a[i+m]-a[ind]\n }\n }\n print(ans)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2dce3f8726978017e8c3c06f3f4d0853", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\nval OUT = mutableListOf()\nval N = 100000\nvar cnt = IntArray(10)\nval dp = HashMap()\n\nfun dfs(len: Int, c2: Int, c3: Int, c5: Int, c7: Int) : Long {\n if (c2 < 0 || c3 < 0 || c5 < 0 || c7 < 0)\n return 0L\n var tmp = (c2 + (c3 shl 5) + (c5 shl 10) + (c7 shl 14) + (len shl 18)).toLong()\n if (len == 0) {\n if (tmp == 0L)\n return 1L\n return 0L\n }\n dp[tmp]?.let { return it }\n var ret = 0L\n ret += dfs(len-1, c2, c3, c5, c7) // 1\n ret += dfs(len-1, c2-1, c3, c5, c7) // 2\n ret += dfs(len-1, c2, c3-1, c5, c7) // 3\n ret += dfs(len-1, c2-2, c3, c5, c7) // 4\n ret += dfs(len-1, c2, c3, c5-1, c7) // 5\n ret += dfs(len-1, c2-1, c3-1, c5, c7) // 6\n ret += dfs(len-1, c2, c3, c5, c7-1) // 7\n ret += dfs(len-1, c2-3, c3, c5, c7) // 8\n ret += dfs(len-1, c2, c3-2, c5, c7) // 9\n dp[tmp] = ret\n return ret\n}\n\nvar ret = \"\"\n\nfun solve(k: Long, len: Int, c2: Int, c3: Int, c5: Int, c7: Int) {\n if (c2 < 0 || c3 < 0 || c5 < 0 || c7 < 0)\n return\n if (len == 0)\n return\n var cur = 0L\n var tmp = dfs(len-1, c2, c3, c5, c7)\n if (cur+tmp >= k) {\n ret += \"1\"\n solve(k-cur, len-1, c2, c3, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2-1, c3, c5, c7) // 2\n if (cur+tmp >= k) {\n ret += \"2\"\n solve(k-cur, len-1, c2-1, c3, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2, c3-1, c5, c7) // 3\n if (cur+tmp >= k) {\n ret += \"3\"\n solve(k-cur, len-1, c2, c3-1, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2-2, c3, c5, c7) // 4\n if (cur+tmp >= k) {\n ret += \"4\"\n solve(k-cur, len-1, c2-2, c3, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2, c3, c5-1, c7) // 5\n if (cur+tmp >= k) {\n ret += \"5\"\n solve(k-cur, len-1, c2, c3, c5-1, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2-1, c3-1, c5, c7) // 6\n if (cur+tmp >= k) {\n ret += \"6\"\n solve(k-cur, len-1, c2-1, c3-1, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2, c3, c5, c7-1) // 7\n if (cur+tmp >= k) {\n ret += \"7\"\n solve(k-cur, len-1, c2, c3, c5, c7-1)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2-3, c3, c5, c7) // 8\n if (cur+tmp >= k) {\n ret += \"8\"\n solve(k-cur, len-1, c2-3, c3, c5, c7)\n return\n }\n cur += tmp\n tmp = dfs(len-1, c2, c3-2, c5, c7) // 9\n if (cur+tmp >= k) {\n ret += \"9\"\n solve(k-cur, len-1, c2, c3-2, c5, c7)\n return\n }\n}\n\nfun solve() {\n var (m,kk) = nextInts()\n var k = kk.toLong()\n var n = m\n var ar = mutableListOf()\n for (i in 2..9) {\n while (n % i == 0) {\n n /= i\n cnt[i]++\n }\n }\n if (n != 1) {\n println(\"-1\")\n return\n }\n var len = 0\n while (1) {\n len += 1\n var nx = dfs(len, cnt[2], cnt[3], cnt[5], cnt[7]);\n if (nx < k) {\n k -= nx;\n continue\n }\n solve(k, len, cnt[2], cnt[3], cnt[5], cnt[7])\n println(ret)\n return\n }\n}\n\nfun main() {\n var T = 1 // nextInt()\n for (i in 1..T) {\n solve()\n }\n //println(OUT.joinToString(\"\\n\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0be879294192ab9a5b32ac164037f1b3", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.test.currentStackTrace\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\nfun main(args: Array) {\n var (m, k) = readInts()\n var cnt = IntArray(10)\n for (i in 2..7) {\n while (m % i == 0) {\n m /= i\n cnt[i] += 1\n }\n }\n if (m > 1) {\n println(\"-1\")\n return\n }\n var dp = Array(101) { Array(cnt[2] + 1) { Array(cnt[3] + 1) { Array(cnt[5] + 1) {IntArray(cnt[7] + 1) {0} } } } }\n dp[0][0][0][0][0] = 1\n for (i in 0 until dp.size - 1) {\n for (k2 in 0..cnt[2]) {\n for (k3 in 0..cnt[3]) {\n for (k5 in 0..cnt[5]) {\n for (k7 in 0..cnt[7]) {\n var ft = dp[i][k2][k3][k5][k7]\n if (ft == 0) {\n continue\n }\n for (d in 1..9) {\n var n2 = k2\n var n3 = k3\n var n5 = k5\n var n7 = k7\n var x = d\n while (x % 2 == 0) {\n x /= 2\n n2++\n }\n while (x % 3 == 0) {\n x /= 3\n n3++\n }\n while (x % 5 == 0) {\n x /= 5\n n5++\n }\n while (x % 7 == 0) {\n x /= 7\n n7++\n }\n if (n2 <= cnt[2] && n3 <= cnt[3] && n5 <= cnt[5] && n7 <= cnt[7]) {\n dp[i + 1][n2][n3][n5][n7] = minOf(k, dp[i + 1][n2][n3][n5][n7] + ft)\n }\n }\n }\n }\n }\n }\n }\n for (len in 1 until dp.size) {\n var k2 = cnt[2]\n var k3 = cnt[3]\n var k5 = cnt[5]\n var k7 = cnt[7]\n var cur = dp[len][k2][k3][k5][k7]\n if (k > cur) {\n k -= cur\n continue\n }\n for (i in 0 until len) {\n for (d in 1..9) {\n var n2 = k2\n var n3 = k3\n var n5 = k5\n var n7 = k7\n var x = d\n while (x % 2 == 0) {\n x /= 2\n n2--\n }\n while (x % 3 == 0) {\n x /= 3\n n3--\n }\n while (x % 5 == 0) {\n x /= 5\n n5--\n }\n while (x % 7 == 0) {\n x /= 7\n n7--\n }\n if (n2 >= 0 && n3 >= 0 && n5 >= 0 && n7 >= 0) {\n var cur = dp[len - i - 1][n2][n3][n5][n7]\n if (cur < k) {\n k -= cur\n } else {\n print(d)\n k2 = n2\n k3 = n3\n k5 = n5\n k7 = n7\n break\n }\n }\n }\n }\n println()\n break\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "907bfe3d19dfb89c38632769151ca8a2", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.stream.IntStream\nimport java.util.Arrays\nimport java.util.HashMap\nimport java.util.ArrayList\nimport java.io.OutputStreamWriter\nimport java.io.UncheckedIOException\nimport java.util.stream.Stream\nimport java.io.Closeable\nimport java.io.Writer\nimport java.util.function.ToIntFunction\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject Main {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = GMNumbers()\n solver.solve(1, `in`, out)\n out.close()\n }\n }\n\n internal class GMNumbers {\n var inf = 2e9.toLong()\n\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val m = `in`.readInt()\n var k = `in`.readInt()\n\n var mm = m\n for (i in 2..9) {\n while (mm % i == 0) {\n mm /= i\n }\n }\n if (mm != 1) {\n out.println(-1)\n return\n }\n\n val factorList = ArrayList(10000)\n run {\n var i = 1\n while (i * i <= m) {\n if (m % i != 0) {\n i++\n continue\n }\n factorList.add(i)\n if (m / i != i) {\n factorList.add(m / i)\n }\n i++\n }\n }\n val factors = factorList.stream().mapToInt(ToIntFunction { it.toInt() }).toArray()\n Arrays.sort(factors)\n val valToIndex = HashMap(factors.size)\n for (i in factors.indices) {\n valToIndex[factors[i]] = i\n }\n val transfer = Array(factors.size) { IntArray(10) }\n for(i in 0 until factors.size)\n {\n for(j in 0 until 10)\n {\n transfer[i][j] = -1;\n }\n }\n for (i in factors.indices) {\n for (j in 1..9) {\n if (factors[i] % j == 0) {\n transfer[i][j] = valToIndex[factors[i] / j]!!\n }\n }\n }\n\n val dp = ArrayList(100000)\n val firstState = LongArray(factors.size)\n for (i in firstState.indices) {\n if (factors[i] < 10) {\n firstState[i] = 1\n } else {\n firstState[i] = 0\n }\n }\n dp.add(firstState)\n while (dp[dp.size - 1][factors.size - 1] < k) {\n val last = dp[dp.size - 1]\n val next = LongArray(factors.size)\n for (i in factors.indices) {\n for (j in 1..9) {\n if (transfer[i][j] != -1) {\n next[i] += last[transfer[i][j]]\n }\n }\n next[i] = Math.min(next[i], inf)\n }\n dp.add(next)\n }\n\n var len = 0\n while (dp[len][factors.size - 1] < k) {\n k -= dp[len][factors.size - 1].toInt()\n len++\n }\n\n var state = factors.size - 1\n while (len > 0) {\n val last = dp[len - 1]\n for (i in 1..9) {\n if (transfer[state][i] != -1) {\n if (last[transfer[state][i]] < k) {\n k -= last[transfer[state][i]].toInt()\n } else {\n state = transfer[state][i]\n len--\n out.append(i)\n break\n }\n }\n }\n }\n\n out.append(factors[state])\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(c: Int): FastOutput {\n cache.append(c)\n println()\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n }\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "98a51bef34e5d1d855ea0fdff124fb4d", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.stream.IntStream\nimport java.util.Arrays\nimport java.util.HashMap\nimport java.util.ArrayList\nimport java.io.OutputStreamWriter\nimport java.io.UncheckedIOException\nimport java.util.stream.Stream\nimport java.io.Closeable\nimport java.io.Writer\nimport java.util.function.ToIntFunction\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject Main {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = GMNumbers()\n solver.solve(1, `in`, out)\n out.close()\n }\n }\n\n internal class GMNumbers {\n var inf = 2e9.toLong()\n\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val m = `in`.readInt()\n var k = `in`.readInt()\n\n var mm = m\n for (i in 2..9) {\n while (mm % i == 0) {\n mm /= i\n }\n }\n if (mm != 1) {\n out.println(-1)\n return\n }\n\n val factorList = ArrayList(10000)\n run {\n var i = 1\n while (i * i <= m) {\n if (m % i != 0) {\n i++\n continue\n }\n factorList.add(i)\n if (m / i != i) {\n factorList.add(m / i)\n }\n i++\n }\n }\n val factors = factorList.stream().mapToInt(ToIntFunction { it.toInt() }).toArray()\n Arrays.sort(factors)\n val valToIndex = HashMap(factors.size)\n for (i in factors.indices) {\n valToIndex[factors[i]] = i\n }\n val transfer = Array(factors.size) { IntArray(10) }\n SequenceUtils.deepFill(transfer, -1)\n for (i in factors.indices) {\n for (j in 1..9) {\n if (factors[i] % j == 0) {\n transfer[i][j] = valToIndex[factors[i] / j]!!\n }\n }\n }\n\n val dp = ArrayList(100000)\n val firstState = LongArray(factors.size)\n for (i in firstState.indices) {\n if (factors[i] < 10) {\n firstState[i] = 1\n } else {\n firstState[i] = 0\n }\n }\n dp.add(firstState)\n while (dp[dp.size - 1][factors.size - 1] < k) {\n val last = dp[dp.size - 1]\n val next = LongArray(factors.size)\n for (i in factors.indices) {\n for (j in 1..9) {\n if (transfer[i][j] != -1) {\n next[i] += last[transfer[i][j]]\n }\n }\n next[i] = Math.min(next[i], inf)\n }\n dp.add(next)\n }\n\n var len = 0\n while (dp[len][factors.size - 1] < k) {\n k -= dp[len][factors.size - 1].toInt()\n len++\n }\n\n var state = factors.size - 1\n while (len > 0) {\n val last = dp[len - 1]\n for (i in 1..9) {\n if (transfer[state][i] != -1) {\n if (last[transfer[state][i]] < k) {\n k -= last[transfer[state][i]].toInt()\n } else {\n state = transfer[state][i]\n len--\n out.append(i)\n break\n }\n }\n }\n }\n\n out.append(factors[state])\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(c: Int): FastOutput {\n cache.append(c)\n println()\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n }\n\n internal object SequenceUtils {\n fun deepFill(array: Any, `val`: Int) {\n if (!array.javaClass.isArray()) {\n throw IllegalArgumentException()\n }\n if (array is IntArray) {\n Arrays.fill(array, `val`)\n } else {\n val objArray = array as Array\n for (obj in objArray) {\n deepFill(obj, `val`)\n }\n }\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6a33141dcbba773a616f0f7f462f13d7", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "\n\nimport java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.util.stream.IntStream\nimport java.util.Arrays\nimport java.util.HashMap\nimport java.util.ArrayList\nimport java.io.OutputStreamWriter\nimport java.io.UncheckedIOException\nimport java.util.stream.Stream\nimport java.io.Closeable\nimport java.io.Writer\nimport java.util.Comparator\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject programkt {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", (1 shl 27).toLong())\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastInput(inputStream)\n val out = FastOutput(outputStream)\n val solver = GMNumbers()\n solver.solve(1, `in`, out)\n out.close()\n }\n }\n\n internal class GMNumbers {\n var inf = 2e9.toLong()\n\n fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {\n val m = `in`.readInt()\n var k = `in`.readInt()\n\n var mm = m\n for (i in 2..9) {\n while (mm % i == 0) {\n mm /= i\n }\n }\n if (mm != 1) {\n out.println(-1)\n return\n }\n\n val factorList = ArrayList(10000)\n run {\n var i = 1\n while (i * i <= m) {\n if (m % i != 0) {\n i++\n continue\n }\n factorList.add(i)\n if (m / i != i) {\n factorList.add(m / i)\n }\n i++\n }\n }\n factorList.sort(Comparator.naturalOrder())\n val factors = factorList.stream().mapToInt(ToIntFunction { it.toInt() }).toArray()\n val valToIndex = HashMap(factors.size)\n for (i in factors.indices) {\n valToIndex[factors[i]] = i\n }\n val transfer = Array(factors.size) { IntArray(10) }\n SequenceUtils.deepFill(transfer, -1)\n for (i in factors.indices) {\n for (j in 1..9) {\n if (factors[i] % j == 0) {\n transfer[i][j] = valToIndex[factors[i] / j]\n }\n }\n }\n\n val dp = ArrayList(100000)\n val firstState = LongArray(factors.size)\n for (i in firstState.indices) {\n if (factors[i] < 10) {\n firstState[i] = 1\n } else {\n firstState[i] = 0\n }\n }\n dp.add(firstState)\n while (dp[dp.size - 1][factors.size - 1] < k) {\n val last = dp[dp.size - 1]\n val next = LongArray(factors.size)\n for (i in factors.indices) {\n for (j in 1..9) {\n if (transfer[i][j] != -1) {\n next[i] += last[transfer[i][j]]\n }\n }\n next[i] = Math.min(next[i], inf)\n }\n dp.add(next)\n }\n\n var len = 0\n while (dp[len][factors.size - 1] < k) {\n k -= dp[len][factors.size - 1].toInt()\n len++\n }\n\n var state = factors.size - 1\n while (len > 0) {\n val last = dp[len - 1]\n for (i in 1..9) {\n if (transfer[state][i] != -1) {\n if (last[transfer[state][i]] < k) {\n k -= last[transfer[state][i]].toInt()\n } else {\n state = transfer[state][i]\n len--\n out.append(i)\n break\n }\n }\n }\n }\n\n out.append(factors[state])\n }\n\n }\n\n internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {\n private val cache = StringBuilder(10 shl 20)\n\n override fun append(csq: CharSequence): FastOutput {\n cache.append(csq)\n return this\n }\n\n override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {\n cache.append(csq, start, end)\n return this\n }\n\n constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}\n\n override fun append(c: Char): FastOutput {\n cache.append(c)\n return this\n }\n\n fun append(c: Int): FastOutput {\n cache.append(c)\n return this\n }\n\n fun println(c: Int): FastOutput {\n cache.append(c)\n println()\n return this\n }\n\n fun println(): FastOutput {\n cache.append(System.lineSeparator())\n return this\n }\n\n fun flush(): FastOutput {\n try {\n os.append(cache)\n os.flush()\n cache.setLength(0)\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n return this\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n throw UncheckedIOException(e)\n }\n\n }\n\n override fun toString(): String {\n return cache.toString()\n }\n\n }\n\n internal class FastInput(private val `is`: InputStream) {\n private val buf = ByteArray(1 shl 20)\n private var bufLen: Int = 0\n private var bufOffset: Int = 0\n private var next: Int = 0\n\n private fun read(): Int {\n while (bufLen == bufOffset) {\n bufOffset = 0\n try {\n bufLen = `is`.read(buf)\n } catch (e: IOException) {\n bufLen = -1\n }\n\n if (bufLen == -1) {\n return -1\n }\n }\n return buf[bufOffset++].toInt()\n }\n\n fun skipBlank() {\n while (next >= 0 && next <= 32) {\n next = read()\n }\n }\n\n fun readInt(): Int {\n var sign = 1\n\n skipBlank()\n if (next == '+'.toInt() || next == '-'.toInt()) {\n sign = if (next == '+'.toInt()) 1 else -1\n next = read()\n }\n\n var `val` = 0\n if (sign == 1) {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 + next - '0'.toInt()\n next = read()\n }\n } else {\n while (next >= '0'.toInt() && next <= '9'.toInt()) {\n `val` = `val` * 10 - next + '0'.toInt()\n next = read()\n }\n }\n\n return `val`\n }\n\n }\n\n internal object SequenceUtils {\n fun deepFill(array: Any, `val`: Int) {\n if (!array.javaClass.isArray()) {\n throw IllegalArgumentException()\n }\n if (array is IntArray) {\n Arrays.fill(array, `val`)\n } else {\n val objArray = array as Array\n for (obj in objArray) {\n deepFill(obj, `val`)\n }\n }\n }\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9f129228f2b44305a9b116e633b5aeb0", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "// 7/7/2020 11:13 AM\n\npackage p489\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n findSumToN(403, 105)\n}\n\nfun findSumToN(m: Int, s: Int) {\n// findSumToN_recursive(m, s, listOf())\n printLeastAndGreatest(findSumToN_iterative(m, s))\n}\n\nfun printLeastAndGreatest(l: List) {\n if (l.isEmpty()) {\n println(\"-1 -1\")\n return\n }\n\n val theGreatest = l.toMutableList()\n val theLeast = l.toMutableList()\n\n for (i in theLeast.size-1 downTo 1) {\n if (theLeast[i] > 0) {\n val v = theLeast.removeAt(i)\n theLeast.add(0, v)\n break\n }\n }\n\n var pos = 1\n for (i in theLeast.size - 1 downTo 1) {\n val v = theLeast.removeAt(theLeast.size - 1)\n theLeast.add(pos, v)\n pos++\n }\n\n print(theLeast.fold(\"\", { acc, cur -> acc + cur.toString()}))\n print(\" \")\n println(theGreatest.fold(\"\", { acc, cur -> acc + cur.toString()}))\n\n\n}\n\nfun findSumToN_iterative(m: Int, s: Int) : List {\n var currentList = mutableListOf()\n while (currentList.sum() < s) {\n val totalLeft = s - currentList.sum()\n currentList.add(\n when{\n totalLeft > 9 -> 9\n else -> totalLeft\n }\n )\n }\n if (currentList.size > m) return emptyList()\n\n while (currentList.size < m) {\n currentList.add(0)\n }\n return currentList\n}\n\nfun findSumToN_recursive(m: Int, s: Int, numbersSoFar: List) : Unit {\n val currentTotal = numbersSoFar.sum()\n val nNumbers = numbersSoFar.size\n if (currentTotal > s || nNumbers > m)\n return\n else if (currentTotal == s) {\n var newNumbersSoFar = numbersSoFar.toMutableList()\n while (newNumbersSoFar.size < m) {\n newNumbersSoFar.add(0)\n }\n println(newNumbersSoFar)\n } else {\n val lastNum = if (numbersSoFar.isEmpty()) 9 else numbersSoFar.last()\n for (i in lastNum downTo 1) {\n val newNumbersSoFar = numbersSoFar.toMutableList()\n newNumbersSoFar.add(i)\n findSumToN_recursive(s, m, newNumbersSoFar)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0488dbb849350d4c16f5aeae8096e96a", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class A {\n private static InputReader in = new InputReader();\n\n public static void main(String[] args) throws Exception {\n StringBuilder sb = new StringBuilder();\n\n int n = in.next(Integer.class), sum = 0, cur = 0, cnt = 0;\n long[] arr = new long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = in.next(Integer.class);\n sum += arr[i];\n if (i == 0 || arr[i] <= arr[0] / 2) {\n cur += arr[i];\n cnt++;\n sb.append(i + 1);\n sb.append(' ');\n }\n }\n if (cur > sum / 2) {\n System.out.println(cnt);\n System.out.println(sb.toString().trim());\n } else\n System.out.println(0);\n\n }\n\n static final long MOD = 1_000_000_007;\n\n\n static class InputReader {\n private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n private StringTokenizer tokenizer = new StringTokenizer(\"\");\n\n public String nextLine() throws Exception {\n return reader.readLine();\n }\n\n public T next(Class c) throws Exception {\n while (!tokenizer.hasMoreTokens())\n tokenizer = new StringTokenizer(reader.readLine());\n return (T) c.getMethod(\"valueOf\", String.class).invoke(null, tokenizer.nextToken());\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fdb3188ea4008f388e7449a80893a6f8", "src_uid": "0a71fdaaf08c18396324ad762b7379d7", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.company.codeforces.mailru\n\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\n\nclass TaskA : Solver() {\n override fun solve() {\n val x = scanner.nextInt()\n val y = scanner.nextInt()\n val z = scanner.nextInt()\n val t = arrayOf(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())\n val dist = Math.abs(x - y)\n val walk = dist * t[0]\n val lift = (Math.abs(z - x) + dist)*t[1] + 2*t[2]\n if (walk< lift){\n System.out.println(\"NO\")\n } else{\n System.out.println(\"YES\")\n }\n }\n}\n\nfun main(args: Array) {\n TaskA().solve()\n}\n\nabstract class Solver {\n internal val scanner = MyScanner()\n abstract fun solve()\n}\n\ninternal class MyScanner {\n private val `in` = BufferedReader(InputStreamReader(System.`in`))\n private var buffer: Array? = null\n private var pos = 0\n\n @Throws(IOException::class)\n fun nextInt(): Int {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return Integer.parseInt(buffer!![pos - 1])\n }\n\n @Throws(IOException::class)\n fun nextLong(): Long {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return (buffer!![pos - 1]).toLong()\n }\n\n @Throws(IOException::class)\n fun nextString(): String {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return buffer!![pos - 1]\n }\n\n @Throws(IOException::class)\n fun getIntList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextInt())\n return result\n }\n\n @Throws(IOException::class)\n fun getIntArray(n: Int): IntArray {\n val result = IntArray(n)\n for (i in 0 until n)\n result[i] = nextInt()\n return result\n }\n\n @Throws(IOException::class)\n fun getLongList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextLong())\n return result\n }\n\n @Throws(IOException::class)\n fun getLongArray(n: Int): LongArray {\n val result = LongArray(n)\n for (i in 0 until n)\n result[i] = nextLong()\n return result\n }\n\n @Throws(IOException::class)\n fun getStringList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextString())\n return result\n }\n\n}\n\nclass TaskC : Solver() {\n override fun solve() {\n val n = scanner.nextInt()\n val ls = scanner.getIntArray(n)\n val rs = scanner.getIntArray(n)\n\n val ans = IntArray(n)\n var cur = n\n val visited = BooleanArray(n)\n val touched = BooleanArray(n)\n var count = 0\n while (count < n) {\n var found = false\n touched.fill(false)\n for (i in 0 until n) {\n if (!visited[i] && ls[i] == 0 && rs[i] == 0 && !touched[i]) {\n found = true\n ans[i] = cur\n visited[i] = true\n count++\n for (j in 0 until n) {\n if (j < i) {\n if (rs[j] > 0) {\n rs[j]--\n touched[j] = true\n }\n }\n if (j > i) {\n if (ls[j] > 0) {\n ls[j]--\n touched[j] = true\n }\n }\n }\n }\n }\n if (!found) {\n System.out.print(\"NO\")\n return\n }\n cur--\n }\n\n System.out.println(\"YES\")\n for (i in ans) {\n System.out.print(\"$i \")\n }\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "61f97a2b74c9073bb2a57ca2307139a4", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import com.sun.jdi.IntegerValue\nimport java.sql.Array\n\nfun main() {\n var (a, b) = readLine()!!.split(' ').map(String::toInt)\n var count = 0\n while(a>=1 && b>=2 || a>=2 && b>=1) {\n if (a >= b) {\n a = a - 2\n b = b - 1\n count++\n } else {\n a = a - 1\n b = b - 2\n count++\n }\n }\n print(count)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7eb982546cae8180a5639d77cd726cdf", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n println(readLine()?.let { solve59A(it) })\n }\n\n private fun solve59A(input: String): String {\n val lowercaseCount = input.filter { it.isLowerCase() }.count()\n return if (lowercaseCount >= input.length/2)\n input.toLowerCase()\n else\n input.toUpperCase()\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "36cb703a62028b98ea891b39e2a24391", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n println(solve59A())\n}\n\nfun solve59A(): String {\n val line = Scanner(System.`in`).nextLine()\n var up = 0\n var low = 0\n line.forEach { \n if(it.isUpperCase())\n up += 1\n else\n low += 1\n }\n return if(up >= low)\n line.toUpperCase()\n else\n line.toLowerCase()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ec596d5f50a94669b4180f5424e3b637", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.util.*\n\nobject programkt {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n val x = sc.nextInt()\n val a = 2\n val b = -2\n val c = 13 - a * 3 * 3 - b * 3\n if (x == 0)\n println(15)\n else if (x == 1)\n println(14)\n else if (x == 2)\n println(12)\n else if (x == 3)\n println(13)\n else if (x == 4)\n println(8)\n else if (x == 5)\n println(9)\n else if (x == 6)\n println(10)\n else if (x == 7)\n println(11)\n else if (x == 8)\n println(0)\n else if (x == 9)\n println(1)\n else if (x == 10)\n println(2)\n else if (x == 11)\n println(3)\n else if (x == 12)\n println('aaaa')\n else if (x / 1 % 3 == 0)\n println('a')\n else if (x / 1 % 3 == 1)\n while(true) {}\n else\n throw RuntimeException()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0a570205defc75c4ed64b3e9503b32b6", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.util.*\n\nobject programkt {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n val x = sc.nextInt()\n val a = 2\n val b = -2\n val c = 13 - a * 3 * 3 - b * 3\n if (x % 3 == 0)\n println('a')\n if (x % 3 == 1)\n while(true) {}\n if (x % 3 == 2)\n throw new RuntimeException()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "767ee105b387e38e35eeea5f1b8456c2", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null} {"lang": "Kotlin", "source_code": "val pole = listOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)\n\nfun main() {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n println(if (pole[x*64 + y] == 0) \"OUT\" else \"IN\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "48714cd1f5b07574b4ca147c3fe215e9", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val stones= readLine()!!.toString()\n var count=1\n var j=1\n val size=n-1\n for (i in 0 until size)\n {\n\n if (stones[i]==stones[j])\n {\n count++\n }\n j++\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "217e5f04ef6a18638f8122829622ad99", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val _ = readInt()\n val str = readLine()!!\n var counter = 0\n var prev = str[0]\n str.substring(1).forEach { c ->\n if (prev == c) counter++\n prev = c\n }\n println(counter)\n}\n\nprivate fun readInt() = readLine()!!.toInt()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "270102711ff839332d475f63e00c124f", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val stones= readLine()!!.toString()\n var count=1\n var j=1\n val size=stones.length-1\n for (i in 0 until size)\n {\n\n if (stones[i]==stones[j])\n {\n count++\n }\n j++\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8bf1f056944f5183712ba3ee16f40ba4", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val stones= readLine()!!.toString()\n var count=1\n var j=1\n val size=stones.length-1\n for (i in 0 until size)\n {\n\n if (stones[i]==stones[j])\n {\n count++\n }\n j++\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5f3f20c934b3adaf33e64b1be1ff6ec8", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val inputs = readLine()!!.split(\" \").map(Integer::parseInt)\n val a = inputs[0]\n val b = inputs[1]\n\n val unmatched = min(a, b)\n val matched = abs(a - b) / 2\n\n println(\"$unmatched $matched\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9b8fca0ab2b00a34cad0acb0a5911b24", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package Avito\n\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val str = scanner.next()\n for (i in str.length downTo 0) {\n for (j in 0 .. str.length - i) {\n// println(\"$i $j\")\n if (i % 2 == 0) {\n// println(str.substring(j, j + i / 2) + \" \" + str.substring(j + i / 2, j + i))\n if (str.substring(j, j + i / 2) != str.substring(j + i / 2, j + i).reversed()) {\n println(i)\n return\n }\n }\n else {\n// println((str.substring(j, j + i / 2 ) + \" \" + str.substring(j + i / 2 + 1, j + i)))\n if (str.substring(j, j + i / 2) != str.substring(j + i / 2 + 1, j + i).reversed()) {\n println(i)\n return\n }\n }\n }\n }\n println(0)\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e87b065a4accd4b1bb49dc1461a69155", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n var (n, m) = readLine()!!.split(' ').map { it.toInt() }\n var n1 = readLine()!!.split(' ').map { it.toInt() }.toMutableList()\n var x = n1\n var x1 = n1\n var a = HashMap()\n for(i in x){\n a.put(i, 0)\n }\n for (i in x){\n a.put(i, a.getOrDefault(i, 0) + 1)\n }\n for(i in a){\n if(i.value >= n){\n println(0)\n return\n }\n }\n var t = m - n\n for(i in 0 until t){\n n1.remove(maxt(n1))\n }\n for(i in 0 until t){\n x1.remove(mint(x1))\n }\n println(min(maxt(n1) - mint(n1), maxt(x1) - mint(x1)))\n}\nfun maxt(x: MutableList): Int{\n var r = x[0]\n for(i in x){\n if(i > r){\n r = i\n }\n }\n return r\n}\nfun mint(x: MutableList): Int{\n var r = x[0]\n for(i in x){\n if(i < r){\n r = i\n }\n }\n return r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "beac5a9bed1f9d8db83bb3ba87c883d7", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.math.RoundingMode\nimport java.text.DecimalFormat\nimport java.util.*\nimport kotlin.collections.ArrayList\n\nimport kotlin.collections.HashMap\n\n\n\nfun main() {\n\n\n\n var n=Integer.parseInt(readLine()!!)\n var a:MutableList = readLine()!!.split(' ').map(String::toInt).toMutableList();\n\n var one=0\n\n \n \n for (i in 0..(a.size-1)){\n var cur=0\n for (k in (i..a.size-1)) {\n cur = 0\n for (l in 0..a.size - 1) {\n if ((l >= i && l <= k)) {\n if (a[l] == 0) ++cur\n } else if (a[l] == 1) ++cur\n }\n max = Math.max(max, cur)\n\n\n }\n }\n println(max)\n\n}\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d76311be675935609035e757616efcb6", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "package con895\n\nimport java.io.*\nimport java.lang.Integer.sum\nimport java.lang.Math.abs\nimport java.util.*\n\nfun main (args : Array){\n val n = nextInt()\n val opt: Int = 180\n var optAns = 0\n val angles = nextArray(n)\n for (i in 1..n){\n for (j in i..n) {\n if (abs(angles.slice(i..j).sum() - opt) < abs(optAns - opt)) {\n optAns = angles.slice(i..j).sum()\n }\n }\n }\n print(2 * abs(opt-optAns))\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextLine() = if(hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n,{nextInt()})\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nvar br = BufferedReader(InputStreamReader(System.`in`))\n\nvar pw = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n}\n\nvar st = StringTokenizer(\"\")", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "64533b5e3e6dccd7a02e556c56f579a9", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n \npublic class Solution{\n\n public static void main(String[] args) {\n \n \n Scanner in = new Scanner(System.in);\n String f = \"hello\";\n String s = in.nextLine();\n int nowp = 0;\n for(int i = 0; i < s.length(); i++){\n if(s.charAt(i)==f.charAt(nowp))\n nowp ++;\n if(nowp == f.length()) break;\n }\n if(nowp == f.length()){\n System.out.println(\"YES\");\n } else {\n System.out.println(\"NO\");\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "006059c9a11f3498a8a6b7decb58599a", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (k, r) = readLines()!!.split(\" \").map{ it.toInt() }\n for(i in 1..9) {\n if((i * k) % 10 == r ) {\n println(i)\n break\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "37c66e04ca738597dbc4c2f69001a7cf", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val a_n_1 = 1\n val a_n = 1\n for (i in 2..n) {\n\n a_n = (a_n_1 + Math.pow(2.0, i.toDouble())).toInt()\n a_n_1 = a_n\n }\n \n println(a_n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "48dd48a4dfc79f8b923539a39223543c", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\n val (a, b) = readLine()!!.split(delimiters = \" \").map{it.toInt()}\n\n if (b - a == 0) {\n println(\"${a}1 ${b}2\")\n } else if (b - a == 1) {\n println(\"${a}9 ${b}0\")\n } else {\n println(-1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8ef2078fdef63e58bd947870cbeab6cd", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject Main {\n\n @JvmStatic fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val a = java.lang.Long.toString(n)\n var t = 0\n for (i in 0..a.length - 1) {\n if (a[i] - '0' == 7 || a[i] - '0' == 4)\n t++\n else\n continue\n }\n if (t == 4 || t == 7)\n println(\"YES\")\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a97134d3ee4e42b7a612b8be567554fc", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n println(readLine()?.let { solve110A(it) })\n }\n\n private fun solve110A(input: String): String{\n val count4s = input.filter { it == '4' }.count()\n val count7s = input.filter { it == '7' }.count()\n\n return (input.isLucky() || (count4s + count7s).toString().isLucky()).toAnswer()\n }\n\n private fun String.isLucky(): Boolean {\n val count4s = this.filter { it == '4' }.count()\n val count7s = this.filter { it == '7' }.count()\n\n return count4s + count7s == this.length\n }\n\n private fun Boolean.toAnswer(): String = when(this) {\n true -> \"YES\"\n false -> \"NO\"\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1f69261feb7de3420fdb6d95cb0aefa8", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n println(TaskSolver.solve110A(\"47047\"))\n }\n }\n}\n\nclass TaskSolver {\n companion object {\n fun solve110A(input: String): String{\n val count4s = input.filter { it == '4' }.count()\n val count7s = input.filter { it == '7' }.count()\n\n return (input.isLucky() || (count4s + count7s).toString().isLucky()).toAnswer()\n }\n\n private fun String.isLucky(): Boolean {\n val count4s = this.filter { it == '4' }.count()\n val count7s = this.filter { it == '7' }.count()\n\n return count4s + count7s == this.length\n }\n\n private fun Boolean.toAnswer(): String = when(this) {\n true -> \"YES\"\n false -> \"NO\"\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6268ecb0c8fde9acfab320671e370bed", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Main {\n companion object {\n @JvmStatic\n fun main(args: Array) {\n println(solve110A(\"47047\"))\n }\n\n fun solve110A(input: String): String{\n val count4s = input.filter { it == '4' }.count()\n val count7s = input.filter { it == '7' }.count()\n\n return (input.isLucky() || (count4s + count7s).toString().isLucky()).toAnswer()\n }\n\n private fun String.isLucky(): Boolean {\n val count4s = this.filter { it == '4' }.count()\n val count7s = this.filter { it == '7' }.count()\n\n return count4s + count7s == this.length\n }\n\n private fun Boolean.toAnswer(): String = when(this) {\n true -> \"YES\"\n false -> \"NO\"\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aeafd9ba8c9d14c024a5b7f3bc666222", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n var num = r.readLine()!!.toLong()\n val luck = listOf<>(4, 7)\n var many = 0\n while (num>0){\n val remainer = num%10\n if (remainer in luck) many++\n num /= 10\n }\n println(if (many%4==0||many%7==0)\"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2245ee9261d1b8a475c262f52991f45c", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n val s = readLine()!!.filter { it == '4' || it == '7' }.count()\n if (s == 4 || s == 7) println(\"YES\") else println(\"NO\")", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2814057d2b8fae4299546bfe3fe93809", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var result = 0\nfor (i in 1..5) \n{\n val (a, b, c, d, e) = readLine()!!.split(\" \").map { it.toInt() }\n\tif(i==1 || i==5)\n\t{\n if (a == 1) {\n result += 4\n\t\tbreak\n\t\t}\t\t\n if (b == 1) {\n result += 3\n\t\tbreak\n\t\t}\t\n\t\tif (c == 1) {\n result += 1\n\t\tbreak\n if (d == 1) {\n result += 1\n\t\tbreak\n\t\t}\n if (e == 1) {\n result += 2\n\t\tbreak\n\t}\n\tif(i==2 || i==4)\n\t{\n if (a == 1) {\n result += 3\n\t\tbreak\n\t\t}\t\t\n if (b == 1) {\n result += 2\n\t\tbreak\n\t\t}\t\n\t\tif (c == 1) {\n result += 1\n\t\tbreak\n if (d == 1) {\n result += 2\n\t\tbreak\n\t\t}\n if (e == 1) {\n result += 3\n\t\tbreak\n\t}\n\tif(i==3)\n\t{\n if (a == 1) {\n result += 2\n\t\tbreak\n\t\t}\t\t\n if (b == 1) {\n result += 1\n\t\tbreak\n\t\t}\t\n\t\tif (c == 1) {\n result += 0\n\t\tbreak\n if (d == 1) {\n result += 1\n\t\tbreak\n\t\t}\n if (e == 1) {\n result += 2\n\t\tbreak\n\t}\n\t\n}\n\n println(result)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "086c403e5f976d868cecb20811266e0c", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tval matrix: MutableList> = mutableListOf<>()\n\tfor (i in 0 until 5) {\n\t\tval row = readLine()!!.split(' ').map(String::toInt)\n\t\tmatrix.add(row)\n\t}\n\tprintln(getResult(input))\n}\n\nfun getResult(input: List>): Int {\n\tval centerI = 3\n\tval centerJ = 3\n\tvar integerI = 0\n\tvar integerJ = 0\n\n\tloop@ for (i in 0 until matrix.size) {\n\t\tfor (j in 0 until matrix[i].size) {\n\t\t\tif (matrix[i][j] == 1) {\n\t\t\t\tintegerI = i\n\t\t\t\tintegerJ = j\n\t\t\t\tbreak@loop\n\t\t\t}\n\t\t}\t\n\t}\n\t\n\treturn abs(integerI - centerI) + abs(integerJ - centerJ)\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "12a1640181d17d8236333d5dde20653b", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n for (r in 0..4) {\n val index = readLine()!!.split(\" \").map { it.toInt() }.indexOf(1)\n if(index != -1) {\n println(abs(2 - r) + abs(2 - index))\n return\n }\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c79240d846ade3026c997842c79c7ca6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n\nimport java.util.*\nimport kotlin.math.abs\n\nclass Main {\n\n var array=Array(5){IntArray(5)}\n var read: Scanner=Scanner(System.`in`)\n fun main(){\n\n var x:Int=0\n var y:Int=0\n for(i in 1..5)\n for(j in 1..5){\n array[i][j]=read.nextInt()\n if(array[i][j]==1){\n x=i\n y=j\n }\n }\n println(abs(x-3)+ abs(y-3))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f01d96ce53d643eb9c4d99edfd4b6748", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n \n\nfun main() \n{ \n\tvar result = 0\n\tfor (i in 1..5) \n\t{\n\t\tval (a, b, c, d, e) = readLine()!!.split(\" \").map { it.toInt() }\n\t\tif(i==1 || i==5)\n\t\t{\n\t\t\tif (a == 1) {\n\t\t\t\tresult = 4\n\t\t\tbreak\n\t\t\t}\t\t\n\t\t\tif (b == 1) {\n\t\t\t\tresult = 3\n\t\t\tbreak\n\t\t\t}\t\n\t\t\tif (c == 1) {\n\t\t\t\tresult = 1\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (d == 1) {\n\t\t\t\tresult = 1\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (e == 1) {\n\t\t\t\tresult = 2\n\t\t\tbreak\n\t\t}\n\t\tif(i==2 || i==4)\n\t\t{\n\t\t\tif (a == 1) {\n\t\t\t\tresult = 3\n\t\t\tbreak\n\t\t\t}\t\t\n\t\t\tif (b == 1) {\n\t\t\t\tresult = 2\n\t\t\tbreak\n\t\t\t}\t\n\t\t\tif (c == 1) {\n\t\t\t\tresult = 1\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (d == 1) {\n\t\t\t\tresult = 2\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (e == 1) {\n\t\t\t\tresult = 3\n\t\t\tbreak\n\t\t}\n\t\tif(i==3)\n\t\t{\n\t\t\tif (a == 1) {\n\t\t\t\tresult = 2\n\t\t\tbreak\n\t\t\t}\t\t\n\t\t\tif (b == 1) {\n\t\t\t\tresult = 1\n\t\t\tbreak\n\t\t\t}\t\n\t\t\tif (c == 1) {\n\t\t\t\tresult = 0\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (d == 1) {\n\t\t\t\tresult = 1\n\t\t\tbreak\n\t\t\t}\n\t\t\tif (e == 1) {\n\t\t\t\tresult = 2\n\t\t\tbreak\n\t\t}\t\n\t}\n\tprintln(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cc343e0b1d2d9fc4dd52f28fd370ef64", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math\n\nfun main(args: Array) {\n\tval matrix: MutableList> = mutableListOf()\n\tfor (i in 0 until 5) {\n\t\tval row = readLine()!!.split(' ').map(String::toInt)\n\t\tmatrix.add(row)\n\t}\n\tprintln(getResult(matrix))\n}\n\nfun getResult(matrix: List>): Int {\n\tval centerI = 3\n\tval centerJ = 3\n\tvar integerI = 0\n\tvar integerJ = 0\n\n\tloop@ for (i in 0 until matrix.size) {\n\t\tfor (j in 0 until matrix[i].size) {\n\t\t\tif (matrix[i][j] == 1) {\n\t\t\t\tintegerI = i\n\t\t\t\tintegerJ = j\n\t\t\t\tbreak@loop\n\t\t\t}\n\t\t}\t\n\t}\n\t\n\treturn abs(integerI - centerI) + abs(integerJ - centerJ)\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c7781198e2b78505196b873cda256394", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "[3:36 PM] NamHP\n + t\u1ee9c l\u00e0 1 l\u1ea7n \u0111\u00fang lu\u00f4n\n\u200b[3:36 PM] NamHP\n fun main()\n{ \n var result = 0\n for (i in 1..5)\n {\n val (a, b, c, d, e) = readLine()!!.split(\" \").map { it.toInt() }\n if(i==1 || i==5)\n {\n if (a == 1 || e == 1) {\n result = 4\n break\n } \n if (b == 1 || d == 1) {\n result = 3\n break\n } \n if (c == 1) {\n result = 2\n break\n } \n }\n if(i==2 || i==4)\n {\n if (a == 1 || e == 1) {\n result = 3\n break\n } \n if (b == 1 || d == 1) {\n result = 2\n break\n } \n if (c == 1) {\n result = 1\n break\n } \n }\n if(i==3)\n {\n if (a == 1 || e == 1) {\n result = 2\n break\n } \n if (b == 1 || d == 1) {\n result = 1\n break\n } \n if (c == 1) {\n result = 0\n break\n } \n } \n }\n println(result)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eb3329650c81328053299e0a3fe34130", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val matrix = Array>(5, {_ -> readLine()!!.split(' ').map(String::toInt).toTypedArray()})\n for (i in matrix.indices) {\n for (j in matrix[i].indices) {\n if (matrix[i][j] == 1) {\n var a = if (i >= 2) i - 2 else 2 - i\n var b = if (j >= 2) j - 2 else 2 - j\n // print(\"a = $a\\n\")\n // print(\"b = $b\\n\")\n print((a + b).toString() + \"\\n\")\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "87fb4fb10ad3aefb2ebc9d588109b907", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n fun prime(i: Int) = (2..sqrt(i.toDouble()).toInt()).none { it % i == 0 }\n val n = r.readLine()!!.toInt()\n //val v = r.readLine()!!.split(\" \").map { it.toInt() }.toSet().toList().sorted()\n var m = 1\n while (!prime(m*n+1)){\n m++\n }\n println(m)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d368725c41041276140b6ad45f3b7e7c", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// 1C - AncientBerlandCircus\npackage set_1.C\n\nimport java.util.ArrayList\nimport java.lang.Math\n\nfun readString(): String {\n val line: String? = readLine()\n return (line ?: \"\").trim()\n}\n\nfun readWords(): List {\n val s: String = readString()\n val pat: Regex = Regex(\"\\\\s+\")\n return s.split(pat)\n}\n\nfun readDoubles(): List {\n val words: List = readWords()\n var lst: ArrayList = ArrayList()\n for (word in words) {\n try {\n var v: Double = word.toDouble()\n lst.add(v)\n }\n catch(nfe: NumberFormatException) {\n println(\"invalid word: \" + word)\n }\n }\n return lst\n}\n\ndata class Point(val x: Double, val y: Double)\ndata class Line(val m: Double, val b: Double, val vertical: Boolean = false, val x_intercept: Double = 0.0)\n\nfun midpoint(p1: Point, p2: Point) : Point {\n val x = (p1.x + p2.x) / 2.0\n val y = (p1.y + p2.y) / 2.0\n return Point(x, y)\n}\n\nfun makeLine(p1: Point?, p2: Point?) : Line? {\n if (p1 == null || p2 == null) return null\n if (p1.x == p2.x && p1.y == p2.y) return null\n if (p1.x == p2.x) {\n return Line(0.0,0.0,true,p1.x)\n }\n val m = (p1.y - p2.y) / (p1.x - p2.x)\n val b = p1.y - m * p1.x\n return Line(m,b)\n}\n\nfun distance(p1: Point?, p2: Point?) : Double? {\n if (p1 == null || p2 == null) return null\n val dx = Math.abs(p1.x - p2.x)\n val dy = Math.abs(p1.y - p2.y)\n val dh = Math.sqrt(dx * dx + dy * dy)\n return dh\n}\nfun bisector(p1: Point?, p2: Point?) : Line? {\n if (p1 == null || p2 == null) return null\n if (p1.y == p2.y) {\n if (p1.x == p2.x) return null\n return Line(0.0, 0.0, true, (p1.x + p2.x)/ 2.0)\n } else {\n val bslope: Double = (p1.x - p2.x) / (p2.y - p1.y)\n val p3: Point = midpoint(p1, p2)\n val b: Double = p3.y - bslope * p3.x\n return Line(bslope, b)\n }\n}\n\nfun intersect_vertical(lnv: Line?, lvert: Line?) : Point? {\n if (lnv == null || lvert == null) return null\n val m = lnv.m\n val b = lnv.b\n val x = lvert.x_intercept\n return Point(x, m * x + b)\n}\nfun intersection(l1: Line?, l2: Line?) : Point? {\n if (l1 == null || l2 == null) return null\n if (l1.vertical && l2.vertical) return null\n if (!l1.vertical && !l2.vertical) {\n val m1: Double = l1.m\n val m2: Double = l2.m\n if (m1 == m2) return null\n // y = m1*x + b1\n // y = m2*x + b2\n // 0 = (m1-m2)*x + b1-b2\n // x = (b2 - b1) / (m1 - m2)\n val x = (l2.b - l1.b) / (l1.m - l2.m)\n val y = l1.m * x + l1.b\n return Point(x, y)\n }\n if (l1.vertical) {\n return intersect_vertical(l2, l1);\n } else {\n return intersect_vertical(l1, l2);\n }\n}\n// angle in radians between two lines.\n// A circle has 2*PI radians\nfun angle(l1: Line?, l2: Line?) : Double? {\n if (l1 == null || l2 == null) return null\n if (l1.vertical && l2.vertical) return 0.0\n if (!l1.vertical && !l2.vertical) {\n val tan_phi2 = (l2.m - l1.m) / (1.0 + l1.m * l2.m)\n val tan_phi: Double = if (l2.m > l1.m) tan_phi2 else -1.0 * tan_phi2\n val phi = Math.atan(tan_phi)\n return phi\n }\n if (l1.vertical && l2.m == 0.0 || l2.vertical && l1.m == 0.0) {\n // they are at right-angles\n return Math.PI/2.0\n }\n if (l1.vertical) {\n // we're going to rotate l1.m 90 degrees, so the slope is 0.0\n // the other line will have slope -1/m\n val m2 = -1.0 / l2.m\n val tan_phi = if (m2 > 0.0) m2 else -m2\n return Math.atan(tan_phi)\n }\n if (l2.vertical) {\n val m1 = -1.0 / l1.m\n val tan_phi = if (m1 > 0.0) m1 else -m1\n return Math.atan(tan_phi)\n }\n return null\n}\n\nfun minFit(phi: Double?) : Int? {\n if (phi == null) return null\n val p = Math.abs(phi)\n for (n in 2..100) {\n val div = 2.0 * Math.PI / n\n if (p % div < 0.00001) {\n return n\n }\n }\n return null\n}\n\nfun fits(phi: Double?, n: Int): Boolean {\n if (phi == null) return true;\n val p = Math.abs(phi)\n val div = 2.0 * Math.PI / n\n if (p % div < 0.00001) {\n return true\n }\n return false\n}\nfun bestFit(phi1: Double?, phi2: Double?, phi3: Double?): Int? {\n\n for (n in 2..100) {\n if (fits(phi1,n) && fits(phi2,n) && fits(phi3,n)) {\n return n\n }\n }\n return null\n}\n\nfun main(args: Array) {\n val dat1: List = readDoubles()\n val p1 = Point(dat1[0], dat1[1])\n val dat2: List = readDoubles()\n val p2 = Point(dat2[0], dat2[1])\n val dat3: List = readDoubles()\n val p3 = Point(dat3[0], dat3[1])\n val b1: Line? = bisector(p1, p2)\n val b2: Line? = bisector(p2, p3)\n val b3: Line? = bisector(p3, p1)\n val i1: Point? = intersection(b1, b2)\n val i2: Point? = intersection(b2, b3)\n val i3: Point? = intersection(b3, b1)\n var center: Point? = i1 ?: i2 ?: i3\n val l1: Line? = makeLine(center, p1)\n val l2: Line? = makeLine(center, p2)\n val l3: Line? = makeLine(center, p3)\n val a1: Double? = angle(l1, l2)\n val a2: Double? = angle(l2, l3)\n val a3: Double? = angle(l3, l1)\n val fit: Int? = bestFit(a1, a2, a3)\n val d1: Double? = distance(center, p1)\n val d2: Double? = distance(center, p2)\n val d3: Double? = distance(center, p3)\n val d: Double? = d1 ?: d2 ?: d3\n if (fit != null && d != null) {\n val phi = Math.PI / fit\n val dy = d * Math.sin(phi)\n val dx = d * Math.cos(phi)\n val area = dx * dy * fit\n println(\"%.6f\".format(area))\n } else {\n println(\"unable to calculate\")\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "63d47bf88652986b0a503b95e8a3b14d", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\nfun main(args: Array) {\n val p = readLine()!!.toInt()\n val m = readLine()!!.toBigInteger()\n print(m % BigInteger.TWO.pow(p))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d5567cbf09a72f59179efbb6456660aa", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val j = readLine()!!.toLong()\n if (j % 2 == 1)\n println((j - j / 2).unaryMinus())\n else\n println(j / 2)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "527ebf94b645947b4fad95e91f4f1d01", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " val j = readLine()!!.toInt()\n if (j % 2 == 1)\n println((j - j / 2).unaryMinus())\n else\n println(j / 2)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6c75ba349b4aaca8cdfe1e7558adcab9", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\nfun main(args: Array) {\n var (ye, bl) = readLine()!!.split(\" \").map { it.toBigInteger() }\n val (x, y, z) = readLine()!!.split(\" \").map { it.toBigInteger() }\n var add = BigInteger.ZERO\n val three = BigInteger(\"3\")\n\n if (bl < z * three) {\n val toAdd = z * three - bl\n add += toAdd\n bl += toAdd\n }\n bl -= z * three\n if (ye < x * BigInteger.TWO) {\n val toAdd = x * BigInteger.TWO - ye\n add += toAdd\n ye += toAdd\n }\n ye -= x * BigInteger.TWO\n val toAddYe = y - ye\n val toAddBl = y - bl\n\n if (toAddBl > BigInteger.ZERO) {\n add += toAddBl\n }\n if (toAddYe > BigInteger.ZERO) {\n add += toAddYe\n }\n print(add)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a58ce90936038bc9b2d16eb7cd8bb3cc", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package main\n\nimport java.util.Scanner\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n input.nextInt()\n val k = input.nextInt()\n\n val baloons = readLine()\n\n val groups = baloons?.groupBy { it }\n val m = groups?.values?.map { it.size }?.max() ?: 0\n\n println(if (k >= m) \"YES\" else \"NO\");\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3e0d0c5e714ab1404869d421f7950515", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.FileReader\nimport java.io.InputStreamReader\n\nval ONLINE = System.getProperty(\"ONLINE_JUDGE\") != null\nval inp = BufferedReader(if (ONLINE) InputStreamReader(System.`in`) else FileReader(\"in.txt\"))\n\ninline fun readTokens() = inp.readLine()!!.split(' ')\ninline fun readInt() = inp.readLine()!!.toInt()\ninline fun readInt2() = readTokens().map { it.toInt() }.let { it[0] to it[1] }\ninline fun readLine() = inp.readLine()!!\n\nfun main(args: Array) {\n val (_, k) = readInt2()\n val s = readLine()\n val a = IntArray('z' - 'a') { 0 }\n s.forEach { a[it - 'a']++ }\n val r = a.max() ?: 0\n println(if (k <= r) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f920ebe06d6fd98b48592eca58a3acbf", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package codeforces.com.tasks.task670A\n\nfun main() {\n val days = readLine()!!.toInt()\n val weeks = days / 7\n var minDaysOff = weeks * 2\n var maxDaysOff = weeks * 2\n\n when(days % 7) {\n 1 -> maxDaysOff += 1\n 2 -> maxDaysOff += 2\n 6 -> { maxDaysOff += 2; minDaysOff += 1 }\n }\n println(\"$minDaysOff $maxDaysOff\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5746ddc8aa29bbd1688edd25cd9e21f7", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Kotlin", "source_code": " val input = Scanner(System.`in`)\n val n = input.nextFloat()\n val t = input.nextFloat()\n val k = input.nextFloat()\n val d = input.nextFloat()\n val timeOneOven= (ceil(n.div(k))).times(t).minus(t)\n if (timeOneOven > d)\n println(\"YES\")\n else\n println(\"NO\")", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cfde3ba47da8149ed8c51e1660a35f9b", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun fibInv(n: Long): Int {\n if(n < 3) {\n return 1;\n }\n\n var i = 1;\n val fib = ArrayList(2)\n\n fib.add(1);\n fib.add(2);\n\n while(n >= fib[i]) {\n i++\n fib.add(fib[i - 1] + fib[i - 2]);\n }\n\n return i - 1;\n}\n\nfun main(args: Array) {\n val n = readLine()?.toLong() ?: 0\n\n println(fibInv(n));\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ee0c2a52e2cb68d0503af218f013df43", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "Kotlin 1.5", "source_code": "@file:Suppress(\"EXPERIMENTAL_API_USAGE\")\r\n\r\nimport Utils.ArrayUtils.Companion.arrayOfNullsSafe\r\nimport Utils.ArrayUtils.Companion.makeDistinct\r\nimport Utils.ArrayUtils.Companion.toNotNulls\r\nimport Utils.ArrayUtils.Prints.Companion.println\r\nimport Utils.ArrayUtils.Sorts.Companion.countSort\r\nimport Utils.ArrayUtils.Sorts.Companion.shuffleSort\r\nimport Utils.ArrayUtils.Swaps.Companion.swap\r\nimport Utils.BinarySearchUtils.Companion.binarySearch\r\nimport Utils.BinarySearchUtils.Companion.binarySearchDouble\r\nimport Utils.BinarySearchUtils.Companion.binarySearchLong\r\nimport Utils.BitUtils.Companion.flip\r\nimport Utils.BitUtils.Companion.get\r\nimport Utils.BitUtils.Companion.set\r\nimport Utils.BitUtils.Companion.submaskOf\r\nimport Utils.FastReader\r\nimport Utils.GeneralUtils.Companion.catch\r\nimport Utils.GeneralUtils.Companion.length\r\nimport Utils.GeneralUtils.Companion.rnd\r\nimport Utils.MathUtils.Companion.compareDoubles\r\nimport Utils.MathUtils.Companion.gcd\r\nimport Utils.MathUtils.Companion.log2\r\nimport Utils.Pairs.Companion.ComparablePair\r\nimport Utils.Pairs.Companion.IntPair\r\nimport Utils.Pairs.Companion.LongPair\r\nimport java.io.*\r\nimport java.util.*\r\nimport kotlin.collections.ArrayDeque\r\nimport kotlin.math.*\r\nimport kotlin.random.Random\r\nimport kotlin.time.ExperimentalTime\r\n\r\n@ExperimentalStdlibApi\r\n@ExperimentalTime\r\n@ExperimentalUnsignedTypes\r\nfun main() {\r\n Locale.setDefault(Locale.US)\r\n System.setOut(PrintStream(BufferedOutputStream(System.out)))\r\n Task(FastReader()).solve()\r\n System.out.flush()\r\n}\r\n\r\nconst val eps = 1e-8\r\n\r\nconst val mod = 998244353\r\n\r\n@JvmInline\r\nvalue class MInt(val x: Int) {\r\n operator fun plus(m: MInt) = MInt((x + m.x) % mod)\r\n operator fun minus(m: MInt) = MInt((x - m.x + mod) % mod)\r\n operator fun times(m: MInt) = MInt((x.toLong() * m.x % mod).toInt())\r\n operator fun div(m: MInt) = this * m.inv()\r\n\r\n fun inv() = inv(x)\r\n fun pow(p: Int): MInt {\r\n if (p == 0) return MInt(1)\r\n var r = pow(p / 2)\r\n r *= r\r\n if (p % 2 == 1) r *= this\r\n return r\r\n }\r\n\r\n override fun toString() = x.toString()\r\n\r\n companion object {\r\n private val facts = mutableListOf(MInt(1))\r\n private val invs = mutableListOf(MInt(0))\r\n private val invFacts = mutableListOf(MInt(1))\r\n fun Int.mod() = MInt(this)\r\n\r\n fun factorial(x: Int): MInt {\r\n while (x !in facts.indices) facts += facts.last() * facts.size.mod()\r\n return facts[x]\r\n }\r\n\r\n fun inv(x: Int): MInt {\r\n while (x !in invs.indices) invs += MInt((mod - mod / x) % mod) * inv(mod % x)\r\n return x.mod().pow(mod - 2)\r\n }\r\n\r\n fun invFact(x: Int): MInt {\r\n while (x !in invFacts.indices) invFacts += invFacts.last() * inv(invFacts.size)\r\n return invFacts[x]\r\n }\r\n }\r\n}\r\n\r\nfun c(n: Int, k: Int) = if (k in 0..n) MInt.factorial(n) * MInt.invFact(k) * MInt.invFact(n - k) else MInt(0)\r\n\r\n@ExperimentalTime\r\n@ExperimentalStdlibApi\r\nclass Task(private val fin: FastReader = FastReader()) {\r\n fun solve() {\r\n val n = fin.readInt()\r\n val maxHealth = fin.readInt()\r\n\r\n val powers = Array(maxHealth + 1) { x ->\r\n Array(n + 1) { null as MInt? }.apply {\r\n this[0] = MInt(1)\r\n for (p in 1 until size) this[p] = this[p - 1]!! * MInt(x)\r\n } as Array\r\n }\r\n\r\n val cache = Array(n + 1) { IntArray(maxHealth + 1) { -1 } }\r\n fun go(alive: Int, damageGot: Int): MInt {\r\n if (alive == 0) return MInt(1)\r\n if (damageGot > maxHealth) return MInt(0)\r\n if (alive == 1) return MInt(0)\r\n cache[alive][damageGot].let { if (it != -1) return MInt(it) }\r\n var res = go(alive, damageGot + alive - 1)\r\n for (died in 1..alive) {\r\n val survived = alive - died\r\n val minWas = 1 + damageGot\r\n val maxWas = minOf(alive - 1 + damageGot, maxHealth)\r\n val numberOfWaysDied = c(alive, died)\r\n val healthForDied = powers[maxWas - minWas + 1][died]\r\n res += go(survived, damageGot + alive - 1) * numberOfWaysDied * healthForDied\r\n }\r\n cache[alive][damageGot] = res.x\r\n return res\r\n }\r\n\r\n val ans = go(n, 0)\r\n println(ans)\r\n }\r\n}\r\n\r\n@Suppress(\"MemberVisibilityCanBePrivate\", \"unused\")\r\n@ExperimentalStdlibApi\r\n@ExperimentalUnsignedTypes\r\nclass Utils {\r\n class GeneralUtils {\r\n companion object {\r\n val rnd = Random(239)\r\n val IntRange.length get() = maxOf(last - first + 1, 0)\r\n\r\n @Suppress(\"UNREACHABLE_CODE\", \"ControlFlowWithEmptyBody\")\r\n fun catch(throwMLE: Boolean = false, f: () -> R): R {\r\n try {\r\n return f()\r\n } catch (e: Exception) {\r\n if (throwMLE) throw OutOfMemoryError()\r\n while (true) {\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n class MathUtils {\r\n companion object {\r\n tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\r\n tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\r\n fun lcm(a: Long, b: Long) = a / gcd(a, b) * b\r\n\r\n fun Int.log2(): Int {\r\n var log = 0\r\n while (1 shl log < this) log++\r\n return log\r\n }\r\n\r\n fun Long.log2(): Int {\r\n var log = 0\r\n while (1L shl log < this) log++\r\n return log\r\n }\r\n\r\n fun compareDoubles(x: Double, y: Double) =\r\n if (abs(x - y) < eps) 0 else if (x < y) -1 else +1\r\n\r\n fun isZero(x: Double) = abs(x) < eps\r\n }\r\n }\r\n\r\n class BitUtils {\r\n companion object {\r\n operator fun Int.get(bit: Int) = (this shr bit) and 1\r\n operator fun Long.get(bit: Int) = ((this shr bit) and 1).toInt()\r\n fun Int.set(bit: Int) = this or (1 shl bit)\r\n fun Long.set(bit: Int) = this or (1L shl bit)\r\n fun Int.flip(bit: Int) = this xor (1 shl bit)\r\n fun Long.flip(bit: Int) = this xor (1L shl bit)\r\n infix fun Int.submaskOf(x: Int) = (this and x) == this\r\n infix fun Long.submaskOf(x: Long) = (this and x) == this\r\n }\r\n }\r\n\r\n class ArrayUtils {\r\n companion object {\r\n fun > MutableList.makeDistinct() {\r\n if (size <= 1) return\r\n sort()\r\n var sz = 1\r\n for (i in 1 until size) {\r\n if (this[i] != this[i - 1]) {\r\n this[sz++] = this[i]\r\n }\r\n }\r\n while (size > sz) removeAt(lastIndex)\r\n }\r\n\r\n @Suppress(\"UNCHECKED_CAST\")\r\n fun Array.toNotNulls() = this as Array\r\n\r\n @Suppress(\"UNCHECKED_CAST\")\r\n inline fun arrayOfNullsSafe(size: Int): Array =\r\n arrayOfNulls(size).toNotNulls()\r\n }\r\n\r\n class Swaps {\r\n companion object {\r\n fun Array.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n }\r\n\r\n fun MutableList.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n }\r\n\r\n fun IntArray.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n }\r\n\r\n fun LongArray.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n }\r\n\r\n fun DoubleArray.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n sort()\r\n }\r\n\r\n fun CharArray.swap(i: Int, j: Int) {\r\n val x = this[i]\r\n this[i] = this[j]\r\n this[j] = x\r\n sort()\r\n }\r\n }\r\n }\r\n\r\n class Sorts {\r\n companion object {\r\n fun IntArray.shuffleSort() {\r\n for (i in 1 until size) swap(i, rnd.nextInt(i + 1))\r\n sort()\r\n }\r\n\r\n fun LongArray.shuffleSort() {\r\n for (i in 1 until size) swap(i, rnd.nextInt(i + 1))\r\n sort()\r\n }\r\n\r\n fun DoubleArray.shuffleSort() {\r\n for (i in 1 until size) swap(i, rnd.nextInt(i + 1))\r\n sort()\r\n }\r\n\r\n fun CharArray.shuffleSort() {\r\n for (i in 1 until size) swap(i, rnd.nextInt(i + 1))\r\n sort()\r\n }\r\n\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun Array.countSort(\r\n inPlace: Boolean = true,\r\n type: (T) -> Int = { (it as Number).toInt() }\r\n ): Array {\r\n if (isEmpty()) return if (inPlace) this else emptyArray()\r\n val types = IntArray(size) { type(this[it]) }\r\n val min = types.minOrNull()!!\r\n val max = types.maxOrNull()!!\r\n val count = IntArray(max - min + 1)\r\n for (t in types) count[t - min]++\r\n var sum = 0\r\n for (i in count.indices) {\r\n val shift = count[i]\r\n count[i] = sum\r\n sum += shift\r\n }\r\n val sorted = arrayOfNullsSafe(size)\r\n for (i in 0 until size) sorted[count[types[i] - min]++] = this[i]\r\n return if (inPlace) {\r\n this.also { sorted.copyInto(this) }\r\n } else {\r\n sorted\r\n }\r\n }\r\n\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun List.countSort(\r\n inPlace: Boolean = true,\r\n type: (T) -> Int = { (it as Number).toInt() }\r\n ): List {\r\n if (isEmpty()) return if (inPlace) this else emptyList()\r\n val types = IntArray(size) { type(this[it]) }\r\n val min = types.minOrNull()!!\r\n val max = types.maxOrNull()!!\r\n val count = IntArray(max - min + 1)\r\n for (t in types) count[t - min]++\r\n var sum = 0\r\n for (i in count.indices) {\r\n val shift = count[i]\r\n count[i] = sum\r\n sum += shift\r\n }\r\n val sorted = arrayOfNullsSafe(size)\r\n for (i in 0 until size) sorted[count[types[i] - min]++] = this[i]\r\n return if (inPlace) {\r\n return (this as MutableList).apply {\r\n for (i in indices) this[i] = sorted[i]\r\n }\r\n } else {\r\n sorted.asList()\r\n }\r\n }\r\n\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun IntArray.countSort(\r\n inPlace: Boolean = true,\r\n type: (Int) -> Int = { it -> it }\r\n ): IntArray {\r\n if (isEmpty()) return if (inPlace) this else intArrayOf()\r\n val types = IntArray(size) { type(this[it]) }\r\n val min = types.minOrNull()!!\r\n val max = types.maxOrNull()!!\r\n val count = IntArray(max - min + 1)\r\n for (t in types) count[t - min]++\r\n var sum = 0\r\n for (i in count.indices) {\r\n val shift = count[i]\r\n count[i] = sum\r\n sum += shift\r\n }\r\n val sorted = IntArray(size)\r\n for (i in 0 until size) sorted[count[types[i] - min]++] = this[i]\r\n return if (inPlace) {\r\n this.also { sorted.copyInto(this) }\r\n } else {\r\n sorted\r\n }\r\n }\r\n }\r\n }\r\n\r\n class Prints {\r\n companion object {\r\n fun println(a: IntArray) {\r\n if (a.isNotEmpty()) {\r\n print(a[0])\r\n for (i in 1 until a.size) {\r\n print(' ')\r\n print(a[i])\r\n }\r\n }\r\n println()\r\n }\r\n\r\n fun println(a: LongArray) {\r\n if (a.isNotEmpty()) {\r\n print(a[0])\r\n for (i in 1 until a.size) {\r\n print(' ')\r\n print(a[i])\r\n }\r\n }\r\n println()\r\n }\r\n\r\n fun println(a: CharArray, printSpace: Boolean = false) {\r\n if (a.isNotEmpty()) {\r\n print(a[0])\r\n for (i in 1 until a.size) {\r\n if (printSpace) print(' ')\r\n print(a[i])\r\n }\r\n }\r\n println()\r\n }\r\n\r\n fun println(a: Array<*>) {\r\n if (a.isNotEmpty()) {\r\n print(a[0])\r\n for (i in 1 until a.size) {\r\n print(' ')\r\n print(a[i])\r\n }\r\n }\r\n println()\r\n }\r\n\r\n fun println(a: List<*>) {\r\n if (a.isNotEmpty()) {\r\n print(a[0])\r\n for (i in 1 until a.size) {\r\n print(' ')\r\n print(a[i])\r\n }\r\n }\r\n println()\r\n }\r\n\r\n fun println(a: Iterable<*>) {\r\n val it = a.iterator()\r\n if (it.hasNext()) {\r\n print(it.next())\r\n while (it.hasNext()) {\r\n print(' ')\r\n print(it.next())\r\n }\r\n }\r\n println()\r\n }\r\n }\r\n }\r\n }\r\n\r\n class BinarySearchUtils {\r\n companion object {\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun binarySearch(from: Int, to: Int, f: (Int) -> Boolean): Int {\r\n var l = from\r\n var r = to + 1\r\n while (r - l > 1) {\r\n val m = (l + r) / 2\r\n if (f(m)) l = m\r\n else r = m\r\n }\r\n return l\r\n }\r\n\r\n inline fun binarySearch(from: Int = 0, f: (Int) -> Boolean): Int {\r\n var len = 1\r\n while (f(from + len)) len *= 2\r\n return binarySearch(from + len / 2, from + len - 1, f)\r\n }\r\n\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun binarySearchLong(from: Long, to: Long, f: (Long) -> Boolean): Long {\r\n var l = from\r\n var r = to + 1\r\n while (r - l > 1) {\r\n val m = (l + r) / 2\r\n if (f(m)) l = m\r\n else r = m\r\n }\r\n return l\r\n }\r\n\r\n inline fun binarySearchLong(from: Long = 0, f: (Long) -> Boolean): Long {\r\n var len = 1L\r\n while (f(from + len)) len *= 2\r\n return binarySearchLong(from + len / 2, from + len - 1, f)\r\n }\r\n\r\n @Suppress(\"DuplicatedCode\")\r\n inline fun binarySearchDouble(\r\n from: Double,\r\n to: Double,\r\n times: Int = 200,\r\n f: (Double) -> Boolean\r\n ): Double {\r\n var l = from\r\n var r = to\r\n repeat(times) {\r\n val m = (l + r) / 2\r\n if (f(m)) l = m\r\n else r = m\r\n }\r\n return l\r\n }\r\n\r\n inline fun binarySearchDouble(\r\n from: Double = 0.0,\r\n times: Int = 200,\r\n f: (Double) -> Boolean\r\n ): Double {\r\n var len = 1.0\r\n while (f(from + len)) len *= 2\r\n return binarySearchDouble(from, from + len, times, f)\r\n }\r\n }\r\n }\r\n\r\n class Pairs {\r\n companion object {\r\n data class ComparablePair, T2 : Comparable>(\r\n val first: T1,\r\n val second: T2\r\n ) :\r\n Comparable> {\r\n override fun compareTo(other: ComparablePair): Int {\r\n var c = first.compareTo(other.first)\r\n if (c == 0) c = second.compareTo(other.second)\r\n return c\r\n }\r\n }\r\n\r\n data class IntPair(val first: Int, val second: Int) : Comparable {\r\n override fun compareTo(other: IntPair): Int {\r\n var c = first.compareTo(other.first)\r\n if (c == 0) c = second.compareTo(other.second)\r\n return c\r\n }\r\n\r\n fun swap() = IntPair(second, first)\r\n }\r\n\r\n data class LongPair(val first: Long, val second: Long) : Comparable {\r\n override fun compareTo(other: LongPair): Int {\r\n var c = first.compareTo(other.first)\r\n if (c == 0) c = second.compareTo(other.second)\r\n return c\r\n }\r\n }\r\n }\r\n }\r\n\r\n class UtilsImports {\r\n fun importDependencies() {\r\n check(gcd(4, 6) == 2)\r\n check(rnd.nextInt(10) in 0 until 10)\r\n check(mutableListOf(1, 3, 2, 2, 1).apply { makeDistinct() } == listOf(1, 2, 3))\r\n check((5..10).length == 6)\r\n check(intArrayOf(3, 4).apply { swap(0, 1) }.contentEquals(intArrayOf(4, 3)))\r\n check(\r\n intArrayOf(5, 6, 2, 1, 5).apply { shuffleSort() }\r\n .contentEquals(intArrayOf(1, 2, 5, 5, 6))\r\n )\r\n check(binarySearch { it < 10 } == 9)\r\n check(binarySearchLong { it < 1e13.toLong() } == 1e13.toLong() - 1)\r\n binarySearchDouble { true }\r\n println(intArrayOf())\r\n ArrayDeque()\r\n abs(1)\r\n sin(1.0)\r\n cos(1.0)\r\n hypot(1.0, 1.0)\r\n catch {}\r\n ComparablePair(1, 2)\r\n IntPair(1, 2)\r\n arrayOfNulls(0).toNotNulls()\r\n arrayOfNullsSafe(0)\r\n 5.log2()\r\n @Suppress(\"ReplaceGetOrSet\")\r\n 5.get(3)\r\n 5.sign\r\n 5 submaskOf 3\r\n 5.set(3)\r\n 5.flip(3)\r\n compareDoubles(0.0, 1.0)\r\n arrayOf(1, 2).countSort { it.countOneBits() }\r\n LongPair(1, 2)\r\n }\r\n }\r\n\r\n class FastReader(fileName: String? = null) {\r\n @JvmField\r\n val br =\r\n BufferedReader(if (fileName != null) FileReader(fileName) else InputStreamReader(System.`in`))\r\n\r\n @JvmField\r\n var st = StringTokenizer(\"\")\r\n\r\n fun readString(): String {\r\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\r\n return st.nextToken()\r\n }\r\n\r\n fun readInt() = readString().toInt()\r\n fun readLong() = readString().toLong()\r\n fun readDouble() = readString().toDouble()\r\n\r\n fun readIntArray(n: Int) = IntArray(n) { readInt() }\r\n fun readLongArray(n: Int) = LongArray(n) { readLong() }\r\n fun readStringArray(n: Int) = Array(n) { readString() }\r\n fun readDoubleArray(n: Int) = DoubleArray(n) { readDouble() }\r\n\r\n fun readInts(n: Int) = MutableList(n) { readInt() }\r\n fun readLongs(n: Int) = MutableList(n) { readLong() }\r\n fun readStrings(n: Int) = MutableList(n) { readString() }\r\n fun readDoubles(n: Int) = MutableList(n) { readDouble() }\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bd165fbb270b47efec06d2613300491d", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "Kotlin 1.6", "source_code": "fun main() { repeat(readln().toInt()) { println( 100 / gcd( 100 , readln().toInt())) } }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2aaf06207bfe483ff2798b8cae088085", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Kotlin 1.4", "source_code": "fun main() {\r\n val br = BufferedReader(InputStreamReader(System.`in`))\r\n val bw = BufferedWriter(OutputStreamWriter(System.out))\r\n\r\n val t = br.readLine().toInt()\r\n repeat(t) {\r\n val k = br.readLine().toInt()\r\n\r\n val gcd = gcd(k, 100)\r\n\r\n bw.write(\"${100 / gcd}\")\r\n bw.newLine()\r\n }\r\n\r\n bw.flush()\r\n bw.close()\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7f665396771e3998f195425f65cedbb3", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import jdk.jfr.Frequency\nimport java.util.*\n\nfun main(args : Array){\n var n : Int = readLine()!!.toInt()\n val str : List = readLine()!!.split(\" \")\n var arr : List = List(n, {i : Int -> str[i].toInt()})\n var h : HashSet = hashSetOf()\n var s : Stack = Stack()\n for (i in n-1 downTo 0){\n if(!h.contains(arr[i])){\n h.add(arr[i])\n s.add(arr[i])\n }\n }\n while(s.size > 0) {\n val x : Int = s.pop()\n print(\"$x \")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f49e92372c0b911ec66051d4d6718f21", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import jdk.jfr.Frequency\nimport java.util.*\n\nfun main(args : Array){\n var n : Int = readLine()!!.toInt()\n val str : List = readLine()!!.split(\" \")\n var arr : List = List(n, {i : Int -> str[i].toInt()})\n var h : HashSet = hashSetOf()\n var s : Stack = Stack()\n for (i in n-1 downTo 0){\n if(!h.contains(arr[i])){\n h.add(arr[i])\n s.add(arr[i])\n }\n }\n println(s.size)\n while(s.size > 0) {\n val x : Int = s.pop()\n print(\"$x \")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "65080914fb90c98866173a6832a3293d", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\nobject Main {\n @Throws(Exception::class)\n @JvmStatic\n fun main(args: Array) {\n val thread = Thread(null, TaskAdapter(), \"\", 1 shl 28)\n thread.start()\n thread.join()\n }\n\n internal class TaskAdapter : Runnable {\n override fun run() {\n val startTime = System.currentTimeMillis()\n val inputStream = System.`in`\n val outputStream: OutputStream = System.out\n val `in` = FastReader(inputStream)\n val out = Output(outputStream)\n val solver = FKotlinkotlinkotlinkotlin()\n solver.solve(1, `in`, out)\n out.close()\n System.err.println((System.currentTimeMillis() - startTime).toString() + \"ms\")\n }\n }\n\n internal class FKotlinkotlinkotlinkotlin {\n lateinit var graph: Array>\n var clock = 0\n var path: ArrayDeque? = null\n fun dfs(u: Int) {\n while (!graph[u].isEmpty()) {\n dfs(graph[u].pollLast())\n }\n path!!.addFirst(u)\n }\n\n fun solve(kase: Int, `in`: InputReader, pw: Output) {\n val n = `in`.nextInt()\n val kotlin = \"kotlin\"\n graph = Array(6) { ArrayDeque() }\n val edges: Array>> = Array(6) { Array(6) { ArrayDeque() } }\n for (i in 0 until n) {\n val s = `in`.next()\n val u = kotlin.indexOf(s[0])\n val v = (kotlin.indexOf(s[s.length - 1]) + 1) % 6\n graph[u].addLast(v)\n edges[u][v].addFirst(i)\n }\n path = ArrayDeque(n)\n clock = n\n dfs(0)\n Utilities.Debug.dbg(path)\n var prev = path!!.pollFirst()\n for (i in 1..n) {\n val next = path!!.pollFirst()\n pw.print((edges[prev][next].pollFirst() + 1).toString() + \" \")\n prev = next\n }\n pw.println()\n }\n }\n\n internal interface InputReader {\n operator fun next(): String\n fun nextInt(): Int\n }\n\n internal class Output @JvmOverloads constructor(os: OutputStream?, var BUFFER_SIZE: Int = 1 shl 16) : Closeable, Flushable {\n var sb: StringBuilder\n var os: OutputStream\n var lineSeparator: String\n fun print(s: String?) {\n sb.append(s)\n if (sb.length > BUFFER_SIZE shr 1) {\n flushToBuffer()\n }\n }\n\n fun println() {\n sb.append(lineSeparator)\n }\n\n private fun flushToBuffer() {\n try {\n os.write(sb.toString().toByteArray())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n sb = StringBuilder(BUFFER_SIZE)\n }\n\n override fun flush() {\n try {\n flushToBuffer()\n os.flush()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n }\n\n override fun close() {\n flush()\n try {\n os.close()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n }\n\n init {\n sb = StringBuilder(BUFFER_SIZE)\n this.os = BufferedOutputStream(os, 1 shl 17)\n lineSeparator = System.lineSeparator()\n }\n }\n\n internal class FastReader(`is`: InputStream?) : InputReader {\n private val BUFFER_SIZE = 1 shl 16\n private val din: DataInputStream\n private val buffer: ByteArray\n private var bufferPointer: Int\n private var bytesRead: Int\n override fun next(): String {\n val ret = StringBuilder(64)\n var c = skip()\n while (c.toInt() != -1 && !isSpaceChar(c)) {\n ret.appendCodePoint(c.toInt())\n c = read()\n }\n return ret.toString()\n }\n\n override fun nextInt(): Int {\n var ret = 0\n var c = skipToDigit()\n val neg = c == '-'.toByte()\n if (neg) {\n c = read()\n }\n do {\n ret = ret * 10 + c - '0'.toInt()\n } while (read().also { c = it } >= '0'.toByte() && c <= '9'.toByte())\n return if (neg) {\n -ret\n } else ret\n }\n\n private fun isSpaceChar(b: Byte): Boolean {\n return b == ' '.toByte() || b == '\\r'.toByte() || b == '\\n'.toByte() || b == '\\t'.toByte()\n }\n\n private fun skip(): Byte {\n var ret: Byte\n while (isSpaceChar(read().also { ret = it }));\n return ret\n }\n\n private fun isDigit(b: Byte): Boolean {\n return b >= '0'.toByte() && b <= '9'.toByte()\n }\n\n private fun skipToDigit(): Byte {\n var ret: Byte\n while (!isDigit(read().also { ret = it }) && ret != '-'.toByte());\n return ret\n }\n\n private fun fillBuffer() {\n try {\n bytesRead = din.read(buffer, 0.also { bufferPointer = it }, BUFFER_SIZE)\n } catch (e: IOException) {\n e.printStackTrace()\n throw InputMismatchException()\n }\n if (bytesRead == -1) {\n buffer[0] = -1\n }\n }\n\n private fun read(): Byte {\n if (bytesRead == -1) {\n throw InputMismatchException()\n } else if (bufferPointer == bytesRead) {\n fillBuffer()\n }\n return buffer[bufferPointer++]\n }\n\n init {\n din = DataInputStream(`is`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n }\n\n internal class Utilities {\n object Debug {\n val LOCAL = System.getProperty(\"LOCAL\") != null\n private fun ts(t: T?): String {\n return if (t == null) {\n \"null\"\n } else try {\n ts(t as Iterable<*>)\n } catch (e: ClassCastException) {\n if (t is IntArray) {\n val s = Arrays.toString(t as IntArray?)\n return \"{\" + s.substring(1, s.length - 1) + \"}\"\n } else if (t is LongArray) {\n val s = Arrays.toString(t as LongArray?)\n return \"{\" + s.substring(1, s.length - 1) + \"}\"\n } else if (t is CharArray) {\n val s = Arrays.toString(t as CharArray?)\n return \"{\" + s.substring(1, s.length - 1) + \"}\"\n } else if (t is DoubleArray) {\n val s = Arrays.toString(t as DoubleArray?)\n return \"{\" + s.substring(1, s.length - 1) + \"}\"\n } else if (t is BooleanArray) {\n val s = Arrays.toString(t as BooleanArray?)\n return \"{\" + s.substring(1, s.length - 1) + \"}\"\n }\n try {\n ts(t as Array)\n } catch (e1: ClassCastException) {\n t.toString()\n }\n }\n }\n\n private fun ts(arr: Array): String {\n val ret = StringBuilder()\n ret.append(\"{\")\n var first = true\n for (t in arr) {\n if (!first) {\n ret.append(\", \")\n }\n first = false\n ret.append(ts(t))\n }\n ret.append(\"}\")\n return ret.toString()\n }\n\n private fun ts(iter: Iterable): String {\n val ret = StringBuilder()\n ret.append(\"{\")\n var first = true\n for (t in iter) {\n if (!first) {\n ret.append(\", \")\n }\n first = false\n ret.append(ts(t))\n }\n ret.append(\"}\")\n return ret.toString()\n }\n\n fun dbg(vararg o: Any?) {\n if (LOCAL) {\n System.err.print(\"Line #\" + Thread.currentThread().stackTrace[2].lineNumber + \": [\")\n for (i in 0 until o.size) {\n if (i != 0) {\n System.err.print(\", \")\n }\n System.err.print(ts(o[i]))\n }\n System.err.println(\"]\")\n }\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f469464bfdf01d0f8da579e5158faf28", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Collections\nimport java.util.Comparator\nimport java.util.HashMap\nimport java.util.HashSet\nimport java.util.Scanner\n\n internal var g:Array> = Array>(10)\n internal var used = BooleanArray(10)\n class Pair {\n internal var to:Int = 0\n internal var id:Int = 0\n constructor() {\n }\n constructor(_to:Int, _id:Int) {\n to = _to\n id = _id\n }\n internal fun compareTo(p:Pair):Int {\n if (to == p.to && id == p.id) return 0\n if (to < p.to || (to == p.to && id < p.id)) return -1\n return 1\n }\n fun equals(p:Pair):Boolean {\n return to == p.to && id == p.id\n }\n public override fun hashCode():Int {\n return to + id * 6\n }\n }\n fun encode(p:Pair):String {\n return (p.to).toString() + \" \" + (p.id).toString()\n }\n fun decode(s:String):Pair {\n val m = s.indexOf(\" \")\n return Pair(Integer.valueOf(s.substring(0, m)), Integer.valueOf(s.substring(m + 1, s.length)))\n }\n internal fun dfs(v:Int) {\n while (!g[v].isEmpty())\n {\n val p = decode(g[v].iterator().next())\n g[v].remove(encode(p))\n g[p.to].remove(encode(Pair(v, p.id)))\n dfs(p.to)\n print(p.id + 1)\n print(\" \")\n }\n }\n fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n g = Array>(6)\n for (i in 0..5)\n g[i] = HashSet()\n val target = \"kotlin\"\n for (i in 0 until n)\n {\n val s = `in`.next()\n var a = target.indexOf(s.get(0), 0)\n val b = target.indexOf(s.get(s.length - 1), 0)\n a = (a + 5) % 6\n g[a].add(encode(Pair(b, i)))\n g[b].add(encode(Pair(a, i)))\n }\n dfs(5)\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fb842892dca342dda0396921f7068031", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Collections\nimport java.util.Comparator\nimport java.util.HashMap\nimport java.util.HashSet\nimport java.util.Scanner\n\n internal var g:Array> = arrayOfNulls>(10)\n internal var used = BooleanArray(10)\n class Pair {\n internal var to:Int = 0\n internal var id:Int = 0\n constructor() {\n }\n constructor(_to:Int, _id:Int) {\n to = _to\n id = _id\n }\n internal fun compareTo(p:Pair):Int {\n if (to == p.to && id == p.id) return 0\n if (to < p.to || (to == p.to && id < p.id)) return -1\n return 1\n }\n fun equals(p:Pair):Boolean {\n return to == p.to && id == p.id\n }\n public override fun hashCode():Int {\n return to + id * 6\n }\n }\n fun encode(p:Pair):String {\n return (p.to).toString() + \" \" + (p.id).toString()\n }\n fun decode(s:String):Pair {\n val m = s.indexOf(\" \")\n return Pair(Integer.valueOf(s.substring(0, m)), Integer.valueOf(s.substring(m + 1, s.length)))\n }\n internal fun dfs(v:Int) {\n while (!g[v].isEmpty())\n {\n val p = decode(g[v].iterator().next())\n g[v].remove(encode(p))\n g[p.to].remove(encode(Pair(v, p.id)))\n dfs(p.to)\n print(p.id + 1)\n print(\" \")\n }\n }\n fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n g = arrayOfNulls>(6)\n for (i in 0..5)\n g[i] = HashSet()\n val target = \"kotlin\"\n for (i in 0 until n)\n {\n val s = `in`.next()\n var a = target.indexOf(s.get(0), 0)\n val b = target.indexOf(s.get(s.length - 1), 0)\n a = (a + 5) % 6\n g[a].add(encode(Pair(b, i)))\n g[b].add(encode(Pair(a, i)))\n }\n dfs(5)\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b43bcfe1513d6ac57193a62a6b7986e4", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Collections\nimport java.util.Comparator\nimport java.util.HashMap\nimport java.util.HashSet\nimport java.util.Scanner\n\n internal var g:Array> = arrayOfNulls>(10)\n internal var used = BooleanArray(10)\n class Pair {\n internal var to:Int = 0\n internal var id:Int = 0\n constructor() {\n }\n constructor(_to:Int, _id:Int) {\n to = _to\n id = _id\n }\n internal fun compareTo(p:Pair):Int {\n if (to == p.to && id == p.id) return 0\n if (to < p.to || (to == p.to && id < p.id)) return -1\n return 1\n }\n fun equals(p:Pair):Boolean {\n return to == p.to && id == p.id\n }\n public override fun hashCode():Int {\n return to + id * 6\n }\n }\n fun encode(p:Pair):String {\n return (p.to).toString() + \" \" + (p.id).toString()\n }\n fun decode(s:String):Pair {\n val m = s.indexOf(\" \")\n return Pair(Integer.valueOf(s.substring(0, m)), Integer.valueOf(s.substring(m + 1, s.length)))\n }\n internal fun dfs(v:Int) {\n while (!g[v].isEmpty())\n {\n val p = decode(g[v].iterator().next())\n g[v].remove(encode(p))\n g[p.to].remove(encode(Pair(v, p.id)))\n dfs(p.to)\n print(p.id + 1)\n print(\" \")\n }\n }\n fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n g = arrayOfNulls>(6)\n for (i in 0..5)\n g[i] = HashSet()\n val target = \"kotlin\"\n for (i in 0 until n)\n {\n val s = `in`.next()\n var a = target.indexOf(s.get(0), 0)\n val b = target.indexOf(s.get(s.length - 1), 0)\n a = (a + 5) % 6\n g[a].add(encode(Pair(b, i)))\n g[b].add(encode(Pair(a, i)))\n }\n dfs(5)\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "076c3093eedf760185ef509d10a1b6c1", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n val w = List(n) { readLine()!! }\n val k = \"kotlin\"\n val g = k.withIndex().associateBy({ it.value }) { it.index }\n val gf = IntArray(k.length) { -1 }\n val gn = IntArray(n)\n val gv = IntArray(n)\n for ((i, s) in w.withIndex()) {\n val p = g.getValue(s.first())\n val q = (g.getValue(s.last()) + 1) % k.length\n gv[i] = q\n gn[i] = gf[p]\n gf[p] = i\n }\n val ans = IntArray(n)\n var cnt = 0\n val vStack = IntArray(n + 1)\n val eStack = IntArray(n + 1)\n var sp = 0\n while (true) {\n val p = vStack[sp]\n if (gf[p] < 0) {\n if (sp <= 0) break\n ans[cnt++] = eStack[sp\u2013]\n continue\n }\n val j = gf[p]\n val q = gv[j]\n gf[p] = gn[j]\n sp++\n vStack[sp] = q\n eStack[sp] = j\n }\n check(cnt == n)\n ans.reverse()\n println(ans.joinToString(\" \") { (it + 1).toString() })\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e90d7f70c4e2a54a4d261b0a4133b2b7", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main(){\n\tval n=readLine()!!.toInt()\n\tval g=Array(6){ArrayList>()}\n\tfor(i in 1..n){\n\t\tval s=readLine()!!\n\t\tval f=\"kotlin\".indexOf(s[0])\n\t\tval t=(f+s.length)%6\n\t\tg[f].add(t to it)\n\t}\n\tval s=ArrayList()\n\tfun r(n:Int) {\n\t\twhile (!g[n].isEmpty()) {\n\t\t\tval (t,i) = g[n].removeAt(g[n].size-1)\n\t\t\tr(t)\n\t\t\ts.add(i)\n\t\t}\n\t}\n\tr(0)\n\tprintln(s.reversed().joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "eb3e4f0fb3c152005e49efa1641953d5", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Collections\nimport java.util.Comparator\nimport java.util.HashMap\nimport java.util.HashSet\nimport java.util.Scanner\n\n internal var g:Array>\n internal var used:BooleanArray\n class Pair {\n internal var to:Int = 0\n internal var id:Int = 0\n constructor() {\n }\n constructor(_to:Int, _id:Int) {\n to = _to\n id = _id\n }\n internal fun compareTo(p:Pair):Int {\n if (to == p.to && id == p.id) return 0\n if (to < p.to || (to == p.to && id < p.id)) return -1\n return 1\n }\n fun equals(p:Pair):Boolean {\n return to == p.to && id == p.id\n }\n public override fun hashCode():Int {\n return to + id * 6\n }\n }\n fun encode(p:Pair):String {\n return (p.to).toString() + \" \" + (p.id).toString()\n }\n fun decode(s:String):Pair {\n val m = s.indexOf(\" \")\n return Pair(Integer.valueOf(s.substring(0, m)), Integer.valueOf(s.substring(m + 1, s.length)))\n }\n internal fun dfs(v:Int) {\n while (!g[v].isEmpty())\n {\n val p = decode(g[v].iterator().next())\n g[v].remove(encode(p))\n g[p.to].remove(encode(Pair(v, p.id)))\n dfs(p.to)\n print(p.id + 1)\n print(\" \")\n }\n }\n fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n g = arrayOfNulls>(6)\n for (i in 0..5)\n g[i] = HashSet()\n val target = \"kotlin\"\n for (i in 0 until n)\n {\n val s = `in`.next()\n var a = target.indexOf(s.get(0).toInt(), 0)\n val b = target.indexOf(s.get(s.length - 1).toInt(), 0)\n a = (a + 5) % 6\n g[a].add(encode(Pair(b, i)))\n g[b].add(encode(Pair(a, i)))\n }\n dfs(5)\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c845b6c232b3670c23efdca223e4dec6", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "package ru.hse.spb\n\nimport java.util.*\n\nclass Graph {\n private val SIZE = 6\n private var adjacencyMatrix = Array(SIZE) { ArrayList>() }\n\n fun addEdge(from: Int, to: Int, id: Int) {\n adjacencyMatrix[from].add(Pair(to, id))\n }\n\n fun dfs(v: Int, eulerCycle: ArrayList) {\n while (!adjacencyMatrix[v].isEmpty()) {\n val (to, id) = adjacencyMatrix[v].last()\n adjacencyMatrix[v].removeAt(adjacencyMatrix[v].size - 1)\n eulerCycle.add(id)\n dfs(to, eulerCycle)\n }\n }\n\n fun findEulerCycle(): List {\n val eulerCycle = ArrayList()\n dfs(0, eulerCycle)\n return eulerCycle\n }\n}\n\nconst val KOTLIN = \"kotlin\"\n\nfun main() {\n val n = readLine()!!.toInt()\n val symbolToReminder = TreeMap()\n for (i in 0 until KOTLIN.length) {\n symbolToReminder[KOTLIN[i]] = i\n }\n val graph = Graph()\n for (i in 0 until n) {\n val part = readLine()!!\n val from = symbolToReminder[part.first()]!!\n val to = (symbolToReminder[part.last()]!! + 1) % KOTLIN.length\n graph.addEdge(from, to, i)\n }\n val eulerCycle = graph.findEulerCycle()\n for (i in eulerCycle) {\n print(\"${i + 1} \")\n }\n println()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d5f73140f3135cbd65bac8722f25a921", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "package heroes\n\nval order = mapOf('k' to 0, 'o' to 1, 't' to 2, 'l' to 3, 'i' to 4, 'n' to 5)\nval kotlin = mapOf('k' to 'o', 'o' to 't', 't' to 'l', 'l' to 'i', 'i' to 'n', 'n' to 'k')\nval graph = Array(6){ArrayList>()}\n\nvar ptr = 0\nval euler = IntArray(100003)\n\nfun dfs(u: Int){\n for(i in graph[u].indices)\n if(graph[u][i].third){\n graph[u][i] = Triple(graph[u][i].first, graph[u][i].second, false)\n dfs(graph[u][i].first)\n euler[ptr++] = graph[u][i].second + 1\n }\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n for(i in 0 until n) {\n val piece = readLine()!!\n graph[order.getOrDefault(piece[0], 6)].add(Triple(order[kotlin[piece.last()]]!!, i, true))\n }\n dfs(0)\n for(i in n-1 downTo 0)\n print(\"${euler[i]} \")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e41cd3cf81b640c99e9b2a53b2085f5c", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main(){val n=readLine()!!.toInt() val g=Array(6){ArrayList>()} (1..n).forEach{val s=readLine()!! val f=\"kotlin\".indexOf(s[0]) val t=(f+s.length)%6 g[f].add(t to it)}val s=ArrayList()fun r(n:Int) {while (!g[n].isEmpty()) {val (t,i) = g[n].removeAt(g[n].size-1) r(t) s.add(i)}}r(0) println(s.reversed().joinToString(\" \"))}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "834df7fc3ca7affb66807a20734534a4", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "\nimport java.util.ArrayList\nimport java.util.Collections\nimport java.util.Comparator\nimport java.util.HashMap\nimport java.util.HashSet\nimport java.util.Scanner\n\n internal var g:Array> = Array>(6){i -> arrayOf()}\n internal var iter = IntArray(6)\n internal var used = BooleanArray(10)\n class Pair {\n internal var to:Int = 0\n internal var id:Int = 0\n constructor() {\n }\n constructor(_to:Int, _id:Int) {\n to = _to\n id = _id\n }\n internal fun compareTo(p:Pair):Int {\n if (to == p.to && id == p.id) return 0\n if (to < p.to || (to == p.to && id < p.id)) return -1\n return 1\n }\n fun equals(p:Pair):Boolean {\n return to == p.to && id == p.id\n }\n public override fun hashCode():Int {\n return to + id * 6\n }\n }\n fun encode(p:Pair):String {\n return (p.to).toString() + \" \" + (p.id).toString()\n }\n fun decode(s:String):Pair {\n val m = s.indexOf(\" \")\n return Pair(Integer.valueOf(s.substring(0, m)), Integer.valueOf(s.substring(m + 1, s.length)))\n }\n internal fun dfs(v:Int) {\n while (iter[v] < g[v].size())\n {\n val p = decode(g[v].get(iter[v]))\n iter[v]++\n //\t\t\tg[v].remove(encode(p));\n //\t\t\tg[p.to].remove(encode(new Pair(v, p.id)));\n dfs(p.to)\n print(p.id + 1)\n print(\" \")\n }\n }\n fun main(args:Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n //g = arrayOfNulls>(6)\n for (i in 0..5)\n g[i] = ArrayList()\n val target = \"kotlin\"\n for (i in 0 until n)\n {\n val s = `in`.next()\n var a = target.indexOf(s.get(0).toInt(), 0)\n val b = target.indexOf(s.get(s.length - 1).toInt(), 0)\n a = (a + 5) % 6\n //\t\t\tg[a].add(encode(new Pair(b, i)));\n g[b].add(encode(Pair(a, i)))\n }\n dfs(5)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6d1b88d20eae285bdffc8bf12c6dffa1", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toFloat()\n println( if (n.rem(2) > 0) n.pow(n/2) else 0 )\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fa6bae8e70b22cde479b7916576d4c4a", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (a, b) = br.readLine().split(\" \").map { it.toInt()}\n var i = a\n var candles = a\n while (i >= b){\n candles += i/b\n i = i/b + i % b\n }\n\n println(candles)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "97217ffa02183ebe328b7fdf1c4121c5", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val (given, left, rite) = readLine().split(' ').map{ it.toInt()}\n val mins = (1 shl left) + (given - left - 1)\n val maxs = (1 shl rite) - 1 + (1 shl rite - 1) * (given - rite)\n println(\"$mins $maxs\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c78c77071e4467cfad187b9cc3d13346", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (x,y) = readLine()!!.split(' ').take(2).map{it.toLong()}\n val n = readLine()!!.toLong()\n val nums= arrayOf(x-y,x,y)\n val (div,mod)=(n/3) to n%3\n val sign = -1*((div%2)*2-1)\n val ans = nums[mod]*sign\n println(if (ans<0) 1000000007+ans else ans)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a71a385ba1d4aa88351569c784c8d9df", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n const val M = 1000000007\n val (x,y) = readLine()!!.split(' ').take(2).map{it.toLong()}\n val n = readLine()!!.toLong()\n val nums= arrayOf(x-y,x,y)\n val (div,mod)=(n/3L) to n.toInt()%3\n val sign = -1L*((div%2L)*2L-1L)\n val ans = nums[mod]*sign\n println(if (ans<0) (M+ans)%M else ans)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "da64fb7097cec0a95a86a9b129b251d0", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package ru.dmpolyakov.hackerrank\n\n\nobject MainActivity {\n\n @JvmStatic\n fun main(args: Array) {\n\n val a = readLine()!!.splitToIntArray()\n val x = readLine()!!.toCharArray()\n val n = a[1]\n\n for (i in 0 until x.size) {\n var m = i\n for (j in i + 1 until x.size) {\n if (x[j] < x[m]) {\n m = j\n }\n }\n val q = x[i]\n x[i] = x[m]\n x[m] = q\n }\n\n var s = \"\"\n\n s += x[0]\n\n for (i in 1 until x.size) {\n val c = x[i]\n if ((c - s.last()) < 2) continue\n s += c\n }\n\n if (s.length < k) {\n System.out.println(-1)\n } else {\n s = s.substring(0 until k)\n var ans = 0\n for (c in s) {\n ans += c.toInt() - 'a'.toInt() + 1\n }\n System.out.println(ans)\n }\n\n\n }\n\n private fun String.splitToIntArray(): IntArray {\n val n = length\n if (n == 0) return IntArray(0) // EMPTY\n var res = IntArray(4)\n var m = 0\n var i = 0\n while (true) {\n var cur = 0\n var neg = false\n var c = get(i) // expecting number, IOOB if there is no number\n if (c == '-') {\n neg = true\n i++\n c = get(i) // expecting number, IOOB if there is no number\n }\n while (true) {\n val d = c.toInt() - '0'.toInt()\n require(d >= 0 && d <= 9) { \"Unexpected character '$c' at $i\" }\n require(cur >= Integer.MIN_VALUE / 10) { \"Overflow at $i\" }\n cur = cur * 10 - d\n require(cur <= 0) { \"Overflow at $i\" }\n i++\n if (i >= n) break\n c = get(i)\n if (c == ' ') break\n }\n if (m >= res.size) res = res.copyOf(res.size * 2)\n res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { \"Overflow at $i\" } }\n if (i >= n) break\n i++\n }\n if (m < res.size) res = res.copyOf(m)\n return res\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5dea3a7e4358956edae09708bcf13ff2", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package ru.dmpolyakov.hackerrank\n\nimport java.util.*\n\n\nobject MainActivity {\n\n @JvmStatic\n fun main(args: Array) {\n\n val cin = Scanner(System.`in`)\n\n val n = cin.nextInt()\n val k = cin.nextInt()\n cin.nextLine()\n val x = cin.nextLine().toCharArray()\n\n for (i in 0 until x.size) {\n var m = i\n for (j in i + 1 until x.size) {\n if (x[j] < x[m]) {\n m = j\n }\n }\n val q = x[i]\n x[i] = x[m]\n x[m] = q\n }\n\n var s = \"\"\n\n s += x[0]\n\n for (i in 1 until x.size) {\n val c = x[i]\n if ((c - s.last()) < 2) continue\n s += c\n }\n\n if (s.length < k) {\n System.out.println(-1)\n } else {\n s = s.substring(0 until k)\n var ans = 0\n for (c in s){\n ans += c.toInt() - 'a'.toInt() + 1\n }\n System.out.println(ans)\n }\n\n\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c349d92acb1fd4d3766aa10d3c9d9dfc", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "object MainActivity {\n\n @JvmStatic\n fun main(args: Array) {\n\n val cin = Scanner(System.`in`)\n\n val n = cin.nextInt()\n val k = cin.nextInt()\n cin.nextLine()\n val x = cin.nextLine().toCharArray()\n\n for (i in 0 until x.size) {\n var m = i\n for (j in i + 1 until x.size) {\n if (x[j] < x[m]) {\n m = j\n }\n }\n val q = x[i]\n x[i] = x[m]\n x[m] = q\n }\n\n var s = \"\"\n\n s += x[0]\n\n for (i in 1 until x.size) {\n val c = x[i]\n if ((c - s.last()) < 2) continue\n s += c\n }\n\n if (s.length < k) {\n System.out.println(-1)\n } else {\n s = s.substring(0 until k)\n var ans = 0\n for (c in s){\n ans += c.toInt() - 'a'.toInt() + 1\n }\n System.out.println(ans)\n }\n\n\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "50c4d89aebc54317855660bc54debf63", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "object MainActivity {\n\n @JvmStatic\n fun main(args: Array) {\n\n val a = readLine()!!.splitToIntArray()\n val x = readLine()!!.toCharArray()\n val k = a[1]\n\n for (i in 0 until x.size) {\n var m = i\n for (j in i + 1 until x.size) {\n if (x[j] < x[m]) {\n m = j\n }\n }\n val q = x[i]\n x[i] = x[m]\n x[m] = q\n }\n\n var s = \"\"\n\n s += x[0]\n\n for (i in 1 until x.size) {\n val c = x[i]\n if ((c - s.last()) < 2) continue\n s += c\n }\n\n if (s.length < k) {\n System.out.println(-1)\n } else {\n s = s.substring(0 until k)\n var ans = 0\n for (c in s) {\n ans += c.toInt() - 'a'.toInt() + 1\n }\n System.out.println(ans)\n }\n\n\n }\n\n private fun String.splitToIntArray(): IntArray {\n val n = length\n if (n == 0) return IntArray(0) // EMPTY\n var res = IntArray(4)\n var m = 0\n var i = 0\n while (true) {\n var cur = 0\n var neg = false\n var c = get(i) // expecting number, IOOB if there is no number\n if (c == '-') {\n neg = true\n i++\n c = get(i) // expecting number, IOOB if there is no number\n }\n while (true) {\n val d = c.toInt() - '0'.toInt()\n require(d >= 0 && d <= 9) { \"Unexpected character '$c' at $i\" }\n require(cur >= Integer.MIN_VALUE / 10) { \"Overflow at $i\" }\n cur = cur * 10 - d\n require(cur <= 0) { \"Overflow at $i\" }\n i++\n if (i >= n) break\n c = get(i)\n if (c == ' ') break\n }\n if (m >= res.size) res = res.copyOf(res.size * 2)\n res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { \"Overflow at $i\" } }\n if (i >= n) break\n i++\n }\n if (m < res.size) res = res.copyOf(m)\n return res\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b910434f93aa4ae7c02990eb7fa41959", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package library\n\nimport java.io.*\nimport java.util.*\n\nclass MinQueue {\n val q = ArrayDeque()\n val minq = ArrayDeque()\n\n fun offer(x: Int) {\n q.offer(x)\n while (minq.isNotEmpty() && minq.peekLast() > x)\n minq.pollLast()\n minq.offer(x)\n }\n\n fun poll() {\n if (minq.peekFirst() == q.pollFirst())\n minq.pollFirst()\n }\n\n fun min() = minq.peekFirst()!!\n}\n\nclass Solution : Runnable {\n override fun run() {\n\n val (n, m, a, b) = nextInts(4)\n val (g0, x, y, z) = nextInts(4)\n var g: Long = g0.toLong()\n\n val prefix = Array(n) { IntArray(m - b + 1) }\n for (r in 0 until n) {\n val row_mins = prefix[r]\n val q = MinQueue()\n for (c in 0 until b) {\n q.offer(g.toInt())\n g = ((g * x + y) % z + z) % z\n }\n row_mins[0] = q.min()\n for (c in b until m) {\n q.poll()\n q.offer(g.toInt())\n g = ((g * x + y) % z + z) % z\n row_mins[c - b + 1] = q.min()\n }\n }\n\n var ans: Long = 0\n for (c in 0 until prefix[0].size) {\n val q = MinQueue()\n for (i in 0 until a)\n q.offer(prefix[i][c])\n \n ans += q.min()\n for (r in a until n) {\n q.poll()\n q.offer(prefix[r][c])\n g = ((g * x + y) % z + z) % z\n ans += q.min()\n }\n }\n println(ans)\n }\n}\n\nfun console(vararg objects: Any) {\n if (!OJ) {\n out.println(Arrays.deepToString(objects))\n out.flush()\n }\n}\n\ninternal fun abs(x: Int): Int {\n return if (x < 0) -x else x\n}\n\ninternal fun max(a: Int, b: Int): Int {\n return if (a > b) a else b\n}\n\ninternal fun min(a: Int, b: Int): Int {\n return if (a < b) a else b\n}\n\ninternal fun abs(x: Long): Long {\n return if (x < 0) -x else x\n}\n\ninternal fun max(a: Long, b: Long): Long {\n return if (a > b) a else b\n}\n\ninternal fun min(a: Long, b: Long): Long {\n return if (a < b) a else b\n}\n\ninternal var OJ = System.getProperty(\"ONLINE_JUDGE\") != null\n\nclass InputReader {\n\n private var stream: InputStream\n private val buf = ByteArray(2048)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private var filter: SpaceCharFilter? = null\n\n constructor() {\n this.stream = System.`in`\n }\n\n constructor(stream: InputStream) {\n this.stream = stream\n }\n\n constructor(filter: SpaceCharFilter) {\n this.stream = System.`in`\n this.filter = filter\n }\n\n constructor(stream: InputStream, filter: SpaceCharFilter) {\n this.stream = stream\n this.filter = filter\n }\n\n fun read(): Int {\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream!!.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun nextChar(): Char {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n return c.toChar()\n }\n\n fun nextDigit(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n return c - '0'.toInt()\n }\n\n fun nextInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var negative = false\n if (c == '-'.toInt()) {\n negative = true\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return if (negative) -res else res\n }\n\n fun nextInts(N: Int): IntArray {\n val nums = IntArray(N)\n for (i in 0 until N)\n nums[i] = nextInt()\n return nums\n }\n\n fun nextLongs(N: Int): LongArray {\n val nums = LongArray(N)\n for (i in 0 until N)\n nums[i] = nextLong()\n return nums\n }\n\n fun nextUnsignedInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var res = 0\n do {\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res\n }\n\n fun nextLong(): Long {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var negative = false\n if (c == '-'.toInt()) {\n negative = true\n c = read()\n }\n var res: Long = 0\n do {\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return if (negative) -res else res\n }\n\n fun nextUnsignedLong(): Long {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var res: Long = 0\n do {\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return res\n }\n\n fun nextDouble(): Double {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn: Long = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res: Long = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += (c - '0'.toInt()).toLong()\n c = read()\n } while (!(c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1 || c == '.'.toInt()))\n\n if (c != '.'.toInt()) {\n return (res * sgn).toDouble()\n }\n c = read()\n\n var aft: Long = 0\n var len = 1\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n aft *= 10\n len *= 10\n aft += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n\n return res * sgn + aft / (1.0 * len)\n }\n\n fun nextLine(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isEndChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return if (filter != null) filter!!.isSpaceChar(c) else c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1\n }\n\n fun isEndChar(c: Int): Boolean {\n return if (filter != null) filter!!.isSpaceChar(c) else c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1\n }\n\n operator fun next(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun nextChars(): CharArray {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n\n val chars = CharArray(res.length)\n res.getChars(0, chars.size, chars, 0)\n return chars\n }\n\n fun nextIntMatrix(rows: Int, cols: Int): Array {\n val matrix = Array(rows) { IntArray(cols) }\n for (i in 0 until rows)\n for (j in 0 until cols)\n matrix[i][j] = nextInt()\n return matrix\n }\n\n fun nextLongMatrix(rows: Int, cols: Int): Array {\n val matrix = Array(rows) { LongArray(cols) }\n for (i in 0 until rows)\n for (j in 0 until cols)\n matrix[i][j] = nextLong()\n return matrix\n }\n\n fun nextCharMap(rows: Int, cols: Int): Array {\n val matrix = Array(rows) { CharArray(cols) }\n for (i in 0 until rows)\n for (j in 0 until cols)\n matrix[i][j] = nextChar()\n return matrix\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n}\n\nvar reader = InputReader(System.`in`)\nvar out = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n\nfun next() = reader.next()\nfun nextLine() = reader.nextLine()\nfun nextChar() = reader.nextChar()\nfun nextChars() = reader.nextChars()\nfun nextCharMap(R: Int, C: Int) = reader.nextCharMap(R, C)\nfun nextDigit() = reader.nextDigit()\nfun nextInt() = reader.nextInt()\nfun nextInts(N: Int) = reader.nextInts(N)\nfun nextIntMatrix(R: Int, C: Int) = reader.nextIntMatrix(R, C)\nfun nextLong() = reader.nextLong()\nfun nextLongs(N: Int) = reader.nextLongs(N)\nfun nextUnsignedLong() = reader.nextUnsignedLong()\nfun nextLongMatrix(R: Int, C: Int) = reader.nextLongMatrix(R, C)\nfun nextDouble() = reader.nextDouble()\n\nfun main() {\n val main = Thread(null, Solution(), \"Main\", (1 shl 28).toLong())\n main.start()\n main.join()\n out.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7fb62e7af1471ec09adbf9f7850de63b", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "package tasks.t509a\n\nfun tableMaximum(n: Int): Int {\n val matrix = IntArray(n * n) { 1 }\n\n for (i in 1 until n) {\n for (j in 1 until n) {\n matrix[i * n + j] = matrix[(i - 1) * n + j] + matrix[i * n + j - 1]\n }\n }\n return matrix[n * n - 1]\n}\n\nfun main(args: Array) {\n println(tableMaximum(readLine()!!.toInt()))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "350ff613b9da0a2cac7e5c6cbedf2454", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " val input = readLine()!!\n val splitInput = input.split(\" \")\n\n val price = splitInput[0].toInt()\n val solderMoney = splitInput[1].toInt()\n val count = splitInput[2].toInt()\n\n var sum = 0\n\n for(i in 1..count){\n sum += i*price\n }\n\n if (solderMoney - sum>= 0 ){\n print(0)\n }else {\n print (sum - solderMoney)\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "05f79208dd3a739374d39313e6894003", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val ph=\"qwertyuiopasdfghjkl;zxcvbnm,./\"\n var dir = readLine().toString()\n var a = readLine().toString()\n for(index in 0..(a.length-1))\n {\n if(dir=='R')\n a[incdex].set(ph.indexOf[a[index]-1)\n else\n a[incdex].set(ph.indexOf(a[index)+1)\n }\n println(a)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7de1743e1b88584eef2ec4210480cbab", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Kotlin 1.4", "source_code": "fun main() {\r\n val task = readLine()!!.toInt()\r\n for (i in 1..task) {\r\n// readLine()\r\n// var s = readLine()!!.toString()\r\n// var iSub = 0\r\n// val arr1 = ArrayList()\r\n// val arr2 = ArrayList()\r\n// for (j in s.indices) {\r\n// if (s[j] == ' ') {\r\n// arr1.add(s.substring(iSub, j).toInt())\r\n// iSub = j + 1\r\n// }\r\n// }\r\n// arr1.add(s.substring(iSub, s.length).toInt())\r\n// iSub = 0\r\n// s = readLine()!!.toString()\r\n// for (j in s.indices) {\r\n// if (s[j] == ' ') {\r\n// arr2.add(s.substring(iSub, j).toInt())\r\n// iSub = j + 1\r\n// }\r\n// }\r\n// arr2.add(s.substring(iSub, s.length).toInt())\r\n val input = readLine()!!.toDouble()\r\n val x1 = input.pow(1.0 / 3)\r\n val x2 = input.pow(1.0 / 2)\r\n var x3 = input.pow(1.0 / 6)\r\n print(\"$x1 $x2 $x3 ${x1.toInt() + x2.toInt() - x3.toInt()}\\n\")\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7e1b7fe206259d5c9047baa2f12199b4", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "Kotlin 1.5", "source_code": "fun main() {\r\n repeat(readLine()!!.toInt()) {\r\n val n = readLine()!!.toLong()\r\n var i = 0L\r\n val res = mutableSetOf()\r\n while(i * i < n) {\r\n i++\r\n if(i * i <= n) res.add(i * i)\r\n if(i * i * i<= n) res.add(i * i * i)\r\n }\r\n println(res.size())\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "67045d9edf6e69e7d2f826cbd89aefab", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "Kotlin 1.4", "source_code": "fun main() {\r\n val task = readLine()!!.toInt()\r\n for (i in 1..task) {\r\n// readLine()\r\n// var s = readLine()!!.toString()\r\n// var iSub = 0\r\n// val arr1 = ArrayList()\r\n// val arr2 = ArrayList()\r\n// for (j in s.indices) {\r\n// if (s[j] == ' ') {\r\n// arr1.add(s.substring(iSub, j).toInt())\r\n// iSub = j + 1\r\n// }\r\n// }\r\n// arr1.add(s.substring(iSub, s.length).toInt())\r\n// iSub = 0\r\n// s = readLine()!!.toString()\r\n// for (j in s.indices) {\r\n// if (s[j] == ' ') {\r\n// arr2.add(s.substring(iSub, j).toInt())\r\n// iSub = j + 1\r\n// }\r\n// }\r\n// arr2.add(s.substring(iSub, s.length).toInt())\r\n val input = readLine()!!.toDouble()\r\n val x1 = Math.cbrt(input)\r\n val x2 = sqrt(input)\r\n print(\"${x1.toInt() + x2.toInt() - 1}\\n\")\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8d2e81dae2cfabba3c45a985c709541f", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val result = 0\n while (m > n)\n {\n if (m % 2 == 0)\n {\n m = m / 2\n result++\n }\n else\n {\n m++\n result++\n }\n }\n if (n > m)\n {\n result += Math.abs(n - m)\n }\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c51e31f36a9bf9572d80e01a8cf5f70a", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val k = r.readLine()!!.toInt()\n val (a, b) = r.readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val c = 7-b\n println(\"${c/ gcd(c, 6)}/${6/ gcd(c, 6)}\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d9a4b96c12301e6283d73d1f7e6505f2", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{ var c=0\n\tvar s= readLine()!!\n\tfor(i in 1..5)\n\t{\n\t\tvar n= readLine()!!\n\t\tif(s[0]==n[0]||s[1]==n[1])\n\t\t\t{\n\t\t\t\tc=1\n\t\t\t\t\n\t\t\t}\n\t}\n\t\n\tprintln(if(c==1) \"YES\" else \"NO\")\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b88cd127761711e0815c934810262dc5", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\nval INF_F = 1e-6\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val a = reader.nextArrayInt(n)\n\n val count0 = a.filterIndexed { index, value -> index in l..r && value == 0 }.count()\n var ans = n - min(r - l + 1 - count0, count0)\n for (i in 0 until n) {\n val x0 = a.filterIndexed { index, value -> index in 0..i && value == 0 }.count()\n val x1 = a.filterIndexed { index, value -> index in i + 1 until n && value == 1 }.count()\n ans = max(ans, x0 + x1)\n }\n writer.println(ans)\n}\n\nfun gcd(a: Int, b: Int): Int {\n return if (b == 0) a else gcd(b, a % b)\n}\n\nclass InputReader(stream: InputStream) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c073ea652fbd93b3676415766ff6c6be", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashSet\n\nclass TestClass {\n\n companion object {\n\n private val vowels = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u'))\n private val noRestrictions = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u', 'n'))\n\n private fun isCorrect(str: String): Boolean {\n str.forEachIndexed() { ind, c ->\n if (!noRestrictions.contains(c)) {\n if (ind == str.length - 1) return false\n else if (!vowels.contains(str[ind + 1])) return false\n }\n }\n\n return true\n }\n\n @JvmStatic\n fun main(args: Array) {\n val scan = Scanner(System.`in`)\n\n val str = scan.nextLine().trim()\n\n println(if (isCorrect(str)) \"YES\" else \"NO\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e1b498dd8a6574ec3b512e0763a9d864", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashSet\n\npublic class Main {\n\n public companion object {\n\n private val vowels = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u'))\n private val noRestrictions = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u', 'n'))\n\n private fun isCorrect(str: String): Boolean {\n str.forEachIndexed() { ind, c ->\n if (!noRestrictions.contains(c)) {\n if (ind == str.length - 1) return false\n else if (!vowels.contains(str[ind + 1])) return false\n }\n }\n\n return true\n }\n\n @JvmStatic\n public fun main(args: Array) {\n val scan = Scanner(System.`in`)\n\n val str = scan.nextLine().trim()\n\n println(if (isCorrect(str)) \"YES\" else \"NO\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "df80fa8aa14ef3213ee2769921783c8f", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashSet\n\nclass Main {\n\n companion object {\n\n private val vowels = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u'))\n private val noRestrictions = HashSet(arrayListOf('a', 'e', 'i', 'o', 'u', 'n'))\n\n private fun isCorrect(str: String): Boolean {\n str.forEachIndexed() { ind, c ->\n if (!noRestrictions.contains(c)) {\n if (ind == str.length - 1) return false\n else if (!vowels.contains(str[ind + 1])) return false\n }\n }\n\n return true\n }\n\n @JvmStatic\n fun main(args: Array) {\n val scan = Scanner(System.`in`)\n\n val str = scan.nextLine().trim()\n\n println(if (isCorrect(str)) \"YES\" else \"NO\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8494f2e59dff5d57d4753216cdaee2d0", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() {\n output {\n val s = readLn()\n val t = readLn()\n\n val open = ArrayDeque()\n open.add(Entry(0, 0, 0, 0, null))\n val closed = hashSetOf(State(0, 0, 0))\n\n val ans = run {\n while(true) {\n val (i, j, bal, path) = open.remove()\n if (i == s.length && j == t.length && bal == 0)\n return@run path.toString()\n for (c in \"()\") {\n val nbal = bal + if (c == '(') 1 else -1\n if (nbal !in 0..200) continue\n val ni = if (i < s.length && c == s[i]) i + 1 else i\n val nj = if (j < t.length && c == t[j]) j + 1 else j\n if (closed.add(State(ni, nj, nbal))) {\n open.add(Entry(ni, nj, nbal, path + c))\n }\n }\n }\n \"\"\n }\n\n println(ans)\n }\n}\n\ndata class State(@JvmField val i: Int, @JvmField val j: Int,@JvmField val bal: Int) {\n override fun hashCode(): Int = i.times(201).plus(j).times(201).plus(bal).hash()\n}\ndata class Entry(@JvmField val i: Int, @JvmField val j: Int, @JvmField val bal: Int, @JvmField val path: CharPathNode?)\n\nclass CharPathNode(@JvmField val data: Char, @JvmField val parent: CharPathNode? = null) {\n inline operator fun plus(childData: Char) = CharPathNode(childData, this)\n\n override fun toString() = buildString {\n var node = this@CharPathNode\n while(true) {\n append(node.data)\n node = node.parent ?: break\n }\n reverse()\n }\n}\n\ninline operator fun CharPathNode?.plus(childData: Char) = CharPathNode(childData, this)\nfun CharPathNode?.toString() = this?.toString().orEmpty()\n\nfun splitmix32(seed: Int): Int {\n var x = seed - 1640531527\n x = (x xor (x ushr 16)) * 0x7feb352d\n x = (x xor (x ushr 15)) * 0x846ca68b.toInt()\n return (x xor (x ushr 16))\n}\n@JvmField val nonce32 = random.nextInt()\nfun Int.hash() = splitmix32(nonce32 xor this)\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "210928d641d8943996e74ea6b38c810f", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n\tvar (a,b,c) = readLine()!!.split(' ').map { it.toInt() }\n\tvar answer = 0\n\tif(abs(a-b)>=1) answer += 1\n\tanswer += (c*2 + min(a,b)*2)\n\n\tprintln(answer.toUInt())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9a533818d707472429d635f1f60abdd5", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toLong() }\n println(2*min(a, b) + 2*c + (if (a != b) 1 else 0))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fcd80e4d0bd4de0d7ee5f9183adebf2c", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package a\n\nimport java.util.*\n\nfun main() {\n\n val scanner = Scanner(System.`in`)\n\n val t = scanner.nextLine().split(' ').map { it.toInt() }\n\n val first = t[0] * t[1] + 2 * t[3]\n val second = t[0] * t[2] + 2 * t[4]\n\n when {\n first < second -> println(\"First\")\n first > second -> println(\"Second\")\n else -> println(\"Friendship\")\n }\n\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "332b0ed1db80e3a7abda16b4cc187854", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tval input = readLine()!!.toInt()\n\tprintln(getVariants(input))\n}\n\nfun getVariants(numberOfEmployee: Int): Int {\n\tvar numOfVariants = 0\n\n\tif (numberOfEmployee < 2) return 0\n\n\tif (numberOfEmployee % 3 != 0 && numberOfEmployee % 2 != 0) return 1\n\n\tfor (i in 0 until numberOfEmployee) {\n\t\tif ((numberOfEmployee - i) % i == 0) {\n\t\t\tnumOfVariats += 1\n\t\t}\n\t}\n\n\treturn numOfVariants\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "82cc08f03b24da695cbbf11c0456ef0f", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import Starter.ni\nimport Starter.nia\nimport java.util.*\n\nfun main() {\n var n = ni();\n var a = nia(n)\n var points = 0L\n for(i in 1 until n){\n if(a[i] == 1){\n if(a[i-1] == 2) points += 3\n if(a[i-1] == 3) points += 4\n }\n if(a[i] == 2){\n if(a[i-1] == 1) points += 3\n if(a[i-1] == 3){\n println(\"Infinite\")\n return\n }\n }\n if(a[i] == 3){\n if(a[i-1] == 1) points += 4\n if(a[i-1] == 2){\n println(\"Infinite\")\n return\n }\n }\n }\n for(i in 2 until n){\n if(a[i] == 2 && a[i-1] == 1 && a[i-2] == 3) points--\n }\n println(\"Finite\")\n println(points)\n}\n\nvar input = Scanner(System.`in`)\n\nfun ni() = input.nextInt()\n\nfun nia(n: Int) = Array(n) { ni() }\n\nfun nim(n: Int, m: Int) = Array(n) { nia(m) }\n\nfun nl() = input.nextLong()\n\nfun nla(n: Int) = Array(n) { nl() }\n\nfun nlm(n: Int, m: Int) = Array(n) { nla(m) }\n\nfun ns() = input.next()\n\nfun nsa(n: Int) = Array(n) { ns() }\n\nfun println(arr: Array<*>) = println(arr.fold(\"\") { r, n -> \"$r$n \" })", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c668c715eb95e9be477183cdcc4dc7a4", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import Starter.ni\nimport Starter.nia\nimport java.util.*\n\nfun main() {\n var n = ni();\n var a = nia(n)\n var points = 0L\n for(i in 1 until n){\n if(a[i] == 1){\n if(a[i-1] == 2) points += 3\n if(a[i-1] == 3) points += 4\n }\n if(a[i] == 2){\n if(a[i-1] == 1) points += 3\n if(a[i-1] == 3){\n println(\"Infinite\")\n return\n }\n }\n if(a[i] == 3){\n if(a[i-1] == 1) points += 4\n if(a[i-1] == 2){\n println(\"Infinite\")\n return\n }\n }\n }\n println(\"Finite\")\n println(points)\n}\n\nvar input = Scanner(System.`in`)\n\nfun ni() = input.nextInt()\n\nfun nia(n: Int) = Array(n) { ni() }\n\nfun nim(n: Int, m: Int) = Array(n) { nia(m) }\n\nfun nl() = input.nextLong()\n\nfun nla(n: Int) = Array(n) { nl() }\n\nfun nlm(n: Int, m: Int) = Array(n) { nla(m) }\n\nfun ns() = input.next()\n\nfun nsa(n: Int) = Array(n) { ns() }\n\nfun println(arr: Array<*>) = println(arr.fold(\"\") { r, n -> \"$r$n \" })", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c97b272189d1f4050377c30be3923fc1", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import Starter.ni\nimport Starter.nia\nimport java.util.*\n\nfun main() {\n var n = ni();\n var a = nia(n)\n var points = 0L\n for(i in 1 until n){\n if(a[i] == 1){\n if(a[i-1] == 2) points += 3\n if(a[i-1] == 3) points += 4\n }\n if(a[i] == 2){\n if(a[i-1] == 1) points += 3\n if(a[i-1] == 3){\n println(\"Infinite\")\n return\n }\n }\n if(a[i] == 3){\n if(a[i-1] == 1) points += 4\n if(a[i-1] == 2){\n println(\"Infinite\")\n return\n }\n }\n }\n /*for(i in 2 until n){\n if(a[i] == 2 && a[i-1] == 1 && a[i-2] == 3) points--\n }*/\n println(\"Finite\")\n println(points)\n}\n\nvar input = Scanner(System.`in`)\n\nfun ni() = input.nextInt()\n\nfun nia(n: Int) = Array(n) { ni() }\n\nfun nim(n: Int, m: Int) = Array(n) { nia(m) }\n\nfun nl() = input.nextLong()\n\nfun nla(n: Int) = Array(n) { nl() }\n\nfun nlm(n: Int, m: Int) = Array(n) { nla(m) }\n\nfun ns() = input.next()\n\nfun nsa(n: Int) = Array(n) { ns() }\n\nfun println(arr: Array<*>) = println(arr.fold(\"\") { r, n -> \"$r$n \" })", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "97914217e4ceff5f455157aab1abc2cd", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "package com.lstr.codeforces\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\nprivate fun readIntsArr() = ArrayList(readInts()) // ArrayList of ints\n\nprivate val MX = 200005\nprivate val MOD = 1000000007\nprivate val SZ = 1 shl 18\nprivate val INF = (1e18).toLong()\n\nprivate fun add(a: Int, b: Int) = (a + b) % MOD // from tourist :o\nprivate fun sub(a: Int, b: Int) = (a - b + MOD) % MOD\nprivate fun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()\n\n\nprivate fun solve(){\n val players = readLn()\n println(if(players.contains(\"1111111\")||players.contains(\"0000000\")) \"YES\" else \"NO\")\n}\n\nfun main(){\n val t = 1 // # of test cases\n for (i in 1..t) {\n solve()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0df3dc29ed5f0cfecd4944643eca0f53", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val players = readLine()!!\n val stringMatch = Regex(\"([0-1])\\1\\1\\1\\1\\1\\1+\")\n print(if(players.contains(stringMatch)) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e36133ef6a37094c1c7ee98e17b09dab", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\n\n \n \n \n \n \n \n \n \n \n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7c531a83b554b0ea37c052955f442526", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n println(Regex(\"xxx+\").findAll(string).fold(0) { total, matchResult -> total + matchResult.value.length - 2})\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4ed860399fe65295efb4df88839fa06d", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package n481div3A\n\n\nfun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval file = readLine()!!\n\n\tvar count = 0\n\tvar ans = 0\n\tfile.forEach {\n\t\tcount += if (it == 'x') 1 else 0\n\t\tif (it != 'x') {\n\t\t\tans += if( count >= 3) count - 2 else 0\n\t\t\tcount = 0\n\t\t}\n\t}\n\n\tans += if (count >= 3) count - 2 else 0\n\n\tprintln(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8015306cb406ebc57d150e9e3412533e", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package n481div3A\n\n\nclass B\nfun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval file = readLine()!!\n\n\tvar count = 0\n\tvar ans = 0\n\tfor (c in file) {\n\t\tcount += if (c == 'x') 1 else 0\n\t\tif (c != 'x') {\n\t\t\tans += if (count >= 3) count - 2 else 0\n\t\t\tcount = 0\n\t\t}\n\t}\n\tans += if (count >= 3) count - 2 else 0\n\n\tprintln(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "613d7f22d91603dedeaf76368d82831e", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.*\n\nfun main() {\n output {\n val n = readInt()\n\n var pd = ModInt(2).pow(n)\n var ans = pd - 1\n\n val factorial = ModIntArray(2*n + 1).also {\n it[0] = ModInt(1)\n for(i in 1..2*n) {\n it[i] = it[i-1] * i\n }\n }\n\n val invf = ModIntArray(n + 1) {\n factorial[it].inv_unmemoized()\n }\n\n for(i in n..2*n) {\n ans += pd\n pd -= factorial[i] * invf[n] * invf[i - n]\n pd *= 2\n }\n\n println(ans)\n }\n}\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\n\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\n\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base)\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt((this umod MODINT_BASE))\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n inline operator fun plus(other: ModInt) = plus(other.int) // MODINT_BASE < 2^30\n inline operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n inline operator fun inc() = plus(1)\n\n inline operator fun minus(other: ModInt) = minus(other.int)\n inline operator fun minus(other: Int) = (int - other).toModInt()\n inline operator fun dec() = minus(1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) exponent umod MODINT_BASE - 1 else exponent // assumes MODINT_BASE is prime\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_BASE - 2) // assumes MODINT_BASE is prime\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n\n override fun contains(element: ModInt): Boolean = any { it == element }\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun Iterable.sum() = fold(ModInt(0), ModInt::plus)\nfun Sequence.sum() = fold(ModInt(0), ModInt::plus)\nfun Iterable.product() = fold(ModInt(1), ModInt::times)\nfun Sequence.product() = fold(ModInt(1), ModInt::times)\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\nfun iprintln(o: Any?) { println(o) } // immediate println for interactive, bypasses output{} blocks", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b3a9a1fa5ff62d3f7777728e5c681689", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport java.util.Arrays\n\nfun main(args:Array)\n{\n var sc=Scanner(System.`in`)\n val n : Int = sc.nextInt()\n val a = IntArray(n)\n for(i in 0 until n)\n {\n a[i] = sc.nextInt()\n }\n Arrays.sort(a)\n for(i in 0 until n)\n {\n print(a[i]+\" \")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4220dc63ab9db8572e10c27be2bb7168", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport java.util.Arrays\n\nfun main(args:Array)\n{\n var sc=Scanner(System.`in`)\n val n: Int=sc.nextInt()\n val a:IntArray(n)\n for(i in 0 until n) \n {\n a[i]=sc.nextInt()\n }\n Arrays.sort(a)\n for(i in 0 until n) \n {\n print(a[i]+\" \")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e88ec7a4031161646476ef18b6f3f3ba", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n readLine()\n println(readLine()!!.split(\" \").map(String::toInt).sorted)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9fc6d6128165995207a8ce99e15b82f6", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.*;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.nio.charset.IllegalCharsetNameException;\nimport java.util.*;\n\npublic class Main {\n\n\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static PrintWriter out = new PrintWriter(System.out);\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) {\n st = new StringTokenizer(br.readLine());\n }\n return st.nextToken();\n }\n\n static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n static void solve() throws IOException {\n int t = nextInt();\n for (int tc = 0; tc < t; tc++) {\n int n = nextInt();\n int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n Arrays.sort(a);\n int vals[] = new int[n];\n int x[] = new int[n];\n int ptr = 0;\n int mda = 0;\n while (ptr < n) {\n int j = ptr;\n while (j < n && a[j] == a[ptr]) {\n j++;\n }\n x[mda] = a[ptr];\n vals[mda++] = j - ptr;\n ptr = j;\n }\n int vl = 0, vr = n + 1;\n while (vl < vr - 1) {\n int vm = (vl + vr) / 2;\n int sum = 0;\n for (int i = 0; i < mda; i++) {\n sum += Math.min(vals[i], vm / 2);\n }\n if (vm % 2 == 1 && vals[mda - 1] >= (vm + 1) / 2) {\n sum++;\n }\n if (sum >= vm) {\n vl = vm;\n } else {\n vr = vm;\n }\n }\n int arr[] = new int[vl];\n int kek = 0;\n for (int i = 0; i < mda; i++) {\n int grab = Math.min(vals[i], vl / 2);\n if (vl % 2 == 1 && i == mda - 1 && vals[i] >= (vl + 1) / 2) {\n grab++;\n }\n for (int j = 0; j < grab; j++) {\n if (kek < vl) {\n arr[kek] = x[i];\n kek++;\n }\n }\n }\n out.println(vl);\n int k = (vl + 1) / 2;\n int ans[] = new int[vl];\n for (int i = 0; i < vl; i++) {\n if (i % 2 == 0) {\n ans[i] = arr[i / 2];\n } else {\n ans[i] = arr[i / 2 + k];\n }\n }\n boolean bad = false;\n for (int i= 1; i < vl; i++) {\n if (ans[i] == ans[i-1]) bad = true;\n }\n if (!bad) {\n for (int i = 0; i < vl; i++) out.print(ans[i] + \" \");\n out.println();\n } else {\n for (int i = 0; i < vl; i++) {\n if (i % 2 == 0) {\n ans[i] = arr[i / 2 + vl / 2];\n } else {\n ans[i] = arr[i / 2];\n }\n }\n for (int i = 0; i < vl; i++) out.print(ans[i] + \" \");\n out.println();\n }\n }\n }\n\n public static void main(String[] args) throws IOException {\n solve();\n out.close();\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf4124f487c4f6f607fc2acd79239686", "src_uid": "4e679d176597052498b7b8f14d81f63f", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.*;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.nio.charset.IllegalCharsetNameException;\nimport java.util.*;\n\npublic class Main {\n\n\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer st;\n static PrintWriter out = new PrintWriter(System.out);\n\n static String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) {\n st = new StringTokenizer(br.readLine());\n }\n return st.nextToken();\n }\n\n static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n static void solve() throws IOException {\n int t = nextInt();\n for (int tc = 0; tc < t; tc++) {\n int n = nextInt();\n int a[] = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n Arrays.sort(a);\n int vals[] = new int[n];\n int x[] = new int[n];\n int ptr = 0;\n int mda = 0;\n while (ptr < n) {\n int j = ptr;\n while (j < n && a[j] == a[ptr]) {\n j++;\n }\n x[mda] = a[ptr];\n vals[mda++] = j - ptr;\n ptr = j;\n }\n int vl = 0, vr = n + 1;\n while (vl < vr - 1) {\n int vm = (vl + vr) / 2;\n int sum = 0;\n for (int i = 0; i < mda; i++) {\n sum += Math.min(vals[i], vm / 2);\n }\n if (vm % 2 == 1 && (vals[0] >= (vm + 1) / 2 || vals[mda - 1] >= (vm + 1) / 2)) {\n sum++;\n }\n if (sum >= vm) {\n vl = vm;\n } else {\n vr = vm;\n }\n }\n int arr[] = new int[vl];\n int kek = 0;\n boolean kekos = false;\n for (int i = 0; i < mda; i++) {\n int grab = Math.min(vals[i], vl / 2);\n if (vl % 2 == 1 && i == 0 && vals[i] >= (vl + 1) / 2) {\n kekos = true;\n grab++;\n }\n if (kekos && vl % 2 == 1 && i == mda - 1 && vals[i] >= (vl + 1) / 2) {\n grab++;\n }\n for (int j = 0; j < grab; j++) {\n if (kek < vl) {\n arr[kek] = x[i];\n kek++;\n }\n }\n }\n out.println(vl);\n int k = (vl + 1) / 2;\n int ans[] = new int[vl];\n for (int i = 0; i < vl; i++) {\n if (i % 2 == 0) {\n ans[i] = arr[i / 2];\n } else {\n ans[i] = arr[i / 2 + k];\n }\n }\n boolean bad = false;\n for (int i= 1; i < vl; i++) {\n if (ans[i] == ans[i-1]) bad = true;\n }\n if (!bad) {\n for (int i = 0; i < vl; i++) out.print(ans[i] + \" \");\n out.println();\n } else {\n for (int i = 0; i < vl; i++) {\n if (i % 2 == 0) {\n ans[i] = arr[i / 2 + vl / 2];\n } else {\n ans[i] = arr[i / 2];\n }\n }\n for (int i = 0; i < vl; i++) out.print(ans[i] + \" \");\n out.println();\n }\n }\n }\n\n public static void main(String[] args) throws IOException {\n solve();\n out.close();\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a6770cdd9f93a5140f3806e85e14ec03", "src_uid": "4e679d176597052498b7b8f14d81f63f", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val solver = HMaksimalnayaPila()\n solver.solve(1, `in`, out)\n out.close()\n}\n\ninternal class HMaksimalnayaPila {\n\n fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {\n val tt = `in`.nextInt()\n outer@ for (t in 0 until tt) {\n val n = `in`.nextInt()\n val a = IntArray(n)\n for (i in 0 until n) {\n a[i] = `in`.nextInt()\n }\n ArrayUtils.sort(a)\n\n var t1 = 0\n var t2 = n / 2\n val flag = BooleanArray(1)\n while (t1 < t2) {\n val m = (t1 + t2 + 1) / 2\n if (doit(a, m, flag)) {\n t1 = m\n } else {\n t2 = m - 1\n }\n }\n if (t1 == 0) {\n out.println(1)\n out.println(a[0])\n } else {\n doit(a, t1, flag)\n\n val ans = LinkedList()\n if (flag[0]) {\n var l = t1 - 1\n var r = a.size - 1\n\n while (l >= 0 && a[l] < a[r]) {\n ans.add(a[l])\n ans.add(a[r])\n l--\n r--\n }\n if (t1 * 2 < n) {\n if (a[t1] != a[t1 - 1]) {\n ans.addFirst(a[t1])\n } else if (a[n - t1 - 1] != a[n - t1]) {\n ans.addLast(a[n - t1 - 1])\n }\n }\n } else {\n var l = 0\n var r = a.size - t1\n\n while (l <= t1 - 1 && a[r] > a[l]) {\n ans.add(a[r])\n ans.add(a[l])\n l++\n r++\n }\n if (t1 * 2 < n) {\n if (a[t1] != a[t1 - 1]) {\n ans.addLast(a[t1])\n } else if (a[n - t1 - 1] != a[n - t1]) {\n ans.addFirst(a[n - t1 - 1])\n }\n }\n }\n\n out.println(ans.size)\n for (`val` in ans) {\n out.print(`val`)\n out.print(' ')\n }\n out.println()\n }\n }\n }\n\n fun doit(a: IntArray, m: Int, flag: BooleanArray): Boolean {\n var l = m - 1\n var r = a.size - 1\n while (l >= 0 && a[l] < a[r]) {\n l--\n }\n\n r--\n }\n if (l == -1)\n {\n flag[0] = true\n return true\n }\n l = 0\n r = a.size - m\n while (l <= m - 1 && a[r] > a[l])\n {\n l++\n r++\n }\n flag[0] = false\n return l == m\n}\n}\n\ninternal object ArrayUtils {\n\n val seed = System.nanoTime()\n val rand = Random(seed)\n\n fun sort(a: IntArray) {\n shuffle(a)\n Arrays.sort(a)\n }\n\n fun shuffle(a: IntArray) {\n for (i in a.indices) {\n val j = rand.nextInt(i + 1)\n val t = a[i]\n a[i] = a[j]\n a[j] = t\n }\n }\n}\n\ninternal class InputReader(stream: InputStream) {\n\n var reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2023163ec140dbfa1ba465796bc311f3", "src_uid": "4e679d176597052498b7b8f14d81f63f", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n // 8:02\n val (n, k) = readLine()!!.split(' ').map(String::toLong)\n var res: Long\n if (n % 2 == 0) {\n res = if (k <= n / 2) {\n 2L * k - 1L\n }\n else {\n 2L * (k - n / 2)\n }\n }\n else {\n res = if (k <= (n + 1) / 2) {\n 2L * k - 1\n }\n else {\n 2L * (k - (n + 1) / 2)\n }\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "139fbadd3e6a026a51172bf29166acc1", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n unsigned long long n,k,j=0;\n\n cin>>n>>k;\nif(n%2!=0)\n n++;\nint c=0;\nif(k>n/2)\nc=2*(k-n/2);\nelse\n c=2*k-1;\n cout< m) {\n var temp = m;\n m = n;\n n = temp;\n }\n var k = nextInt()\n if(k == -1 && m + n % 2 == 0L){\n pw.println(0)\n }else pw.println(modPow(2, (n - 1) % modulo * (m - 1) % modulo)\n}\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextLine() = if(hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n,{nextInt()})\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nval br = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`))\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nval pw = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "677c25731a0115d28030412028f359e3", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nval modulo : Long = 1000000007L\n\ntailrec fun modPow(n : Long, m : Long) : Long {\n if(m == 0L) return 1\n if(m == 1L) return n % modulo\n val vur = if(m % 2L == 0L) 1 else n % modulo\n val a = modPow(n,m / 2) % modulo;\n return (vur % modulo * a % modulo * a % modulo) % modulo\n}\n\nfun solve() {\n var n = nextLong()\n var m = nextLong()\n if(m == 1L) {\n pw.println(modPow(2,n - 1))\n }else {\n pw.println(modPow(modPow(2, n - 1), m - 1))\n }\n}\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextLine() = if(hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n,{nextInt()})\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nval br = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`))\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nval pw = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}\nimport java.io.*\nimport java.util.*\n\nval modulo : Long = 1000000007L\n\ntailrec fun modPow(n : Long, m : Long) : Long {\n if(m == 0L) return 1\n if(m == 1L) return n % modulo\n val vur = if(m % 2L == 0L) 1 else n % modulo\n val a = modPow(n,m / 2) % modulo;\n return (vur % modulo * a % modulo * a % modulo) % modulo\n}\n\nfun solve() {\n var n = nextLong()\n var m = nextLong()\n if(m == 1L) {\n pw.println(modPow(2,n - 1))\n }else {\n pw.println(modPow(modPow(2, n - 1), m - 1))\n }\n}\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextLine() = if(hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n,{nextInt()})\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nval br = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`))\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nval pw = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "34549ba636b9786df73d31d156d3300b", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "package mainPackage\n\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val s = scanner.nextLine()\n\n var ans = 0\n\n for(i in 0 .. s.length - 1) {\n for(j in i + 1 .. s.length - 1) {\n for (h in j + 1 .. s.length - 1) {\n if(s[i] == 'Q' && s[j] == 'A' && s[h] == 'Q') {\n ++ans\n }\n }\n }\n }\n\n print(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "da2abb4e009c2ef39390f0e0760537bb", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nimport kotlin.test.assertEquals\n\nprivate object Read {\n fun readLn() = readLine()!! // string line\n fun readInt() = readLn().toInt() // single int\n fun readLong() = readLn().toLong() // single long\n fun readDouble() = readLn().toDouble() // single double\n fun readStrings() = readLn().split(\" \") // list of strings\n fun readInts() = readStrings().map { it.toInt() } // list of ints\n fun readLongs() = readStrings().map { it.toLong() } // list of longs\n fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n}\n\nprivate fun arpasExam(degree: Int) = when (degree % 4) {\n 1 -> 8\n 2 -> 4\n 3 -> 2\n 0 -> 6\n else -> 0\n}\n\n\nfun main() {\n assertEquals(8, arpasExam(1))\n assertEquals(4, arpasExam(2))\n println(arpasExam(Read.readInt()))\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "abde75c67b0a81085c3e6497b3fec3c5", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nimport kotlin.test.assertEquals\n\nprivate object Read {\n fun readLn() = readLine()!! // string line\n fun readInt() = readLn().toInt() // single int\n fun readLong() = readLn().toLong() // single long\n fun readDouble() = readLn().toDouble() // single double\n fun readStrings() = readLn().split(\" \") // list of strings\n fun readInts() = readStrings().map { it.toInt() } // list of ints\n fun readLongs() = readStrings().map { it.toLong() } // list of longs\n fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n}\n\nprivate fun arpasExam(degree: Int) = when (degree % 4) {\n 1 -> 8\n 2 -> 4\n 3 -> 2\n 0 -> 6\n else -> 0\n}\n\n\nfun main() {\n println(arpasExam(Read.readInt()))\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8e519d7743bf0f213db5cb224a1b1b04", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforces\nprivate object Read {\n fun readLn() = readLine()!! // string line\n fun readInt() = readLn().toInt() // single int\n fun readLong() = readLn().toLong() // single long\n fun readDouble() = readLn().toDouble() // single double\n fun readStrings() = readLn().split(\" \") // list of strings\n fun readInts() = readStrings().map { it.toInt() } // list of ints\n fun readLongs() = readStrings().map { it.toLong() } // list of longs\n fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n}\n\nprivate fun arpasExam(degree: Int): Int = if (degree == 0) 1\nelse {\n when (degree % 4) {\n 1 -> 8\n 2 -> 4\n 3 -> 2\n 0 -> 6\n else -> 0\n }\n}\n\n\nfun main() {\n println(arpasExam(Read.readInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "df96497279904b70c1a443049f215a68", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package Round526\n\nimport java.io.*\nimport java.util.*\nimport java.lang.Math.*\nimport java.lang.StringBuilder\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val pw = PrintWriter(System.out)\n val n = sc.nextInt()\n val a = LongArray(n) { sc.nextLong() }\n var min = Long.MAX_VALUE\n for (x in 1..n) {\n var sum = 0L\n for (i in 0 until n)\n sum += a[i] * (abs((i + 1) - x) + (i) + (x - 1)) * 2\n min = min(min, sum)\n }\n pw.print(min)\n pw.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca167e273a3049e1b134a88637bfc11c", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import peace.n\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.ceil\nimport kotlin.math.floor\nimport kotlin.math.log2\nimport kotlin.math.sqrt\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n val arr = IntArray(n) { scanner.nextInt() }\n var res = 0\n for (i in arr) {\n if (i > k)\n break\n res++\n }\n if (res == n) {\n print(n)\n return\n }\n for (i in arr.reversed()) {\n if (i > k)\n break\n res++\n }\n println(res)\n}\n\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n//class Pair(var a: Int, var b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return b - a - other.b + other.a\n// }\n//}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "deb7159e83b0fc995dd1928b80d2b60b", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.text.CharacterIterator\nimport java.util.*\n\n/**\n * Created by ramilagger on 6/15/17.\n *\n */\n\nfun sum(n: String): Int {\n var sum = 0\n n.chars().forEach({ \n sum += Character.getNumericValue(it)\n })\n return sum\n}\n\nfun f(n : Long) = n - sum(n.toString())\n\nfun solve(){\n val n = nextLong()\n val s = nextLong()\n var lo = 0L\n var hi = n\n while (lo < hi) {\n val mid = (lo + hi) / 2\n if(f(mid) < s) lo = mid + 1\n else hi = mid - 1\n }\n if(n != hi) pw.println(n - hi + 1)\n else pw.println(if(f(n) < s) 0 else 1)\n}\n\n\nfun hasNext() : Boolean {\n if(st.hasMoreTokens())\n else\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return true\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\n//fun nextArray(n : Int) = IntArray(n,{ nextInt() })\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\nval br = if(ONLINE_JUDGE) BufferedReader(InputStreamReader(System.`in`)) else BufferedReader(FileReader(\"in.txt\"))\nval pw = if(ONLINE_JUDGE) PrintWriter(BufferedWriter(OutputStreamWriter(System.out))) else PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\nvar st = StringTokenizer(\"\")\n\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e0d2b582c896f24df9d9318fa9a3b242", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n/**\n * Created by ramilagger on 6/15/17.\n *\n */\n\nfun sum(n: String): Int {\n var sum = 0\n n.chars().forEach {\n sum += it\n sum -= '0'.toInt()\n }\n return sum\n}\n\nfun f(n : Long) = n - sum(n.toString())\n\nfun solve(){\n val n = nextLong()\n val s = nextLong()\n var lo = 0L\n var hi = n\n while (lo < hi) {\n val mid = (lo + hi) / 2\n if(f(mid) < s) lo = mid + 1\n else hi = mid - 1\n }\n if(n != hi) pw.println(n - hi + 1)\n else pw.println(if(f(n) < s) 0 else 1)\n}\n\n\nfun hasNext() : Boolean {\n if(st.hasMoreTokens())\n else\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return true\n \n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\n//fun nextArray(n : Int) = IntArray(n,{ nextInt() })\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\nval br = if(ONLINE_JUDGE) BufferedReader(InputStreamReader(System.`in`)) else BufferedReader(FileReader(\"in.txt\"))\nval pw = if(ONLINE_JUDGE) PrintWriter(BufferedWriter(OutputStreamWriter(System.out))) else PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\nvar st = StringTokenizer(\"\")\n\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f056f81e07e10b20c11b11d58d2a28c0", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\t\n\tvar len1 = first.length\n\tvar len2 = second.length\n\tvar lenAll = all.length\n\t\n\tif (len1 + len2 != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tvar s: String\n\tfor (i in 0..lenAll-1){\n\t\ts = all[i].toString()\n\t\tif (first.contains(s), ignoreCase = true){\n\t\t\tfirst = first.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tif (second.contains(s), ignoreCase = true){\n\t\t\tsecond = second.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "deb8b4afbc5851ef0156a5b11553b274", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\t\n\tvar len1 = first.length\n\tvar len2 = second.length\n\tvar lenAll = all.length\n\t\n\tif (len1 + len2 != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tvar s: Char\n\tfor (i in 0..lenAll-1){\n\t\ts = all[i]\n\t\tif (first.contains(s, ignoreCase = true)){\n\t\t\tfirst = first.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tif (second.contains(s, ignoreCase = true)){\n\t\t\tsecond = second.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b1326e9aad74b6151c983ec8b5eec8a2", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\t\n\tvar len1 = first.length\n\tvar len2 = second.length\n\tvar lenAll = all.length\n\t\n\tif (len1 + len2 != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tvar s: Char\n\tfor (i in 0..lenAll-1){\n\t\ts = all[i]\n\t\tif (first.contains(s, ignoreCase = true)){\n\t\t\tfirst = first.replace(s,'')\n\t\t\tcontinue\n\t\t}\n\t\tif (second.contains(s, ignoreCase = true)){\n\t\t\tsecond = second.replace(s,'')\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "546ba49ce8c5657fea8d35765969bef0", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\t\n\tvar len1 = first.length\n\tvar len2 = second.length\n\tvar lenAll = all.length\n\t\n\tif (len1 + len2 != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\t\n\tfor (i in 0..lenAll-1){\n\t\tif (len1.contains(lenAll[i])){\n\t\t\tlen1 = len1.replace(lenAll[i],\"\")\n\t\t\tlenAll = lenAll.replace(lenAll[i],\"\")\n\t\t\tcontinue\n\t\t}\n\t\tif (len2.contains(lenAll[i])){\n\t\t\tlen2 = len2.replace(lenAll[i],\"\")\n\t\t\tlenAll = lenAll.replace(lenAll[i],\"\")\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f497d568836f6d6f5f9b45aa10338f08", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\n\tvar lenAll = all.length\n\t\n\tif (first.length + second.length != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tvar s: Char\n\tfor (i in 0..lenAll-1){\n\t\ts = all[i]\n\t\tif (first.contains(s, ignoreCase = true)){\n\t\t\tfirst = first.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tif (second.contains(s, ignoreCase = true)){\n\t\t\tsecond = second.replace(s,\"\")\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f14ff7a9eb76971efde6d610a1bfdac0", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar first = readLine()!!.toString()\n\tvar second = readLine()!!.toString()\n\tvar all = readLine()!!.toString()\n\t\n\tvar len1 = first.length\n\tvar len2 = second.length\n\tvar lenAll = all.length\n\t\n\tif (len1 + len2 != lenAll){\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tfor (i in 0..lenAll-1){\n\t\tif (first.contains(all[i]), ignoreCase = true){\n\t\t\tfirst = first.replace(lenAll[i],\"\")\n\t\t\tcontinue\n\t\t}\n\t\tif (second.contains(all[i]), ignoreCase = true){\n\t\t\tsecond = second.replace(lenAll[i],\"\")\n\t\t\tcontinue\n\t\t}\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\n\tprintln(\"YES\")\n\treturn\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3c6a34b40588bc5bd22de58138f6f4a7", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n// n a x b y\n val (n,ai,x,bi,y) = readLine()!!.split(\" \").map(::toInt)\n var a = ai\n var b = bi\n (1..n) {\n a += 1\n b -= 1\n if (a > n) a = 1\n if (b < 1) b = n\n if (a == b) {\n println(\"YES\")\n return\n }\n if (a == x || b == y) {\n println(\"NO\")\n return\n }\n }\n println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b2b84e3ba8b05f042f9a90680c776d1b", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\n/* Name of the class has to be \"Main\" only if the class is public. */\npublic class Main\n{\n\tPrintWriter out = new PrintWriter(System.out);\n\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer tok = new StringTokenizer(\"\");\n String next() throws IOException {\n if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }\n return tok.nextToken();\n }\n int ni() throws IOException { return Integer.parseInt(next()); }\n long nl() throws IOException { return Long.parseLong(next()); }\n \n void solve() throws IOException {\n int n=ni(); int a=ni(); long x=nl(); int b=ni(); int y=ni();\n boolean f=false;\n while (a!=x && b!=y) {\n a++;\n if (a==n+1) a=1;\n b--;\n if (b==0) b=n;\n if (a==b) { f=true; break; }\n }\n if (f) System.out.println(\"YES\");\n else System.out.println(\"NO\");\n }\n \n public static void main(String[] args) throws IOException {\n new Main().solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b6c56fb548cb9df402ff9df4b2d2f3f7", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Kotlin 1.6", "source_code": "package com.example.applicationdsa\r\n\r\n\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport java.util.*\r\nimport kotlin.collections.HashSet\r\n\r\n\r\nfun main() {\r\n\r\n// val file = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\input.txt\")\r\n// if (!file.isFile)\r\n// file.createNewFile();\r\n// val fileOut = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\output.txt\")\r\n// val scan = Scanner(file)\r\n val p = PrintWriter(System.out)\r\n val scan = Scanner(System.`in`)\r\n\r\n var t = scan.nextLine().toInt()\r\n\r\n while (t-- > 0) {\r\n var x = scan.nextLine().toInt()\r\n val nk = scan.nextLine().split(\" \")\r\n\r\n // val n = nk[0].trim().toInt()\r\n val a = nk[0].trim().toInt()\r\n val b = nk[1].trim().toInt()\r\n val c = nk[2].trim().toInt()\r\n\r\n if(x == 0)\r\n p.println(\"NO\")\r\n else{\r\n if(x == 1 && (a == 2)){\r\n if(b == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 1 && a == 3){\r\n if(c == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 1){\r\n if(a == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 3){\r\n if(c == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 1){\r\n if(a == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 2){\r\n if(b == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }\r\n p.flush()\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e6e9613c4d857498167c0ca77178c1e0", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "package com.example.applicationdsa\r\n\r\n\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport java.util.*\r\nimport kotlin.collections.HashSet\r\n\r\n\r\nfun main() {\r\n\r\n// val file = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\input.txt\")\r\n// if (!file.isFile)\r\n// file.createNewFile();\r\n// val fileOut = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\output.txt\")\r\n// val scan = Scanner(file)\r\n val p = PrintWriter(System.out)\r\n val scan = Scanner(System.`in`)\r\n\r\n var t = scan.nextLine().toInt()\r\n\r\n while (t-- > 0) {\r\n var x = scan.nextLine().toInt()\r\n val nk = scan.nextLine().split(\" \")\r\n\r\n // val n = nk[0].trim().toInt()\r\n val a = nk[0].trim().toInt()\r\n val b = nk[1].trim().toInt()\r\n val c = nk[2].trim().toInt()\r\n\r\n var count = 0;\r\n\r\n if(x == 0)\r\n p.println(\"NO\")\r\n else{\r\n if(x == 1 && (a == 2)){\r\n if(b == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 1 && a == 3){\r\n if(c == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 1){\r\n if(a == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 3){\r\n if(c == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 1){\r\n if(a == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 2){\r\n if(b == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }\r\n p.flush()\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fd459260509f10b82750b89cb0bbba66", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "package com.example.applicationdsa\r\n\r\n\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport java.util.*\r\nimport kotlin.collections.HashSet\r\n\r\n\r\nfun main(args: Array) {\r\n\r\n// val file = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\input.txt\")\r\n// if (!file.isFile)\r\n// file.createNewFile();\r\n// val fileOut = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\output.txt\")\r\n// val scan = Scanner(file)\r\n val p = PrintWriter(System.out)\r\n val scan = Scanner(System.`in`)\r\n\r\n var t = scan.nextLine().toInt()\r\n\r\n while (t-- > 0) {\r\n var x = scan.nextLine().toInt()\r\n val nk = scan.nextLine().split(\" \")\r\n\r\n // val n = nk[0].trim().toInt()\r\n val a = nk[0].trim().toInt()\r\n val b = nk[1].trim().toInt()\r\n val c = nk[2].trim().toInt()\r\n\r\n var count = 0;\r\n\r\n if(x == 0)\r\n p.println(\"NO\")\r\n else{\r\n if(x == 1 && (a == 2)){\r\n if(b == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 1 && a == 3){\r\n if(c == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 1){\r\n if(a == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 3){\r\n if(c == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 1){\r\n if(a == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 2){\r\n if(b == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }\r\n p.flush()\r\n }\r\n} ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bdc34dac35552f00f3036ec758e66465", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "package com.example.applicationdsa\r\n\r\n\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport java.util.*\r\nimport kotlin.collections.HashSet\r\n\r\n\r\nfun main(args: Array) {\r\n\r\n// val file = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\input.txt\")\r\n// if (!file.isFile)\r\n// file.createNewFile();\r\n// val fileOut = File(\"C:\\\\Users\\\\Adarsh Dhakad\\\\Desktop\\\\output.txt\")\r\n// val scan = Scanner(file)\r\n val p = PrintWriter(System.out)\r\n val scan = Scanner(System.`in`)\r\n\r\n var t = scan.nextLine().toInt()\r\n\r\n while (t-- > 0) {\r\n var x = scan.nextLine().toInt()\r\n val nk = scan.nextLine().split(\" \")\r\n\r\n // val n = nk[0].trim().toInt()\r\n val a = nk[0].trim().toInt()\r\n val b = nk[1].trim().toInt()\r\n val c = nk[2].trim().toInt()\r\n\r\n\r\n if(x == 0)\r\n p.println(\"NO\")\r\n else{\r\n if(x == 1 && (a == 2)){\r\n if(b == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 1 && a == 3){\r\n if(c == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 1){\r\n if(a == 3){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 2 && b == 3){\r\n if(c == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 1){\r\n if(a == 2){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else if(x == 3 && c == 2){\r\n if(b == 1){\r\n p.println(\"YES\")\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }else{\r\n p.println(\"NO\")\r\n }\r\n }\r\n p.flush()\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "198303178027496e7675006f12038670", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() = repeat(readLine()!!.toInt()) {\n val x = readLine()!!\n val dig = x[0] - '0'\n println((dig - 1) * 10 + s.size() * (s.size() + 1) / 2)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "83448c5078b1d88f4f17b2b0a63de9a0", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.r630D2\n\nfun main(args : Array) {\n\n val NT = readLine()?.toInt() ?: 0\n val MOD = 998244353L\n\n for(test in 1..NT) {\n val (N) = readLine()!!.split(' ').map{ it.toInt()}\n// val (N, M, L, R) = arrayOf(1000000000L, 1000000000L, 1L, 1000000000L)\n //val (N, M, L, R) = arrayOf(10000L, 10000L, 1L, 1000000000L)//63306173\n\n var ans = 0\n outer@ for(i in '1'..'9'){\n for(j in 1..4){\n val now = \"$i\".repeat(j).toInt()\n ans += j\n if(now == N)break@outer\n }\n }\n\n println(ans)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8893c563f3ff5ed5af56a3cd1cf3936f", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() = repeat(readLine()!!.toInt()) {\n val x = readLine()!!\n val dig = x[0] - '0'\n println((dig - 1) * 10 + x.size() * (x.size() + 1) / 2)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c5bc3ccbc3dfd4072f4680714c6abbfb", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.OutputStreamWriter\nimport java.io.PrintWriter\nimport java.lang.Math.max\nimport java.lang.Math.min\nimport java.lang.module.ModuleDescriptor.read\nimport java.util.*\nimport kotlin.collections.HashSet\n\nval ord = mutableListOf()\n\nfun comp() {\n for (digit in 1..9){\n var now = digit\n while (now <= 10000){\n ord.add(now)\n now *= 10\n now += digit\n }\n }\n}\n\nfun test() {\n val n = readInt()\n var ans = 0\n for (i in ord){\n ans += (i.toString()).length\n if (i == n) break\n }\n println(ans)\n}\n\nfun solve() {\n comp()\n var tests = readInt()\n while (tests-- > 0) {\n test()\n }\n}\n\n// TEMPLATE\nfun main(args: Array) {\n reader = BufferedReader(InputStreamReader(System.`in`))\n out = PrintWriter(OutputStreamWriter(System.out))\n solve()\n out.close()\n}\n\nprivate lateinit var out: PrintWriter\nprivate lateinit var reader: BufferedReader\nprivate var tokenizer: StringTokenizer? = null\nprivate fun read(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(readLn())\n }\n return tokenizer!!.nextToken()\n}\n\nprivate fun readInt() = read().toInt()\nprivate fun readLong() = read().toLong()\nprivate fun readLn() = reader.readLine()!!\nprivate fun readInts() = readLn().split(\" \").map { it.toInt() }\nprivate fun readInts(sz: Int) = Array(sz) { readInt() }\nprivate fun readLongs() = readLn().split(\" \").map { it.toLong() }\nprivate fun readLongs(sz: Int) = Array(sz) { readLong() }\nprivate fun print(b: Boolean) = out.print(b)\nprivate fun print(i: Int) = out.print(i)\nprivate fun print(d: Double) = out.print(d)\nprivate fun print(l: Long) = out.print(l)\nprivate fun print(s: String) = out.print(s)\nprivate fun print(message: Any?) = out.print(message)\nprivate fun print(a: Array) = a.forEach { print(\"$it \") }\nprivate fun print(a: Array) = a.forEach { print(\"$it \") }\nprivate fun print(a: Collection) = a.forEach { print(\"$it \") }\nprivate fun println(b: Boolean) = out.println(b)\nprivate fun println(i: Int) = out.println(i)\nprivate fun println(d: Double) = out.println(d)\nprivate fun println(l: Long) = out.println(l)\nprivate fun println(s: String) = out.println(s)\nprivate fun println() = out.println()\nprivate fun println(message: Any?) = out.println(message)\nprivate fun println(a: Array) {\n a.forEach { print(\"$it \") }\n println()\n}\n\nprivate fun println(a: IntArray) {\n a.forEach { print(\"$it \") }\n println()\n}\n\nprivate fun println(a: Collection) {\n a.forEach { print(\"$it \") }\n println()\n}\n\nprivate fun intarr(sz: Int, v: Int = 0) = IntArray(sz) { v }\nprivate fun longarr(sz: Int, v: Long = 0) = LongArray(sz) { v }\nprivate fun intarr2d(n: Int, m: Int, v: Int = 0) = Array(n) { intarr(m, v) }\nprivate fun init(vararg elements: T) = elements\nprivate fun VI(n: Int = 0, init: Int = 0) = MutableList(n) { init }\nprivate fun VVI(n: Int = 0, m: Int = 0, init: Int = 0) = MutableList(n) { VI(m, init) }\nprivate fun , T2 : Comparable> pairCmp(): Comparator> {\n return Comparator { a, b ->\n val res = a.first.compareTo(b.first)\n if (res == 0) a.second.compareTo(b.second) else res\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "36aa223201492a28a366370eb433adcc", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.jagito\nimport java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val t = sc.nextInt()\n for (_i in 0 until t) {\n val n = sc.nextInt()\n val a = n %10;\n if (a > 1){\n println(a *10 - when(n.toString().length){\n 1 -> 9\n 2 -> 7\n 3 -> 4\n else -> 0\n })\n }else{\n println(when(n.toString().length){\n 1 -> 1\n 2 -> 3\n 3 -> 6\n else -> 10\n })\n }\n }\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b784db25e72e3f43b8484d7f4b642ad1", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "Is it an apple and a banana simultaneouSLY?\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n readLn().apply {\n if (this[indexOfLast { c -> c != '?' && c != ' ' }].toLowerCase() in \"aeiouy\") print(\"YES\") else print(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d339cd63330587b7f021931a57a78dcd", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val min = Math.min(n, m * 2)\n var max = \"PE\"\n for (i in 1..n) {\n if ((i * i - 1) / 2 >= m) {\n max = i\n break\n }\n }\n println(\"${n - min} ${n - max}\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "021411f915de97dc6f339708b9e2516a", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val m = sc.nextLong()\n val min = Math.min(n, m * 2)\n var max: Long\n for (i in 1..n) {\n if (i * (i - 1) / 2 >= m) {\n max = i\n break\n }\n }\n println(\"${n - min} ${n - max}\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e19306d333cb9009f670f0fb0909bf01", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package Kotlin\n\nimport java.util.*\n\n/**\n * Created by Administrator on 2017/6/8.\n */\nfun isSort(a: Array): Boolean {\n\n var last = 0;\n for (i in 0..a.size){\n if (0 == i){\n last = a[i]\n }else if(a[i]!=0){\n if (a[i]>last)\n return false\n else last = a[i]\n }\n }\n return true\n}\n fun main(args: Array) {\n\n var out = Scanner(System.`in`)\n var aLen = out.nextInt()\n var bLen = out.nextInt()\n var a = Array(aLen,{out.nextInt()})\n var b = Array(bLen,{out.nextInt()})\n if (bLen>=2){\n println(\"Yes\")\n }else if (isSort(a)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n\n}\n\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3ed48340f3d3c6286313e5a15f3b9466", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun isSort(a: Array): Boolean {\n\n var last = 0;\n for (i in 0..a.size){\n if (0 == i){\n last = a[i]\n }else if(a[i]!=0){\n if (a[i]) {\n\n var out = Scanner(System.`in`)\n var aLen = out.nextInt()\n var bLen = out.nextInt()\n var a = Array(aLen,{out.nextInt()})\n var b = Array(bLen,{out.nextInt()})\n if (bLen>=2){\n println(\"Yes\")\n }else if (isSort(a)){\n println(\"No\")\n }else{\n println(\"Yes\")\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "408564879c3e7e27e540f48de4481938", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package com.openbank\n\nclass Fraction {\n fun main(args: Array) {\n val n = readLine()!!.toInt()\n var a = 0\n var b = 0\n\n if ((n % 2) == 0) {\n a = (n / 2) - 1\n b = (n / 2) + 1\n } else {\n a = (n / 2) - 1\n b = n / 2\n }\n\n println(\"$a $b\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0350de58366147c6d24c4db3c03a4c57", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (m, n) = readLongs()\n val leftOver = n.factorize().sorted().toMutableList()\n m.factorize().forEach { leftOver -= it }\n\n println(when {\n leftOver.isEmpty() -> 0\n leftOver.max()!! > 3 -> -1\n else -> leftOver.size\n })\n}\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun Long.factorize(): List {\n var sub = takeIf { it > 1 } ?: return emptyList()\n\n return sequence {\n for (p in Primes.primes) {\n if (sub <= 1) {\n break\n }\n\n while (sub % p == 0L) {\n sub /= p\n yield(p)\n }\n }\n }.toList()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e48165e38dc54c403fb317ae0952aba9", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val (m, n) = readLongs()\n val leftOver = n.factorize().sorted().toMutableList()\n m.factorize().forEach { leftOver -= it }\n\n println(when {\n leftOver.isEmpty() -> 0\n leftOver.max()!! > 3 -> -1\n else -> leftOver.size\n })\n}\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun Long.factorize(): List {\n var sub = takeIf { it > 1 } ?: return emptyList()\n\n return sequence {\n for (p in Primes.primes) {\n if (sub <= 1) {\n break\n }\n\n while (sub % p == 0L) {\n sub /= p\n yield(p)\n }\n }\n }.toList()\n}\n\nobject Primes {\n const val MAX = 2_000_000\n\n val bitmap: BitSet by lazy { Primes.sieve(MAX) }\n val primes: List by lazy { (1..MAX).filter { isPrime(it) }.toList() }\n\n fun isPrime(num: Int) = bitmap[num - 1]\n\n fun nthPrime(n: Int) = primes[n - 1]\n\n private fun sieve(max: Int): BitSet {\n val primeMap = BitSet(max)\n primeMap.set(0, primeMap.size() - 1)\n primeMap.set(0, false)\n\n for (i in 2..primeMap.size()) {\n if (primeMap[i - 1]) {\n for (j in i + i..primeMap.size() step i) {\n primeMap.set(j - 1, false)\n }\n }\n }\n\n return primeMap\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9fc3521e3478459e18f2ee314a6c416b", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val (m, n) = readLongs()\n\n if (n % m != 0L) {\n println(-1)\n return\n }\n\n val leftOver = n.factorize().sorted().toMutableList()\n m.factorize().forEach { leftOver.remove(it) }\n\n println(when {\n leftOver.isEmpty() -> 0\n leftOver.max()!! > 3 -> -1\n else -> leftOver.size\n })\n}\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun Long.factorize(): List {\n var sub = takeIf { it > 1 } ?: return emptyList()\n\n return mutableListOf().apply {\n for (p in Primes.primes) {\n if (sub <= 1) {\n break\n }\n\n while (sub % p == 0L) {\n sub /= p\n add(p)\n }\n }\n }\n}\n\nobject Primes {\n const val MAX = 2_000_000\n\n val bitmap: BitSet by lazy { Primes.sieve(MAX) }\n val primes: List by lazy { (1..MAX).filter { isPrime(it) }.toList() }\n\n fun isPrime(num: Int) = bitmap[num - 1]\n\n fun nthPrime(n: Int) = primes[n - 1]\n\n private fun sieve(max: Int): BitSet {\n val primeMap = BitSet(max)\n primeMap.set(0, primeMap.size() - 1)\n primeMap.set(0, false)\n\n for (i in 2..primeMap.size()) {\n if (primeMap[i - 1]) {\n for (j in i + i..primeMap.size() step i) {\n primeMap.set(j - 1, false)\n }\n }\n }\n\n return primeMap\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca49213f696dbb3334ff5e87bc1b0b1c", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\\import java.io.*\nimport java.util.*\n\nclass Main internal constructor(inputStream: InputStream, val out: PrintWriter) {\n companion object {\n val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n }\n\n private val br = BufferedReader(InputStreamReader(inputStream))\n private var st = StringTokenizer(\"\")\n\n internal fun hasNext(): Boolean {\n while (!st.hasMoreTokens()) {\n val readLine = br.readLine() ?: return false\n st = StringTokenizer(readLine)\n }\n return true\n }\n\n private operator fun next() =\n if (hasNext()) st.nextToken()!!\n else throw RuntimeException(\"No tokens\")\n\n internal fun nline() =\n if (hasNext()) st.nextToken(\"\\n\")\n else throw RuntimeException(\"No tokens\")\n\n private fun ni() = next().toInt()\n private fun nii() = Pair(ni(), ni())\n private fun niii() = Triple(ni(), ni(), ni())\n private fun nia(n: Int) = IntArray(n) { ni() }\n private fun nia(m: Int, n: Int) = Array(m) { nia(n) }\n\n private fun nl() = next().toLong()\n private fun nll() = Pair(nl(), nl())\n private fun nlll() = Triple(nl(), nl(), nl())\n private fun nla(n: Int) = LongArray(n, { nl() })\n private fun nla(m: Int, n: Int) = Array(m) { nla(n) }\n\n private fun nd() = next().toDouble()\n private fun ndd() = Pair(nd(), nd())\n private fun nddd() = Triple(nd(), nd(), nd())\n private fun nda(n: Int) = DoubleArray(n) { nd() }\n private fun nda(m: Int, n: Int) = Array(m) { nda(n) }\n\n inline fun log(name: String, block: () -> Unit) {\n if (!ONLINE_JUDGE) {\n p(\"#$name: \")\n block()\n flush()\n }\n }\n\n inline fun log() = log(\"\") { pln() }\n inline fun log(message: Any?, name: String = \"\") = log(name) { pln(message) }\n inline fun log(arr: IntArray?, name: String = \"\") = log(name) { pln(arr) }\n inline fun log(arr: LongArray?, name: String = \"\") = log(name) { pln(arr) }\n inline fun log(arr: DoubleArray?, name: String = \"\") = log(name) { pln(arr) }\n inline fun log(arr: Array?, name: String = \"\") = log(name) { pln(arr) }\n inline fun log(stack: Stack?, name: String = \"\") = log(name) { pln(stack) }\n inline fun log(list: List?, name: String = \"\") = log(name) { pln(list) }\n\n //prefix print\n inline fun prep(prefix: Boolean, separator: String, message: Any?) {\n if (prefix) {\n p(separator)\n }\n p(message)\n }\n\n inline fun p(message: Any?) = this.also { out.print(message) }\n\n inline fun p(arr: IntArray?, separator: String = \" \") = this.also {\n arr?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun p(arr: LongArray?, separator: String = \" \") = this.also {\n arr?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun p(arr: DoubleArray?, separator: String = \" \") = this.also {\n arr?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun p(arr: Array?, separator: String = \" \") = this.also {\n arr?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun p(list: List?, separator: String = \" \") = this.also {\n list?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun p(stack: Stack?, separator: String = \" \") = this.also {\n stack?.fold(false, { prefix, t -> prep(prefix, separator, t); true })\n }\n\n inline fun pln() = this.also { out.println() }\n inline fun pln(message: Any?) = p(message).pln()\n inline fun pln(arr: IntArray?, separator: String = \" \") = p(arr, separator).pln()\n inline fun pln(arr: LongArray?, separator: String = \" \") = p(arr, separator).pln()\n inline fun pln(arr: DoubleArray?, separator: String = \" \") = p(arr, separator).pln()\n inline fun pln(list: List?, separator: String = \" \") = p(list, separator).pln()\n inline fun pln(arr: Array?, separator: String = \" \") = p(arr, separator).pln()\n inline fun pln(stack: Stack?, separator: String = \" \") = p(stack, separator).pln()\n\n inline fun flush() = out.flush()\n\n //////////////////////////////////////\n\n fun run() {\n val n = ni()\n var answer = 1\n var itr = 1\n var k = 0\n var d = 0\n var set = TreeSet();\n var flag = true;\n for (i in 1..n) {\n k = 0\n d = i\n flag = true;\n while (d > 0) {\n if (d % 2 == 0 && flag) {\n k++\n } else\n { if (d % 2 == 0) {\n flag=false;\n } else {\n k--\n }\n }\n d /= 2\n }\n if (k == -1&&flag) set.add(i)\n }\n for (i in set) if (n % i == 0) answer = i\n out.print(answer)\n }\n\n}\n\n//////////////////////////////////////\nfun main(args: Array) {\n val inp = File(\"input.txt\")\n if (Main.ONLINE_JUDGE || !inp.isFile) {\n val a = Main(System.`in`, PrintWriter(BufferedOutputStream(System.out)))\n a.run()\n a.flush()\n a.out.close()\n } else {\n val t = Main(FileInputStream(\"input.txt\"), PrintWriter(BufferedOutputStream(System.out)))\n while (t.hasNext()) {\n val name = t.nline()\n t.log(\"##### Test $name #####\")\n val startTime = System.currentTimeMillis()\n t.run()\n val endTime = System.currentTimeMillis()\n t.log(endTime - startTime, \"Total Time\")\n t.log()\n t.flush()\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b8cc868ecb1597009381cc93637ce54b", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun debug(x: Any) {\n System.err.println(x)\n}\n\nfun main(args: Array) {\n val (n, w) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n val indexes = a.mapIndexed { index, x -> x to index }.sortedBy { it.first }.map { it.second }\n val sa = a.sorted()\n val b = IntArray(a.size)\n var rem = w\n for ((index, x) in sa.withIndex()) {\n val min = (x + 1) / 2\n if (rem < min) {\n println(-1)\n return\n }\n b[index] = min\n rem -= min\n }\n require(b.toList() == b.sorted())\n for (i in sa.size - 1 downTo 0) {\n val add = minOf(sa[i] - b[i], rem)\n b[i] += add\n rem -= add\n if (rem == 0) {\n break\n }\n }\n val answer = b.mapIndexed { index, x -> indexes[index] to x }.sortedBy { it.first }.map { it.second }\n println(answer.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1891b4b8103cdcbe734b4cfa65140d2e", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "/**\n * Created by Mego on 5/29/2017.\n */\nfun main(args: Array) {\n val input = readLine()!!.split(\" \")\n var inputInt = ArrayList()\n\n for (i in 0..input.size - 1) {\n inputInt.add(input[i].toInt())\n }\n val mid = (inputInt.sorted())[1]\n val numberOfSteps = (Math.abs(mid - inputInt[0]) + Math.abs(mid - inputInt[1]) + Math.abs(mid - inputInt[2]))\n println(numberOfSteps)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4e41afd15e9d7a244d6b9dece5e43fbd", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package A\n\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val t = sc.nextInt()\n\n val min = Math.max(1, t - k + 1)\n val max = Math.min(n, t)\n\n println(max - min + 1)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b38f9b7bd5b6a0aefd2c267432675c84", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cf2\n\nimport java.util.*\nimport kotlin.math.min\n\nval scanner = Scanner(System.`in`)\n\nfun main() {\n val n = scanner.nextInt()\n val h = scanner.nextInt()\n val m = scanner.nextInt()\n\n val heights = IntArray(n) { h }\n for (i in 0 until m) {\n val l = scanner.nextInt()\n val r = scanner.nextInt()\n val x = scanner.nextInt()\n for (j in l..r) {\n heights[j - 1] = min(heights[j - 1], x)\n }\n }\n\n System.out.println(heights.sumBy { it * it })\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3468035feb4330b0bec0348885128b2a", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val len = r.readLine()!!.toInt()\n //val (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n var (a, b, n) = r.readLine()!!.split(\" \").map { it.toInt() }\n var sturn = true\n var finish = false\n var swin = false\n while (!finish){\n if (sturn){\n val remove = gcd(a, n)\n if (remove<=n){\n n -= remove\n sturn = false\n } else {\n swin = false\n finish = true\n }\n } else {\n val remove = gcd(b, n)\n if (remove<=n){\n n -= remove\n sturn = true\n } else {\n swin = true\n finish = true\n }\n }\n }\n println(if (swin) 0 else 1)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6fb25bd4df374e0e0a3cc530c2d30f87", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n\tval arr=readLine()!!.split(\" \").map{it.toInt()}\n var i=1\n while(true)\n {\n \tif(i%2==0)\n \tarr[1]=arr[1]-i\n \telse \n arr[0]=arr[0]-i\n \tif(arr[0]<0 || arr[1]<0) \n break\n \ti=i+1\n }\n if(arr[1]<0)\n print(\"Valera\")\n else\n print(\"Vladik\")\n\n\t\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "15503bd73664b6bb5b166fd494a570e3", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n val args = br.readLine().split(\" \")\n val a = args[0].toInt()\n val b = args[1].toInt()\n\n val ans = if ((a+b).rem(2) == 0) \"Valera\" else \"Vladik\"\n println(ans)\n\n br.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a4c6ee304150cf7255e38d3dd66b09cb", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import org.omg.PortableInterceptor.INACTIVE\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.cos\nimport kotlin.math.pow\nimport kotlin.math.sqrt\nimport kotlin.test.currentStackTrace\n\n//private val INPUT = File(\"input.txt\").inputStream()\n//private val OUTPUT = File(\"output.txt\").outputStream()\nprivate val INPUT = System.`in`\nprivate val OUTPUT = System.out\n\nprivate val bufferedReader = INPUT.bufferedReader()\nprivate val outputWriter = PrintWriter(OUTPUT, false)\nprivate fun readLn() = bufferedReader.readLine()!!\n\nprivate fun readList() = readLn().split(' ')\nprivate var tokenizer = StringTokenizer(\"\")\nprivate fun read(): String {\n while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), \" \")\n return tokenizer.nextToken()\n}\n\nprivate fun readInt() = read().toInt()\nprivate fun readLong() = read().toLong()\nprivate fun readDouble() = read().toDouble()\n\nprivate fun readIntList() = readList().map { it.toInt() }\nprivate fun readLongList() = readList().map { it.toLong() }\nprivate fun readDoubleList() = readList().map { it.toDouble() }\n\nprivate fun readIntArray(n: Int = 0) =\n if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }\n\nprivate fun readLongArray(n: Int = 0) =\n if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }\n\nprivate fun readDoubleArray(n: Int = 0) =\n if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }\n\n\nprivate fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)\n\n\nprivate class `CF268-D2-A` {\n fun solveTestCase(): Int {\n var result = 0\n val n = readInt()\n val costume = mutableListOf>()\n repeat(n) {\n costume.add(Pair(readInt(), readInt()))\n }\n \n for(i in 0 until n) {\n for (j in i+1 until n) {\n if (costume[i].first == costume[j].second) result++\n if (costume[i].second == costume[j].first) result++\n }\n }\n\n return result\n }\n}\n\nfun main(args: Array) {\n\n outputWriter.println(\n `CF268-D2-A`()\n .solveTestCase()\n )\n\n outputWriter.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0820b0a81488361795d7f695321d73b0", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val teams = readLine()!!.toInt()\n var homes = ArrayList()\n var guest = mutableListOf()\n repeat(teams)\n {\n val(a, b) = readLine()!!.split(\" \").map { it.toInt() }\n homes.add(a)\n guest.add(b)\n }\n var answer = 0\n for (g in guest)\n {CFR_268 \n for (a in homes)\n {\n if(a == g){ answer ++}\n }\n }\n println(answer)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "14deba1440646b99c80231f8ac398730", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tval input = readLine()!!.toInt()\n\tprintln(getVariants(input))\n}\n\nfun getWinner(input: Int): String {\n\treturn if (input % 2 == 0) \"Mahmoud\" else \"Ehab\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "28f9cb0e9a6ad931bf0b61b5dba97b93", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.mix\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\nfun main() {\n val word = readLn()\n var count = 0\n var lastPicked = 'a'\n word.forEach { letterAt ->\n val distance = Math.abs((lastPicked - letterAt))\n count += distance.coerceAtMost(26 - distance)\n lastPicked = letterAt\n }\n println(count)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7c04a6a0b80c539422df2cec9e0b1f5f", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package _Kozmirchuk\n\nimport java.util.*\n\n/**\n * Created by kozmirchuk on 12/28/16.\n */\n\n\nfun > Iterable.kths(k : Int) : T {\n\n val array = ArrayList()\n array.addAll(this)\n\n if (k !in 1..array.size) {\n throw IllegalArgumentException()\n }\n\n fun MutableList.swap(i : Int, j : Int) {\n val temp = this[i]\n this[i] = this[j]\n this[j] = temp\n }\n\n fun search(l : Int, r : Int, n : Int) : T {\n\n if (l + 1 >= r) {\n\n if (array[l] > array[r])\n array.swap(l, r)\n\n return if (n == 1) array[l] else array[r]\n }\n\n val pivot = array[(l + r) / 2]\n array.swap((l + r) / 2, l)\n\n var i = l + 1\n var last = i\n while (i <= r) {\n\n if (array[i] < pivot) {\n array.swap(i, last)\n last += 1\n }\n\n i += 1\n }\n\n array.swap(l, last - 1)\n\n return when {\n last - l == n -> array[last - 1]\n last - l > n -> search(l, last - 2, k)\n else -> search(last, r, n - last - l)\n }\n }\n\n\n return search(0, array.size - 1, k)\n}\n\nfun main(args: Array) {\n\n\n fun who(n : Int) = when(n) {\n 1 -> \"Sheldon\"\n 2 -> \"Leonard\"\n 3 -> \"Penny\"\n 4 -> \"Rajesh\"\n else -> \"Howard\"\n }\n\n\n val n = readLine()!!.toInt()\n\n\n fun solve(n : Int) {\n var cnt = 1\n\n while (5 * (2 * cnt - 1) < n) {\n cnt *= 2\n }\n\n var N = 5 * (cnt - 1) + 1\n\n for (i in 1..5) {\n if ( (n >= N) && n < (cnt + N))\n println(who(i))\n N += cnt\n }\n\n }\n\n solve(n)\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cd5b33d3eab8f114e9d7258370243b93", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package com.happypeople.codeforces.c1108\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\nimport kotlin.math.max\n\nfun main(args: Array) {\n try {\n B().run()\n } catch (e: Throwable) {\n println(\"\")\n }\n}\n\nclass B {\n fun run() {\n val sc = Scanner(systemIn())\n val n=sc.nextInt()\n val mset=Multiset()\n for(i in 1..n) {\n mset.add(sc.nextInt())\n }\n val biggest=mset.toSet().max()!!\n\n var other=Int.MIN_VALUE\n val set=mset.toSet().toList()\n for(i in mset.toSet())\n if((biggest%i)!=0 || mset.count(i)>1)\n other=max(other, i)\n\n println(\"$other $biggest\")\n }\n\n class Multiset {\n private val map = mutableMapOf()\n\n public fun add(e: E) {\n val c = map.getOrDefault(e, 0)\n map[e] = c + 1\n }\n\n public fun remove(e: E) {\n val c = map.getOrDefault(e, 0)\n if (c > 1)\n map[e] = c - 1\n else if (c == 1)\n map.remove(e)\n }\n\n public fun contains(e: E) =\n map.contains(e)\n\n public fun count(e: E) =\n map.getOrDefault(e, 0)\n\n public fun toList(): List {\n return map.flatMap { ent -> (1..ent.value).map { ent.key } }\n }\n\n public fun toSet(): Set = map.keys\n }\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "62c49e3dee5f7327dc9c10ad8f854f01", "src_uid": "868407df0a93085057d06367aecaf9be", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val n = r.readLine()!!.toInt()\n //val v = r.readLine()!!.split(\" \").map { it.toLong() }\n val list = r.readLine()!!.split(\" \").map { it.toBigInteger() }\n val set = list.toSet()\n val d1 = list-set\n val n1 = set.fold(BigInteger.ONE){acc, bigInteger -> acc * bigInteger }\n val n2 = d1.fold(BigInteger.ONE){acc, bigInteger -> acc * bigInteger }\n println(\"$n1 $n2\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "079739b63cb4c57e745b560a68b4e85a", "src_uid": "868407df0a93085057d06367aecaf9be", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import org.junit.jupiter.api.Test\n\nimport org.junit.jupiter.api.Assertions.*\n\ninternal class _1058KtTest {\n\n @Test\n fun solution() {\n assertEquals(true,solution(\"73452\"))\n assertEquals(false,solution(\"1248\"))\n assertEquals(true, solution(\"00\"))\n assertEquals(true,solution(\"999999999999999999999999999999999999999999999918888888888888888888888888888888888888888888888888887\"))\n assertEquals(false, solution(\"24954512677\"))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4d8eb7290a912bfe8a4271f15b0a1d6f", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package my.demo\n\nimport kotlin.text.*\nfun main(){\n val x = readLine()\n var cnt: Int = 0\n var buang: Int = 0\n for(i in x.toString()){\n if(i=='a')\n cnt += 1\n }\n var n :Int = x.toString().length\n var half: Double = n/2.0\n while(half>=cnt)\n {\n buang+=1\n half=(n-buang)/2.0\n }\n var ans:Int =n-buang\n println(ans)\n return\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "825342e620f5d3d637ce153002cd60ca", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.nio.file.Files.readString\n\nfun main(args: Array) {\n var n = readLine()!!.toInt()\n var s = readLine()!!\n var zero : Int = 0\n var one = true\n for (i in s) {\n if (i == '0') zero++\n if (i == '1') one = true\n }\n if (one) print('1')\n while (zero > 0) {\n print(0)\n zero--\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4c45f7c49443452208e2587851cdfb9b", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Kotlin 1.4", "source_code": "import kotlin.math.*;\nimport java.math.BigInteger;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val MOD = 998244353;\n@JvmField val exp2sact_cache = HashMap>();\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readInt2() = Pair(readInt(),readInt())\nfun readInt3() = Triple(readInt(),readInt(),readInt())\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readLong2() = Pair(readLong(),readLong())\nfun readLong3() = Triple(readLong(),readLong(),readLong())\nfun readString() = readLine()!!;\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\nfun printVars(vararg vs: Any?){for(v in vs) print(\"$v \");println(\"\");}\nfun moduloAdd(v1: Int,v2: Int) = ((v1+0L+v2)%MOD).toInt();\nfun moduloMultiply(v1: Int,v2: Int) = ((v1*1L*v2)%MOD).toInt();\nfun exp2s(v: Int): List{var targ = v;var es = mli();var e = 0;while(targ>0){if (targ%2==1) es.add(e);targ/= 2;e++;};return es;}\nfun exp2sact(v: Int): List\n{\n if (exp2sact_cache[v]!=null) return exp2sact_cache[v]!!;\n var targ = v;\n var es = mli();\n var e = 1;\n while(targ>0)\n {\n if (targ%2==1) es.add(e);\n targ/= 2;e*= 2;\n };\n exp2sact_cache[v] = es;\n return es;\n}\nfun iLog2(v:Int):Int{var ret=0;var vv= v shr 1;while(vv>0){ret++;vv=vv shr 1};return ret}\nfun iLog2(v:Long):Int{var ret=0;var vv= v shr 1;while(vv>0){ret++;vv=vv shr 1};return ret}\nfun tri(n: Int) = (n*(n+1))/2;\nfun tri(n: Long) = (n*(n+1))/2;\nfun isEven(v: Int) = v%2==0;\nfun isOdd(v: Int) = v%2==1;\nfun isEven(v: Long) = v%2L==0L;\nfun isOdd(v: Long) = v%2L==1L;\ninfix fun Int.between(range: Pair): Boolean = ((this >= range.first) && (this <= range.second));\ninfix fun Long.between(range: Pair): Boolean = ((this >= range.first) && (this <= range.second));\nfun mli() = mutableListOf();\nfun mlid(n: Int,def: (it: Int) -> Int) = MutableList(n,def);\nfun mll() = mutableListOf();\nfun mlld(n: Int,def: (it: Int) -> Long) = MutableList(n,def);\nfun trsti() = TreeSet();\nfun trstl() = TreeSet();\nfun hmii() = HashMap();\nfun hmil() = HashMap();\nfun hmli() = HashMap();\nfun hmll() = HashMap();\nclass MultiSet(initContent: List = listOf()){private val mp = HashMap();init {for(x in initContent) add(x);}operator fun get(value: T): Int{return if (mp[value]!=null) mp[value]!! else 0;}fun add(value: T,count: Int = 1): Int{if (count < 0) throw Exception(\"count must be non-negative\");if (mp[value]==null) mp[value] = 0;var ret = mp[value]!!+count;mp[value] = ret;return ret;}fun remove(value: T,count: Int = 1): Int{if (count < 0) throw Exception(\"count must be non-negative\");var ret = this[value];ret = max(0,ret-count);if (ret==0){mp.remove(value);}else{mp[value] = ret;};return ret;}fun delete(value: T): Int{var ret = this[value];mp.remove(value);return ret;}val size get() = mp.size;operator fun iterator(): MutableIterator> = mp.iterator();override fun toString() = \"$mp\";}\nfun List.floor(v: Int): Int{var pos=binarySearch(v);if (pos>= 0){return pos;}else{return -(pos+1)-1;};}\nfun List.ceiling(v: Int): Int{var pos=binarySearch(v);if (pos>=0){return pos;}else{var ret = -(pos+1);return if (ret < size) ret else -1;}}\nfun List.floor(v: Long): Int{var pos=binarySearch(v);if (pos>= 0){return pos;}else{return -(pos+1)-1;};}\nfun List.ceiling(v: Long): Int{var pos=binarySearch(v);if (pos>=0){return pos;}else{var ret = -(pos+1);return if (ret < size) ret else -1;}}\nfun gcd(a: Int,b: Int): Int{if (b==0) return a;return gcd(b,a%b);}\nfun gcd(a: Long,b: Long): Long{if (b==0L) return a;return gcd(b,a%b);}\n\n@JvmField val DEBUG = FALSE;\n\nclass Prob\n{\n fun exec()\n { \n var s = readString();\n var ls = s.map { it-'A' }.toList();\n if (ls.size>2)\n {\n var flag = true;\n for(i in 2..ls.size-1)\n {\n if (ls[i]!=(ls[i-2]+ls[i-1])%26)\n {\n flag = false;\n break;\n }\n }\n println(if (flag) \"YES\" else \"NO\");\n }\n else\n {\n println(\"NO\");\n }\n }\n}\n\nfun main() \n{\n Prob().exec();\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f62fc0ffd829213e3527b75c21e50059", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "package today\n\nfun main(args: Array) {\n val (a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() }\n val (left, center, right) = listOf(a, b, c).sorted()\n var result = 0\n val d1 = center - left\n val d2 = right - center\n if (d1 < d) {\n result += (d - d1)\n }\n if (d2 < d) {\n result += (d - d2)\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6fb2ca208a2477267c8b3bb28fbfb6fd", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cf1185\n\nimport kotlin.math.max\n\nfun main() {\n val item = readLine()!!.split(\" \").map { it.toInt() }\n val d = item.last()\n val (a, b, c) = item.dropLast(1).sorted()\n\n print(max(d - (b - a), 0) + max(d - (c - b), 0))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c312a93b72ec2104d74ca368124986ea", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val scanner = Scanner(System.`in`)\n val count = scanner.nextInt()\n val array1 = ArrayList(count)\n val array2 = ArrayList(count)\n for(index in 0 until count){\n array1[index] = scanner.nextInt()\n }\n for(index in 0 until count){\n array2[index] = scanner.nextInt()\n }\n\n var bal1 = 0\n var bal2 = 0\n for(index in array1.indices){\n if(array1[index] > array2[index])\n bal1+= 1\n if(array1[index] < array2[index])\n bal2+= 1\n }\n if(bal1 == 0){\n println(-1)\n return\n }\n println(((bal2/bal1+1) + 0.5).toInt())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "29912b57e98eb545be784eaf86da92cd", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n var x = readLine()!!.toLong()\n var origX = x\n var s = x.toBigInteger().sqrt().toInt() + 1\n var firstDivisor : Long? = null\n var secondDivisor : Long? = null\n\n mainfor@for(i in 2L..s) {\n while (x % i == 0L) {\n if(firstDivisor == null) {\n firstDivisor = i\n } else {\n if(i == firstDivisor) {\n secondDivisor = i * i\n } else {\n if(secondDivisor != null) {\n secondDivisor = min(secondDivisor, i)\n } else {\n secondDivisor = i\n break@mainfor\n }\n }\n }\n x /= i\n }\n\n if(x <= 1) {\n break\n }\n }\n\n if(firstDivisor != null && secondDivisor != null){\n println(\"${origX / secondDivisor} ${origX / firstDivisor}\")\n } else {\n println(\"1 $origX\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "61a614dd5a708cd963c7f637a9dab460", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val n = r.readLine()!!.toLong()\n\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n //val (action, remain) = r.readLine()!!.split(\" \").map { it.toLong() }\n fun fac(l: Long): MutableList> {\n val ans = mutableListOf>()\n (1..sqrt(l.toDouble()).toLong()).forEach {\n if (l % it == 0L && it != l / it) ans += Pair(it, l / it)\n }\n return ans\n }\n\n val res = fac(n)\n val ans = res.fold(Pair(Long.MAX_VALUE, Long.MAX_VALUE)) { (a, b), (c, d) ->\n if (maxOf(c, d) < maxOf(a, b)) Pair(c, d)\n else Pair(a, b)\n }\n println(\"${ans.first} ${ans.second}\")\n /*repeat(r.readLine()!!.toInt()) {\n //val len = r.readLine()!!.toInt()\n val (n, s, t) = r.readLine()!!.split(\" \").map { it.toLong() }\n val more = s+t-n\n println(minOf(n- minOf(s, t)+1, maxOf(s, t)+1))\n }*/\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a0bda820cb2641df1a9d3319913640aa", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.lang.Math.abs\nimport java.lang.Math.min\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val r = sc.nextInt()\n val c = sc.nextInt()\n\n val black = min(n - r, n - c) + 1\n val white = min(r - 1, c - 1)\n\n print(if(white < black) \"white\" else \"black\")\n main()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a11f0d9fe88db4e7642049e60c97afaa", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (a, b, max) = Scanner(System.`in`).use {\n listOf(it.nextInt(), it.nextInt(), it.nextInt()).sorted()\n }\n\n println(if (max >= a + b) max - a - b + 1 else 0)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "788f126a8bbed10488dfa30de5daa58c", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package io.github.ranolp.codeforce.season516.div2\n\nimport java.util.*\n\nfun main(args: Array) {\n val (a, b, max) = Scanner(System.`in`).use {\n listOf(it.nextInt(), it.nextInt(), it.nextInt()).sorted()\n }\n\n println(if (max >= a + b) max - a - b + 1 else 0)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "82f485470cd5db4cbbfedc76ce2bbc65", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main() {\n val (turns, left) = readInts()\n val disc = 9L + 8L * turns + 8L * left\n println(disc)\n val discSqrt = sqrt(disc.toDouble()).toLong()\n println(discSqrt)\n val k = (discSqrt - 3) / 2\n println(turns - k)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf840a91ffc95beec69059ce131cbebd", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package c1332.e\n\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\nconst val ACTUAL = 998244353L\n\ndata class MyLong(val num: Long) {\n operator fun times(x: Long): MyLong =\n MyLong(num * (x % REM) % REM)\n\n operator fun minus(x: MyLong): MyLong =\n MyLong((num - x.num + 2 * REM) % REM)\n\n operator fun plus(x: MyLong): MyLong =\n MyLong((num + x.num) % REM)\n\n override fun toString() = num.toString()\n\n companion object {\n private const val REM = 2 * ACTUAL\n }\n}\n\nval Int.X get() = MyLong(toLong())\n\nfun solve(input: LongArray): Long {\n val (n, m, l, r) = input\n if (l == r)\n return 1L\n var result: MyLong = 1.X\n for (i in 1..n * m)\n result *= (r - l + 1)\n\n return if ((n * m) % 2 == 1L)\n result.num % ACTUAL\n else\n (result.num / 2 + (r-l+1)%2) % ACTUAL\n}\n\nfun main() {\n val reader = FastReader()\n println(solve(reader.nextLongArr(4)))\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\ninternal class FastReader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreElements())\n t = StringTokenizer(br.readLine())\n tokenizer = t\n return t.nextToken()\n }\n\n fun nextInt() = next().toInt()\n\n fun nextLong(): Long = next().toLong()\n\n fun nextDouble(): Double = next().toDouble()\n\n fun nextLine(): String = br.readLine()\n\n fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }\n\n fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }\n\n fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }\n\n fun nextIntArr2(n: Int, m: Int): Array = Array(n) { IntArray(m) { nextInt() } }\n\n fun nextLongArr2(n: Int, m: Int): Array = Array(n) { LongArray(m) { nextLong() } }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "199d85174b761043f308094e8893025f", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\n\nfun main() {\n\tval (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n\tval answer = (3 * n) + min(k - 1, n - k)\n\tprintln(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c8bfb511bb5cebad837e53dfff5a244f", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "val squares = ArrayList()\n\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n val n = reader.nextInt()\n\n val max: Int = Math.sqrt(n.toDouble()).toInt()\n for (i in 1..max) {\n squares.add((i*i).toString())\n }\n\n println(containsSubstring(n.toString()))\n}\n\nfun containsSubstring(n: String): String {\n\n for (square in squares.reversed()) {\n var indexOf = 0\n\n var winner = true\n for (char in square.toCharArray()) {\n indexOf = n.indexOf(char, indexOf, true)\n if (indexOf == -1){\n winner = false\n break\n }\n }\n if (winner) {\n return (n.length - square.length).toString()\n }\n }\n\n return \"-1\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "13e0edcead24649c27a51563e0ed52f3", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.*\nimport java.awt.geom.*\nimport java.io.*\nimport java.math.*\nimport java.text.*\nimport java.util.*\nimport java.util.regex.*\n\n/*\n\t\t\t br = new BufferedReader(new FileReader(\"input.txt\"));\n\t\t\t pw = new PrintWriter(new BufferedWriter(new FileWriter(\"output.txt\")));\n\t\t\t br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\t pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n */\n\n private var br: BufferedReader? = null\n private var st: StringTokenizer? = null\n private var pw: PrintWriter? = null\n\n @Throws(IOException::class)\n fun main(args: Array) {\n br = BufferedReader(InputStreamReader(System.`in`))\n pw = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n //int qq = 1;\n val qq = Integer.MAX_VALUE\n //int qq = readInt();\n\n /*\nreminders: arrays of objects are problematic, prefer ArrayList instead\n\t\t */\n for (casenum in 1..qq) {\n val s = readToken()\n var ret = -1\n for (mask in 1 until (1 shl s.length)) {\n var del = 0\n var curr = 0\n var can = true\n for (i in 0 until s.length) {\n if (mask and (1 shl i) != 0) {\n if (curr == 0 && s[i] == '0') {\n can = false\n }\n curr *= 10\n curr += s[i] - '0'\n } else {\n del++\n }\n }\n val cand = Math.sqrt(curr.toDouble()).toInt()\n if (can && cand * cand == curr) {\n if (ret == -1 || del < ret) ret = del\n }\n }\n pw!!.println(ret)\n }\n exitImmediately()\n }\n\n private fun exitImmediately() {\n pw!!.close()\n System.exit(0)\n }\n\n @Throws(IOException::class)\n private fun readLong(): Long {\n return java.lang.Long.parseLong(readToken())\n }\n\n @Throws(IOException::class)\n private fun readDouble(): Double {\n return java.lang.Double.parseDouble(readToken())\n }\n\n @Throws(IOException::class)\n private fun readInt(): Int {\n return Integer.parseInt(readToken())\n }\n\n @Throws(IOException::class)\n private fun readLine(): String? {\n val s = br!!.readLine()\n if (s == null) {\n exitImmediately()\n }\n st = null\n return s\n }\n\n @Throws(IOException::class)\n private fun readToken(): String {\n while (st == null || !st!!.hasMoreTokens()) {\n }\n return st!!.nextToken()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4f6a92644dd9c83dfabadffb34e1796e", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val n = r.readLine()!!.toInt()\n //val (n, time) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val v = r.readLine()!!.split(\" \").map { it.toInt() }\n val s1 = r.readLine()!!.split(\"\").filter { it.length > 0 }\n val pos1 = s1.count { it == \"+\" } * 2 - s1.size\n val s2 = r.readLine()!!.split(\"\").filter { it.length > 0 }\n val pos2 = s2.count { it == \"+\" } - s1.count { it == \"-\" }\n val unk = s2.count { it == \"?\" }\n when{\n unk == 0 -> println(1.0)\n abs(unk+pos2-pos1)%2==1 -> println(0.0)\n else -> {\n val choose = (unk-abs(pos1))/2\n val ans = (unk-choose+1..unk).fold(1L){acc, i -> acc*i }/(1..choose).fold(1L){acc, i -> acc*i }/2.0.pow(unk)\n println(ans)\n /*println((unk-choose+1..unk).fold(1L){acc, i -> acc*i }/(1..choose).fold(1L){acc, i -> acc*i })\n println((unk-choose+1..unk).fold(1L){acc, i -> acc*i })\n println(unk)*/\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3231ef712862a8b885428be15557b2e5", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package p371\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.math.BigInteger\n\n\nfun main(vararg params: String) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n val inputs = br.readLine().split(\" \").take(5).map { BigInteger(it) }\n\n val l1 = inputs[0]\n val r1 = inputs[1]\n val l2 = inputs[2]\n val r2 = inputs[3]\n val k = inputs[4]\n\n\n val lowLimit = l1.max(l2)\n val highLimit = r1.min(r2)\n val minutes = highLimit - lowLimit + BigInteger.ONE\n if (minutes <= BigInteger.ZERO)\n println(0)\n else\n if (k <= highLimit && k >= lowLimit) println(minutes - BigInteger.ONE) else println(minutes)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "50040caf016ee21c3ce78505754e2507", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val (s, n) = r.readLine()!!.split(\" \").map { it.toInt() }\n val (a, b, c) = r.readLine()!!.split(\" \").map { it.toLong() }.sorted()\n if (a==c) {\n val edge = sqrt(a.toDouble()).toInt()\n println(\"$edge $edge $edge\")\n } else{\n val x = gcd(a, c)\n println(\"${a/x} $x ${c/x}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ea3054f37d675bc53b5d7efae636e7f2", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package challenge.codeb\n\nimport java.io.File\nimport java.io.IOException\nimport java.util.StringTokenizer\nimport java.io.InputStreamReader\nimport java.io.BufferedReader\n\nval debugCode = false\n\nfun debugCode(str: String) {\n if (debugCode) {\n println(str)\n }\n}\n\nfun solve(arr: IntArray): Int {\n arr.sort()\n var result = 0\n var i = 0\n while (i < arr.size) {\n result += Math.abs(arr[i]- arr[i+1])\n i += 2\n }\n return result\n}\n\nfun main(args: Array) {\n val scan = FastReader(\"1.txt\")\n val n = scan.nextInt()\n val arr = IntArray(n, {scan.nextInt()} )\n println(solve(arr))\n}\n\n\nclass FastReader(val input: String) {\n var br: BufferedReader\n var st: StringTokenizer? = null\n\n init {\n if (!debugCode) {\n br = BufferedReader(InputStreamReader(System.`in`))\n } else {\n br = BufferedReader(InputStreamReader(File(input).inputStream()))\n }\n }\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n return str\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ceb9c5d0860ed947ae515f8283ab859b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.stream.IntStream.range\n\nfun main() {\n\n val n = readLine()!!\n\n val s = n.toCharArray().map { it.toString().toInt() }.toIntArray()\n\n\n if (s.sum() % 4 == 0) {\n println(n)\n } else {\n\n val nn = n.toInt()\n val l = range(0, 10).map { it + nn }.toArray()!!\n\n val filter = l.filter { it.toString().toCharArray().map { c -> c.toString().toInt() }.sum() % 4 == 0 }\n println(filter.first())\n\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "deb5e1bcdb32d46163b6f12c88060e27", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n while(sumNum(n)%4 != 0) n++;\n println(n)\n}\n\nfun sumNum(n: Int): Int {\n var sum = 0;\n while(n > 0) {\n sum += n%10\n n /= 10\n }\n return sum\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f7ca9db4676ebd60377875c45492de46", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.stream.IntStream.range\nimport kotlin.streams.toList\n\nfun main() {\n\n val n = readLine()!!\n\n val s = n.toCharArray().map { it.toString().toInt() }.toIntArray()\n\n\n if (s.sum() % 4 == 0) {\n println(n)\n } else {\n\n val nn = n.toInt()\n val l = range(0, 10).map { it + nn }.toList()\n\n val filter = l.filter { it.toString().toCharArray().map { c -> c.toString().toInt() }.sum() % 4 == 0 }\n println(filter.first())\n\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4c02aebbcd470d8aa03ebd69d928dcd5", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n var tmp = n\n var d = 2\n val dividers = ArrayList()\n while (tmp >= d) {\n while (tmp % d == 0) {\n tmp /= d\n dividers.add(d)\n }\n d++\n }\n if (dividers.size >= k) {\n print(\"${dividers.subList(0, dividers.size - k + 1).fold(1) { a, b -> a * b }} \")\n dividers.subList(dividers.size - k + 1, dividers.size).forEach { print(\"$it \") }\n } else {\n println(-1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dfe32f0f25dce3b76878e9bbc9ad6411", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n uuuuuval n = readInt()\n val P = IntArray(n) { readInt() - 1 }\n val A = readIntArray(n)\n\n val Q = IntArray(n)\n for(i in 0 until n) { Q[P[i]] = i }\n\n val t = PropagatingSegmentTree(n-1).apply {\n var acc = 0L\n build {\n acc += A[it]\n acc\n }\n }\n\n var ans = t.query(0, n-2)\n for(i in 0 until n) {\n val q = Q[i]\n t.update(q, n-2, -A[q].toLong())\n t.update(0, q-1, A[q].toLong())\n\n ans = min(ans, t.query(0, n-2))\n }\n\n println(ans)\n}\n\nclass PropagatingSegmentTree(\n val size: Int\n) {\n inline fun combiner(a: Long, b: Long): Long = min(a, b)\n inline fun updateCombiner(a: Long, b: Long): Long = a + b\n inline fun updater(t: Long, u: Long): Long = t + u\n\n private inline fun treeSize() = if(size == 0) 0 else Integer.highestOneBit(size.shl(2) - 1)\n\n private val tree = LongArray(treeSize()) { Long.MAX_VALUE }\n private val lazy = LongArray(tree.size)\n\n fun build(list: LongArray) {\n if(size == 0) return\n build(list, 1, 0, size-1)\n }\n\n fun build(generator: (Int) -> Long) { build(LongArray(size, generator)) }\n\n private inline fun mid(low: Int, high: Int) = (low + high) shr 1\n private fun build(list: LongArray, node: Int, a: Int, b: Int) {\n if(a == b) {\n tree[node] = list[a]\n return\n }\n\n build(list, node shl 1, a, mid(a, b))\n build(list, node shl 1 or 1, 1 + mid(a, b), b)\n updateNode(node)\n }\n\n private inline fun updateNode(i: Int) {\n tree[i] = combiner(tree[i shl 1], tree[i shl 1 or 1])\n }\n\n fun update(first: Int, last: Int, value: Long) {\n update(1, 0, size-1, first, last, value)\n }\n fun update(range: IntRange, value: Long) {\n update(range.first, range.last, value)\n }\n\n private inline fun updateLazy(i: Int, u: Long) {\n lazy[i] = updateCombiner(lazy[i], u)\n }\n\n private fun propagate(node: Int, a: Int, b: Int) {\n tree[node] = updater(tree[node], lazy[node])\n if(a != b) {\n updateLazy(node shl 1, lazy[node])\n updateLazy(node shl 1 or 1, lazy[node])\n }\n lazy[node] = 0L\n }\n\n private fun update(node: Int, a: Int, b: Int, i: Int, j: Int, u: Long) {\n if(lazy[node] != 0L) {\n propagate(node, a, b)\n }\n\n if(a > b || a > j || b < i) return\n\n if(a >= i && b <= j) {\n lazy[node] = u\n propagate(node, a, b)\n return\n }\n\n update(node shl 1, a, mid(a, b), i, j, u)\n update(node shl 1 or 1, 1 + mid(a, b), b, i, j, u)\n\n updateNode(node)\n }\n\n fun query(first: Int, last: Int) =\n query(1, 0, size-1, first, last)\n fun query(range: IntRange) =\n query(range.first, range.last)\n\n private fun query(node: Int, a: Int, b: Int, i: Int, j: Int): Long {\n if(a > b || a > j || b < i) return Long.MAX_VALUE\n if(lazy[node] != 0L) {\n propagate(node, a, b)\n }\n\n if(a >= i && b <= j) {\n return tree[node]\n }\n\n val l = query(node shl 1, a, mid(a, b), i, j)\n val r = query(node shl 1 or 1, 1 + mid(a, b), b, i, j)\n\n return combiner(l, r)\n }\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "300ef5ec2a0bfcc3a02ea2841652301f", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\nimport codeforces.sliding\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = Scanner(inputStream)\n val out = PrintWriter(outputStream)\n solve(`in`, out)\n out.close()\n}\n\nprivate fun solve(scanner: Scanner, out: PrintWriter) {\n val n = scanner.nextInt()\n val L = scanner.nextInt()\n scanner.nextLine()\n val kef = scanner.nextLine().split(\" \").map(String::toInt)\n val sash = scanner.nextLine().split(\" \").map(String::toInt)\n\n var m = kef.sliding(2).map { it[1] - it[0] }.toMutableList()\n var r = sash.sliding(2).map { it[1] - it[0] }.toMutableList()\n val kefDiffs = m + (L - m.sum())\n val sashDiffs = r + (L - r.sum())\n\n val s = kefDiffs.joinToString(transform = Int::toString, separator = \"\")\n val res = (s + s).contains(sashDiffs.joinToString(transform = Int::toString, separator = \"\"))\n\n if (res) {\n out.println(\"YES\")\n } else {\n out.println(\"NO\")\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "effa7a84348ca70b5c17143d96a5bb8a", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n\nvar checkVertical = fun (x : Int,y : Int,map : Array) : Boolean {\n if(x + 4 < 10) {\n var seen = false\n for (i in x..x + 4) {\n if(map[i][y] == '.') if(!seen) seen = true else return false\n if(map[i][y] == 'O') return false\n }\n return true\n }\n return false\n}\n\nvar checkHorizontal = fun (x : Int,y : Int,map : Array) : Boolean {\n if(y + 4 < 10) {\n var seen = false\n for (i in y..y + 4) {\n if(map[x][i] == '.') if(!seen) seen = true else return false\n if(map[x][i] == 'O') return false\n }\n return true\n }\n return false\n}\n\nvar check2 =fun (x : Int,y : Int,map : Array) : Boolean {\n if(y + 4 < 10 && x - 4 >= 0) {\n var seen = false\n for (i in 1..4) {\n if(map[x - i][y + i] == '.') if(!seen) seen = true else return false\n if(map[x - i][y + i] == 'O') return false\n }\n return true\n }\n return false\n}\n\nvar check3 = fun (x : Int,y : Int,map : Array) : Boolean {\n if(y - 4 >= 10 && x + 4 < 10) {\n var seen = false\n for (i in 1..4) {\n if(map[x + i][y - i] == '.') if(!seen) seen = true else return false\n if(map[x + i][y - i] == 'O') return false\n }\n return true\n }\n return false\n}\n\n\nfun solve() {\n val map = Array(10,{next()})\n val a = arrayOf(checkVertical,checkHorizontal,check2,check3)\n var ok = false\n map.forEachIndexed {\n i,_ ->\n map[i].forEachIndexed {\n j,c -> if(c == 'X') {\n a.forEach {\n ok = ok.or(it(i, j, map))\n }\n }\n }\n }\n pw.println(if(ok) \"Yes\" else \"No\")\n}\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n}\n\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextLine() = if(hasNext()) st.nextToken(\"\\n\") else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n,{nextInt()})\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nval br = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`))\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nval pw = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\nfun main(args: Array) {\n var start = System.currentTimeMillis()\n solve()\n pw.close()\n br.close()\n if(!ONLINE_JUDGE)\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f7c12f82ef43b7e11c13f96d3978685d", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package A\nimport java.util.Scanner\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n var a = input.nextInt()\n val a1 = a\n var b = input.nextInt()\n val b1 = b\n val c = input.nextInt()\n\n var ans = 0\n while(a <= c && b <= c) {\n if(a == b) {\n ans++\n a += a1\n b += b1\n } else if(a < b) {\n a += a1\n } else {\n b += b1\n }\n }\n print(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cf647ef17535adbcbba823c15ee37fa5", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n var (n, m, k) = jin.readLine().split(\" \").map { it.toInt() }\n var dir = jin.readLine().last() == 'l'\n val state = jin.readLine()\n var prev = mutableListOf(m)\n var answer = 0\n for (chara in state) {\n answer++\n val prevK = k\n if (k == 1) {\n dir = true\n } else if (k == n) {\n dir = false\n }\n if (dir) {\n k++\n } else {\n k--\n }\n val next = mutableSetOf()\n if (chara == '0') {\n for (x in prev) {\n if (x != k) {\n next.add(x)\n }\n if (x != 1 && x - 1 != prevK && x - 1 != k) {\n next.add(x - 1)\n }\n if (x != n && x + 1 != prevK && x + 1 != k) {\n next.add(x + 1)\n }\n }\n } else {\n next.addAll(1..n)\n next.remove(k)\n }\n if (next.isEmpty()) {\n println(\"Controller\")\n println(answer)\n return\n }\n prev = next.toList()\n }\n println(\"Stowaway\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d8593f98b101ac15dd83b057f9cbd78", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n var (n, m, k) = jin.readLine().split(\" \").map { it.toInt() }\n var dir = jin.readLine().last() == 'l'\n val state = jin.readLine()\n var prev = mutableListOf(m)\n var answer = 0\n for (chara in state) {\n answer++\n val prevK = k\n if (k == 1) {\n dir = true\n } else if (k == n) {\n dir = false\n }\n if (dir) {\n k++\n } else {\n k--\n }\n val next = mutableSetOf()\n if (chara == '0') {\n for (x in prev) {\n if (x != k) {\n next.add(x)\n }\n if (x != 1 && x - 1 != prevK && x - 1 != k) {\n next.add(x - 1)\n }\n if (x != n && x + 1 != prevK && x + 1 != k) {\n next.add(x + 1)\n }\n }\n } else {\n next.addAll(1..n)\n next.remove(k)\n }\n if (next.isEmpty()) {\n println(\"Controller\")\n println(answer)\n return\n }\n prev = next\n }\n println(\"Stowaway\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d706ed042b040165db740bde52eb9abb", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n\n val pass: String = input.next()\n\n val n: Int = input.nextInt()\n val left = ArrayList()\n val right = ArrayList()\n\n for (i in 1..n) {\n val word = input.next()\n if (word == pass) {\n print(\"YES\")\n return\n }\n if (word[0] == pass[1]) {\n left.add(word)\n }\n if (word[1] == pass[0]) {\n right.add(word)\n }\n }\n\n if (left.size != 0 && right.size != 0) {\n print(\"YES\")\n return\n }\n\n print(\"NO\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ca31f874947ea893dcca5e6d8692d003", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashMap\n\n/**\n * Created by Igor on 7/17/2017.\n */\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val l = scanner.nextInt()\n val r = scanner.nextInt()\n\n val nums = HashMap()\n\n for (i in l..r) {\n (2..i)\n .filter { i % it == 0 }\n .forEach {\n if (nums[it] == null)\n nums[it] = 1\n else\n nums[it] = nums[it]!! + 1\n }\n }\n val max = nums.values.max()\n nums.keys.forEach {\n if (nums[it] == max) {\n println(it)\n return\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "05ac6218f6168d8f616ad7f3479e9a47", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n val s = 'a' + readLine()!! + 'a'\n var sol = 0\n var last = 0\n val vowels = setOf('a', 'e', 'i', 'o', 'u', 'y')\n for (pos in 1 until s.length) {\n if (s[pos] in vowels) {\n sol = max(sol, pos - last)\n last = pos\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ca4544148fb0667db09ae1f92e98b5c2", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //var (x, y) = r.readLine()!!.split(\" \").map { it.toLong() }\n //val n = r.readLine()!!.toInt()\n //val (a, b, c, d) = r.readLine()!!.split(\" \").map { it.toInt() }\n val str = r.readLine()!!\n val list = listOf('A', 'E', 'I', 'O', 'U', 'Y')\n var dis = 0\n var max = 0\n for (i in str.length-1 downTo 0){\n if (str[i] in list){\n dis = 1\n } else {\n dis++\n max = maxOf(max, dis)\n }\n }\n if (str.length==1){\n println(1)\n }else{\n println(maxOf(1, max))}\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7ef4a2d85458489509185ad76e532080", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n var str = readLine()!!\n var const = \"AEIOUY\"\n var list = ArrayList()\n for (i in 0..str.length - 1) {\n if (const.contains(str[i])) {\n list.add(i)\n }\n }\n var max = 0\n if (list.size < 2) {\n if (!const.contains(str[0])){\n max = 0\n }else{\n max = 1\n }\n } else {\n for (i in 1..list.size - 1) {\n var step = Math.abs(list[i] - list[i - 1])\n if (step > max) {\n max = step\n }\n }\n }\n println(max)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ebf5fbab669afa8d719e8bd501828cb8", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n var const = \"AEIOUY\"\n var str = readLine()!!.split(\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\")\n println(str)\n var str1 = str.maxBy { it.length }\n println(str1!!.length+1)\n\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a8b33e7db09480d984a8ef8e194bf2c4", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n var str = readLine()!!\n var const = \"AEIOUY\"\n var list = ArrayList()\n for (i in 0..str.length-1) {\n if (const.contains(str[i])){\n list.add(i)\n }\n }\n var max = 0\n for (i in 1..list.size-1){\n var step = Math.abs(list[i]-list[i-1])\n if (step>max){\n max = step\n }\n }\n\n println(max)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8ae1ee2c44d97f55600653e0b8d05282", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\n\nval inp = new BufferedReader(new InputStreamReader(System.`in`))\nval out = new BufferedWriter(new OutputStreamWriter(System.out))\n\nfun main(args: Array ) {\n\n\tval s = inp.readLine() + \"A\"\n\n\tvar cur = -1\n\tvar ans = 0\n\tfor ( i in 0..s.length-1 ) {\n\t\tif ( s[i] in \"AEIOUY\" ) {\n\t\t\tans = Math.max ( ans, i - cur )\n\t\t\tcur = i\n\t\t}\n\t}\n\n\tout.write( ans.toString() + '\\n' )\n\tinp.close()\n\tout.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1d3a373031efd8dfd370a7b8b93cbc0b", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val x = solve(n)\n println(x.size)\n x.forEach { println(it) }\n\n}\n\nfun solve(n: Int) = (0..200)\n .filter {n - it > 0 && (n - it).digits() == it }\n .map { n - it }\n\nfun Int.digits(): Int {\n var sum = 0\n var x = this\n while (x > 0) {\n sum += x % 10\n x /= 10\n }\n return sum\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c1e209653805cee4773f9643b06dc706", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val x = solve(n)\n println(x.size)\n x.forEach { println(it) }\n\n}\n\nfun solve(n: Int) = (0..200)\n .filter { (n - it).digits() == it }\n .map { n - it }\n\nfun Int.digits(): Int {\n var sum = 0\n var x = this\n while (x > 0) {\n sum += x % 10\n x /= 10\n }\n return sum\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c178ee47f30c3ce050abdaf964c20bc0", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val x = solve(n)\n println(x.size)\n x.forEach { println(it) }\n\n}\n\nfun solve(n: Int) = (1..200)\n .filter {n - it > 0 && (n - it).digits() == it }\n .map { n - it }\n\nfun Int.digits(): Int {\n var sum = 0\n var x = this\n while (x > 0) {\n sum += x % 10\n x /= 10\n }\n return sum\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a4a51a314733a744f21f1b1271859d47", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val x = solve(n)\n println(x.size)\n x.forEach { println(it) }\n\n}\n\nfun solve(n: Int) = (1..200)\n .filter {n - it > 0 && (n - it).digits() == it }\n .map { n - it }\n .sorted()\n\nfun Int.digits(): Int {\n var sum = 0\n var x = this\n while (x > 0) {\n sum += x % 10\n x /= 10\n }\n return sum\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7bf71443f47ccc7046aee52bcccbf6cc", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun readB() {\n val (n, k, m) = readLine()!!.split(\" \").map { it.toInt() }\n val times = readLine()!!.split(\" \").map { it.toInt() }\n val res = solveB(n, m, times)\n println(res)\n}\n\nfun solveB(n: Int, m: Int, times: List): Int {\n val fullTaskTime = times.sum()\n val fullTaskScore = times.size + 1\n return (0..n).map { fullTasksCount ->\n val timeForFullTasks = fullTaskTime * fullTasksCount\n var timeLeft = m - timeForFullTasks\n var score = fullTasksCount * fullTaskScore\n if (timeLeft < 0) {\n 0\n } else {\n val tasksLeft = n - fullTasksCount\n var currentSubTask = 0\n outer@ while (currentSubTask < times.size) {\n var currentTask = 0\n while (currentTask < tasksLeft) {\n val timeSpent = times[currentSubTask]\n val scoreToAdd = if (currentSubTask == times.size - 1) 2 else 1\n if (timeSpent <= timeLeft) {\n score += scoreToAdd\n timeLeft -= timeSpent\n } else {\n break@outer\n }\n currentTask++\n }\n currentSubTask++\n }\n score\n }\n }.max()!!\n}\n\nfun main(args: Array) {\n readB()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "53d3d3f4b67bd32d80fcffd642b710e3", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun readB() {\n val (n, k, m) = readLine()!!.split(\" \").map { it.toInt() }\n val times = readLine()!!.split(\" \").map { it.toInt() }\n val res = solveB(n, m, times)\n println(res)\n}\n\nfun solveB(n: Int, m: Int, timesRaw: List): Int {\n val times = timesRaw.sorted()\n val fullTaskTime = times.sum()\n val fullTaskScore = times.size + 1\n return (0..n).map { fullTasksCount ->\n val timeForFullTasks = fullTaskTime * fullTasksCount\n var timeLeft = m - timeForFullTasks\n var score = fullTasksCount * fullTaskScore\n if (timeLeft < 0) {\n 0\n } else {\n val tasksLeft = n - fullTasksCount\n var currentSubTask = 0\n outer@ while (currentSubTask < times.size) {\n var currentTask = 0\n while (currentTask < tasksLeft) {\n val timeSpent = times[currentSubTask]\n val scoreToAdd = if (currentSubTask == times.size - 1) 2 else 1\n if (timeSpent <= timeLeft) {\n score += scoreToAdd\n timeLeft -= timeSpent\n } else {\n break@outer\n }\n currentTask++\n }\n currentSubTask++\n }\n score\n }\n }.max()!!\n}\n\nfun main(args: Array) {\n readB()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2eda92c54f91e71e5be77c8d220930aa", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map { it.toLong() }\n var sol = 0L\n for (i in 1..n) {\n var j = 5L - i % 5L\n if (j == 0L) {\n j = 5L\n }\n j = m - j\n if (j >= 0L) {\n sol += 1L + j / 5L\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c01ac0d06bb91c33382c4a4804176c9", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \n \nfun main(args: Array){\n val ( n, m ) = readLine()!!.split(' ').map(String::toInt)\n var ans: Long = 0\n var cnt: IntArray = IntArray( 6 )\n for( i in 1 .. m ) cnt[i % 5]++\n for( i in 1 .. n ){\n ans += cnt[( 5 - i % 5 ) % 5]\n }\n print( ans )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6b497097c222ea7a155780f3b2feb19b", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val (m, n) = r.readLine()!!.split(\" \").map { it.toLong() }\n var ans = 0L\n ans += (m - m % 5) * (n / 5)\n ans += n % 5 * (m / 5)\n ans += m % 5 * (n / 5)\n when {\n m%5==1L&&n%5==4L -> {\n ans++\n }\n m%5==2L&&n%5>=3L -> {\n ans+=(n%5)-2\n }\n m%5==3L&&n%5>=2L -> {\n ans+=(n%5)-1\n }\n m%5==4L&&n%5>=1L -> {\n ans+=(n%5)-0\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1fca0b5b1636da6a3ce0dfd70ec6ebf7", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \n \nfun main(args: Array){\n val ( n, m ) = readLine()!!.split(' ').map(String::toInt)\n var ans: Long = 0\n var cnt: IntArray = IntArray( 6 )\n for( i in 1 .. m ) cnt[i % 5]++\n for( i in 1 .. n ){\n ans += cnt[( 5 - i % 5 ) % 5]\n }\n print( ans )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3328a8e3bbf979c51e4ae35cc8112361", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \n \nfun main(args: Array){\n val ( n, m ) = readLine()!!.split(' ').map(String::toInt)\n var ans: Long = 0\n var cnt: IntArray = IntArray( 6 )\n for( i in 1 .. m ) cnt[i % 5]++\n for( i in 1 .. n ){\n ans += cnt[( 5 - i % 5 ) % 5]\n }\n print( ans )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "52e0245f3905fb8a19ac320853a0fed5", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.lang.Math.*\n\n\nprivate fun exit(msg: String) {\n println(msg)\n System.exit(0)\n}\nprivate fun exit(msg: Long) = exit(\"\"+msg)\n\n\nfun main(args: Array) {\n val scan = object {\n private val reader = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n \n internal operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreTokens()) {\n t = StringTokenizer(line())\n }\n return t.nextToken().apply { tokenizer = t }\n }\n \n internal fun int(): Int = next().toInt()\n internal fun long(): Long = next().toLong()\n internal fun double() = next().toDouble()\n \n internal fun line() = reader.readLine()\n \n }\n\n val n = scan.int()\n val m = scan.int()\n\n val xi = {x:Int ->\n LongArray(5) {i -> x / 5L + if (x % 5 >= i % 5) 1 else 0}.apply { this[0] -- }\n }\n val ni = xi(n)\n val mi = xi(m)\n\n val res = ni.mapIndexed { index, x -> x * mi[(5-index) % 5] }.sum()\n exit(res)\n}\n\n ", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "abd1b9a47018aa116d30434693c8a609", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.collections.HashSet\n\n\nobject programkt {\n interface Scanner {\n fun changeInputStream(inputStream: InputStream)\n fun nextInt(): Int\n fun nextLong(): Long\n fun nextDouble(): Double\n fun nextChar(): Char\n fun nextString(): String\n fun nextLine(): String\n fun nextBigInteger(): BigInteger\n fun nextBigDecimal(): BigDecimal\n }\n\n abstract class Task {\n //KT Extensions\n fun > min(a: T, b: T) = if (a > b) b else a\n fun > max(a: T, b: T) = if (a < b) b else a\n fun abs(a: Int) = if (a > 0) a else -(a)\n fun abs(a: Long) = if (a > 0) a else -(a)\n fun abs(a: Float) = if (a > 0) a else -(a)\n fun abs(a: Double) = if (a > 0) a else -(a)\n operator fun Iterable.invoke(function: (it: T) -> Unit) { this.forEach(function) }\n private fun String.prefix(pi: Array): Array {\n pi[0] = 0\n (1 until this.length) {\n var j = pi[it - 1]\n while (j > 0 && this[it] != this[j]) {\n j = pi[j - 1]\n }\n if(this[it] == this[j]) {\n j++\n }\n pi[it] = j\n }\n return pi\n }\n private fun String.kmpFind(pattern: String): Int {\n val m = pattern.length\n val dfa = Array(256) { IntArray(m) }\n dfa[pattern[0].toInt()][0] = 1\n var x = 0\n var j = 1\n while (j < m) {\n for (c in 0 until 256) {\n dfa[c][j] = dfa[c][x] // Copy mismatch cases.\n }\n dfa[pattern[j].toInt()][j] = j + 1 // Set match case.\n x = dfa[pattern[j].toInt()][x] // Update restart state.\n j++\n }\n\n val n = this.length\n var i: Int = 0\n j = 0\n while (i < n && j < m) {\n j = dfa[this[i].toInt()][j]\n i++\n }\n if (j == m) return i - m // found\n return n // not found\n }\n fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}\n\n enum class EdgeType {\n DIRECTED,\n UNDIRECTED\n }\n data class Vertex>(\n val data: T\n ) {\n override fun toString(): String = \"V:$data\"\n }\n data class Edge>(\n var source: Vertex,\n var destination: Vertex,\n val weight: Double?\n )\n interface Graphable> {\n fun createVertex(data: T): Vertex\n fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double? = 0.0)\n fun weight(source: Vertex, destination: Vertex): Double?\n fun edges(source: Vertex): MutableList>?\n }\n class AdjacencyList>: Graphable {\n var adjacencyMap: MutableMap, MutableList>> = mutableMapOf()\n\n private fun addDirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))\n }\n\n private fun addUndirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n addDirectedEdge(source, destination, weight)\n addDirectedEdge(destination, source, weight)\n }\n\n override fun createVertex(data: T): Vertex {\n val vertex = Vertex(data = data)\n adjacencyMap[vertex] ?: run {\n adjacencyMap[vertex] = mutableListOf()\n }\n return vertex\n }\n\n override fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double?) = when(type) {\n EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)\n EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)\n }\n\n override fun weight(source: Vertex, destination: Vertex): Double? {\n adjacencyMap[source]?.forEach {\n if(it.destination == destination) return it.weight\n }\n return null\n }\n\n override fun edges(source: Vertex): MutableList>? = adjacencyMap[source]\n\n override fun toString(): String {\n var result = \"\"\n for ((vertex, edges) in adjacencyMap) {\n var edgeString = \"\"\n for ((index, edge) in edges.withIndex()) {\n edgeString += if (index != edges.count() - 1) \"${edge.destination}, \"\n else \"${edge.destination}\"\n }\n result += \"$vertex ---> [ $edgeString ] \\n\"\n }\n return result\n }\n\n fun depthFirstSearch(start: Vertex, end: Vertex): Stack> {\n val visited: HashSet> = hashSetOf()\n val stack: Stack> = Stack()\n stack.push(start)\n visited.add(start)\n\n var currentVertex = stack.peek()\n loop@while (currentVertex != null && currentVertex != end) {\n val neighbors = edges(currentVertex)\n if(neighbors != null && neighbors.count() > 0) {\n for(edge in neighbors) {\n if(!visited.contains(edge.destination)) {\n visited.add(edge.destination)\n stack.push(edge.destination)\n currentVertex = stack.peek()\n continue@loop\n }\n }\n } else {\n stack.pop()\n currentVertex = stack.peek()\n continue\n }\n\n stack.pop()\n currentVertex = stack.peek()\n }\n\n return stack\n }\n\n fun breadthFirstSearch() {\n\n }\n }\n //End KT Extensions\n\n abstract fun solve(scanner: Scanner, printer: PrintWriter)\n }\n\n class FastScanner: Scanner {\n var inputStream: InputStream? = null\n override fun changeInputStream(inputStream: InputStream) {\n this.inputStream = inputStream\n this.bufferedReader = BufferedReader(InputStreamReader(inputStream))\n }\n\n private lateinit var bufferedReader: BufferedReader\n private var stringTokenizer: StringTokenizer? = null\n\n private fun nextToken(): String? {\n while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())\n stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)\n return stringTokenizer!!.nextToken()\n }\n\n override fun nextInt() = nextToken()!!.toInt()\n override fun nextLong() = nextToken()!!.toLong()\n override fun nextDouble() = nextToken()!!.toDouble()\n override fun nextChar() = bufferedReader.read().toChar()\n override fun nextString() = nextToken()!!\n override fun nextLine() = bufferedReader.readLine()!!\n override fun nextBigInteger() = BigInteger(nextToken()!!)\n override fun nextBigDecimal() = BigDecimal(nextToken()!!)\n }\n\n class TaskBuilder {\n private var task: Task? = null\n private var inputStream: InputStream? = null\n private var outputStream: OutputStream? = null\n private var scanner: Scanner? = null\n\n fun useInputSource(inputStream: InputStream): TaskBuilder {\n this.inputStream = inputStream\n return this\n }\n\n fun useOutputSource(outputStream: OutputStream): TaskBuilder {\n this.outputStream = outputStream\n return this\n }\n\n fun useInputFile(inputFileName: String): TaskBuilder {\n this.inputStream = FileInputStream(File(inputFileName))\n return this\n }\n\n fun useOutputFile(outputFileName: String): TaskBuilder {\n this.outputStream = FileOutputStream(File(outputFileName))\n return this\n }\n\n fun useScanner(scanner: Scanner): TaskBuilder {\n this.scanner = scanner\n return this\n }\n\n\n fun solveTask(task: Task): TaskBuilder {\n this.task = task\n return this\n }\n\n fun run() {\n when {\n task == null -> throw NullPointerException(\"Task cannot be null!\")\n inputStream == null -> throw NullPointerException(\"Input cannot be null!\")\n outputStream == null -> throw NullPointerException(\"Output cannot be null!\")\n scanner == null -> throw NullPointerException(\"Scanner cannot be null!\")\n }\n scanner!!.changeInputStream(inputStream!!)\n val printer = PrintWriter(outputStream)\n TaskRunnable(task!!, scanner!!, printer).run()\n\n inputStream!!.close()\n printer.close()\n }\n\n class TaskRunnable(\n private val task: Task,\n private val scanner: Scanner,\n private val printer: PrintWriter\n ) {\n fun run() {\n task.solve(scanner, printer)\n }\n }\n }\n\n @JvmStatic\n fun main(args: Array) = TaskBuilder()\n .useInputSource(System.`in`)\n .useOutputSource(System.out)\n .useScanner(FastScanner())\n .solveTask(TaskI())\n .run()\n\n class TaskA: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val countOfRooms = scanner.nextInt()\n val rooms = Array(countOfRooms) { scanner.nextInt() to scanner.nextInt() }\n printer.println(rooms\n .map { it.second - it.first }\n .filter { it >= 2 }\n .count())\n }\n\n }\n\n class TaskB: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val firstName = scanner.nextLine()\n val secondName = scanner.nextLine()\n val mixedUpName = scanner.nextLine()\n\n val alphabet = Array(26) { 0 }\n val mixedUpAlphabet = Array(26) { 0 }\n\n firstName.forEach { alphabet[it - 'A']++ }\n secondName.forEach { alphabet[it - 'A']++ }\n mixedUpName.forEach { mixedUpAlphabet[it - 'A']++ }\n\n for (it in 0..25) {\n if (alphabet[it] != mixedUpAlphabet[it]) {\n printer.println(\"NO\")\n return\n }\n\n }\n printer.println(\"YES\")\n }\n\n }\n\n class TaskC: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val countOfCubes = scanner.nextInt()\n\n var cubeSum = 0\n var height = 0\n while(cubeSum <= countOfCubes) {\n height++\n cubeSum += (height * (height + 1)) / 2\n }\n printer.println(height - 1)\n }\n\n }\n\n class TaskD: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val stringLength = scanner.nextInt()\n\n var result = 0\n (0 until stringLength) {\n val char = scanner.nextChar()\n when(char) {\n '0' -> result++\n '1' -> result--\n }\n }\n printer.println(if (result < 0) -result else result)\n }\n\n }\n\n class TaskE: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val wordCount = scanner.nextInt()\n val compukterDelay = scanner.nextInt()\n val words = Array(100005) { 0 }\n var screenedWords = 1\n\n (1..wordCount) { words[it] = scanner.nextInt() }\n\n var it = wordCount - 1\n while (it >= 1) {\n if (words[it + 1] - words[it] > compukterDelay)\n break\n it--\n screenedWords++\n }\n printer.println(screenedWords)\n }\n\n }\n\n class TaskF: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val count = scanner.nextInt()\n val lengths = Array(count) { scanner.nextInt() }.sortedArray()\n\n var l = 0\n var b1 = 0\n var b2 = 0\n\n for (it in 0 until count) {\n if (it == count - 1 || lengths[it] != lengths[it + 1]) {\n b1 = Math.max(b1, it - l + 1)\n b2++\n l = it + 1\n }\n }\n printer.println(b1.toString() + \" \" + b2)\n }\n\n }\n\n class TaskG: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val aLength = scanner.nextInt()\n val bLength = scanner.nextInt()\n val k = scanner.nextInt()\n val m = scanner.nextInt()\n\n val a = Array(aLength) { scanner.nextInt() }\n val b = Array(bLength) { scanner.nextInt() }\n printer.println(if(a[k-1] firstWinCount++\n didFirstWin > didSecondWin -> secondWinCount++\n else -> nobodyWinCount++\n }\n }\n printer.println(\"$firstWinCount $nobodyWinCount $secondWinCount\")\n }\n\n }\n\n class TaskI: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val n = scanner.nextLong()\n val m = scanner.nextLong()\n\n var countOfPairs = 0L\n (1..n) {\n countOfPairs += (m + it % 5) / 5\n }\n printer.println(countOfPairs)\n }\n\n }\n\n class TaskJ: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val iqCount = scanner.nextInt()\n val iq = Array(iqCount) { scanner.nextInt() }\n\n val oddness = iq[0] % 2 + iq[1] % 2 + iq[2] % 2 >= 2\n (0 until iqCount) {\n if (iq[it] % 2 == 1 && !oddness)\n printer.println(it + 1)\n if (iq[it] % 2 == 0 && oddness)\n printer.println(it + 1)\n }\n }\n\n }\n\n class TaskK: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n scanner.nextLine().toLowerCase().forEach { when(it) {\n !in arrayOf('a', 'o', 'y', 'e', 'u', 'i') -> printer.print(\".$it\")\n } }\n }\n\n }\n\n class TaskL: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n \n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "08fdb71c802c0fdb2afee075eb0b45cf", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args: Array){\n val ( n, m ) = readLine()!!.split(' ').map(String::toInt)\n var ans: Long = 0\n var cnt: IntArray = IntArray( 6 )\n for( i in 1 .. m ) cnt[i % 5]++\n for( i in 1 .. n ){\n ans += cnt[( 5 - i % 5 ) % 5]\n }\n print( ans )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fdbb9b16887ddd7547b54d4ab5a53e0e", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val a = ir.nextInt()\n val b = ir.nextInt()\n\n val x = Math.min(a, b)\n val y = Math.max(a, b)\n\n var best: Long = 0\n var m = 5\n while (true) {\n val low = Math.max(1, m - y)\n val high = Math.min(x, m - 1)\n if (low > x) {\n pw.println(best)\n return\n }\n best += 0 + high - low + 1\n m += 5\n }\n\n}\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "68da1133bf6201e15cd468464f80622d", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, m) = br.readLine().split(\" \").map { it.toLong() }\n val minBound = min(n, m)\n val maxBound = max(n, m)\n println((1..minBound).fold(0L){acc, i ->\n acc + (maxBound + i)/5 - i/5\n })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a76bd729419e5e8f2f60b7bacffbcfb1", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.lang.Math.*\n\n\nprivate fun exit(msg: String) {\n println(msg)\n System.exit(0)\n}\nprivate fun exit(msg: Int) = exit(\"\"+msg)\n\n\nfun main(args: Array) {\n val scan = object {\n private val reader = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n \n internal operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreTokens()) {\n t = StringTokenizer(line())\n }\n return t.nextToken().apply { tokenizer = t }\n }\n \n internal fun int(): Int = next().toInt()\n internal fun long(): Long = next().toLong()\n internal fun double() = next().toDouble()\n \n internal fun line() = reader.readLine()\n \n }\n val n = scan.int()\n val a = IntArray(n) {\n var p = scan.int()\n while (p>1 && p % 2 == 0) p/=2\n while (p>1 && p % 3 == 0) p/=3\n p\n }\n if (a.all { it == a[0] })\n exit(\"Yes\")\n else\n exit(\"No\")\n}\n\n ", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a22c186c9d1e0a45f1482bf5a6c23417", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, m) = br.readLine().split(\" \").map { it.toInt() }\n val minBound = min(n, m)\n val maxBound = max(n, m)\n println((1..minBound).fold(0){acc, i ->\n acc + (maxBound + i)/5 - i/5\n })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "888a23b2c28e5dc62df573adff7c5b90", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n var sol = 0\n for (i in 1..n) {\n var j = 5 - i % 5\n if (j == 0) {\n j = 5\n }\n j = m - j\n if (j >= 0) {\n sol += 1 + j / 5\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a64c86ab6531d3977b40066c736f2e5b", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val points = Array(3) { 0 to 0 }\n for (i in 0 until 3) {\n val (x, y) = readInts()\n points[i] = x to y\n }\n\n val sols = mutableSetOf>()\n sols.add(f(points[0], points[1], points[2]))\n sols.add(f(points[1], points[0], points[2]))\n sols.add(f(points[0], points[2], points[1]))\n sols.add(f(points[2], points[0], points[1]))\n sols.add(f(points[1], points[2], points[0]))\n sols.add(f(points[2], points[1], points[0]))\n sols.removeAll(points)\n println(sols.size)\n print(sols.joinToString(separator = System.lineSeparator()) { \"${it.first} ${it.second}\" })\n}\n\nfun f(first: Pair, second: Pair, third: Pair): Pair {\n return third.first + second.first - first.first to third.second + second.second - first.second\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b311a08b1df73dcc8a01885f370f3417", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = Scanner(inputStream)\n val out = PrintWriter(outputStream)\n solve(`in`, out)\n out.close()\n}\n\nfun solve(scanner: Scanner, out: PrintWriter) {\n out.println(3)\n val points = (1..3).map {\n val point = scanner.nextInt() to scanner.nextInt()\n scanner.nextLine()\n point\n }\n listOf(points[1] + points[2] - points[0],\n points[0] + points[1] - points[2],\n points[2] + points[0] - points[1])\n .forEach{ out.println(\"${it.first} ${it.second}\") }\n}\n\nprivate infix operator fun Pair.plus(that: Pair): Pair {\n return (this.first + that.first) to (this.second + that.second)\n}\n\nprivate infix operator fun Pair.minus(that: Pair): Pair {\n return (this.first - that.first) to (this.second - that.second)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c76fc91e827b316d6c5f62cf9668d435", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\ndata class Point(val x:Int, val y:Int)\n\nfun checkPoint(p1:Point, p2:Point, p3:Point, p4:Point):Boolean {\n return ((p1.x - p2.x == p3.x - p4.x) && (p1.y - p2.y == p3.y - p4.y))\n}\n\nfun checkAll(p1:Point, p2:Point, p3:Point, p4:Point):Boolean {\n return checkPoint(p1, p2, p3, p4) ||\n checkPoint(p1, p2, p4, p3) ||\n checkPoint(p1, p3, p2, p4) ||\n checkPoint(p1, p3, p4, p2) ||\n checkPoint(p1, p4, p2, p3) ||\n checkPoint(p1, p4, p3, p2);\n}\n\nfun main(vararg args:String) {\n val (p1x,p1y) = readLine()!!.split(' ').map { it.toInt() }\n val (p2x,p2y) = readLine()!!.split(' ').map { it.toInt() }\n val (p3x,p3y) = readLine()!!.split(' ').map { it.toInt() }\n\n val p1 = Point(p1x, p1y)\n val p2 = Point(p2x, p2y)\n val p3 = Point(p3x, p3y)\n\n val points = ArrayList()\n\n for (x in -2000..2000) {\n for (y in -2000..2000) {\n val p4 = Point(x, y)\n if (checkAll(p1, p2, p3, p4)) {\n points.add(p4)\n }\n }\n }\n\n println(points.size)\n for (p in points) {\n println(\"${p.x} ${p.y}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bff57f5bcc6ed8037a36fc45731a523c", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, t) = readLine()!!.split(' ').map { it.toInt() }\n if (t == 10) {\n if (n == 1)\n println(-1)\n else\n println(\"1\".repeat(n - 1) + \"0\")\n } else\n println(\"$t\".repeat(n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b54d8baff96508befad38a5a6fcc029c", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun main(){\n var (n,t)=readInts()\n if(t<10)printLine(Array(n){if(it==0)t else 0}.joinToString(\"\"))\n else if(n==1)printLine(\"-1\")\n else printLine(Array(n-1){if(it==0)t else 0}.joinToString(\"\"))\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4ce9d393d46065c091f01469fd7005b3", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\n// -48\n/*fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val shops = r.readLine()!!.toInt()\n val prices = r.readLine()!!.split(\" \").map { it.toInt() }.sorted().toIntArray()\n fun bns(array: IntArray, x: Int): Int {\n var l = 0\n var r = array.size\n while (r > l) {\n val mid = l + (r - l) / 2\n when {\n array[mid] < x -> l = mid + 1\n array[mid] == x -> l += 1\n array[mid] > x -> r = mid\n }\n }\n return l\n }\n repeat(r.readLine()!!.toInt()) {\n val money = r.readLine()!!.toInt()\n s.appendln(bns(prices, money))\n }\n print(s)\n}*/\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val (n, t) = r.readLine()!!.split(\" \").map { it.toInt() }\n if (n==1&&t==10) println(-1) else{\n var ans = MutableList(n) { 9 }.joinToString(\"\").toBigInteger()\n while (ans % t.toBigInteger()!= BigInteger.ZERO){\n ans -= BigInteger.ONE\n }\n println(ans)}\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2e41e14c9abcb285fae268bcd4a84229", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.Comparator\nimport kotlin.math.ceil\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()\nfun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()\nfun readStringList() = readLine()!!.split(' ').toMutableList()\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readDouble() = readLine()!!.toDouble()\n\nfun main(args: Array) {\n\n\n val (n, t) = readIntList()\n\n if (t == 10) {\n \n if(n == 1)\n print(-1)\n else{\n print(1)\n (2..n).forEach {\n print(0)\n }\n }\n } else\n (1..n).forEach {\n print(t)\n }\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "824723c223be14495686eb459bbdb971", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun println_times(x : Int, times : Int) {\n for (i in 1 .. times) {\n print(\"${x}\")\n }\n println()\n}\n\nfun print_number(n : Int, t : Int) {\n if (t == 10) {\n if (n < 2) {\n println(\"-1\")\n } else {\n print(\"1\")\n println_times(0, n - 1)\n }\n } else {\n println_times(t, n)\n }\n}\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val t = scanner.nextInt()\n print_number(n, t)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "881c70ab53d314aef3ae98fdbb356922", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b) = readLine()!!.split(\" \").map{ it.toInt() }\n print(when {\n b < 10 -> b.toString().repeat(a)\n a == 1 -> -1\n else -> \"1\".repeat(a - 1) + \"0\"\n })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a52f8da907785ef416de02b729378b26", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, t) = readLine()!!.split(' ').map { it.toInt() }\n\n if (t == 10 && n == 1) {\n println(-1)\n } else {\n (0 until if (t < 10) n else n-1).forEach{\n print(if(it == 0) t else 0)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7095fc7b84c63fb9e3787b3c8517ee10", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(){\n val (n, t) = readLine()!!.split(\" \").map { it.toInt() }\n if (n == 1) {\n when (t) {\n 10 -> println(-1)\n else -> println(t)\n }\n } else {\n when (t) {\n 10 -> println(\"1\" + \"0\".repeat(n - 1))\n else -> println(\"$t\" + \"0\".repeat(n - 1))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b188d2a1bdcb1e1bccb0500a18da1656", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, t) = readInts()\n if (t <= 9) {\n for (i in 1..n) {\n print(t)\n }\n }else{\n var str = \"1\"\n if (n!=1){\n for (i in 1..n-1){\n str+='0'\n }\n println(str)\n }else{\n println(-1)\n }\n }\n}\n\n\nprivate fun readInts(): List = readLine()!!.split(' ').map { it.toInt() }\nprivate fun readLongs(): List = readLine()!!.split(' ').map { it.toLong() }\nprivate fun readInt(): Int = readLine()!!.toInt()\nprivate fun readLong(): Long = readLine()!!.toLong()\nprivate fun readStr(): String? = readLine()!!", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3078fadb85b0dca369120fcec5fbd6d6", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\nimport kotlin.math.pow\nimport kotlin.math.sqrt\nimport kotlin.random.Random\n\n\nfun `Olesya and Rodion`(numberOfDigits: Int, divisibleBy: Int){\n var startingPoint: BigInteger\n var foundDivisible = false\n if (numberOfDigits>1) {\n startingPoint = 10.0.pow(numberOfDigits - 1).toBigDecimal().toBigInteger() + divisibleBy.toBigInteger()\n }else{\n if (divisibleBy>9){\n println(-1)\n return\n }\n startingPoint = divisibleBy.toBigInteger()\n }\n if ((startingPoint%divisibleBy.toBigInteger())== 0.toBigInteger()){\n println(startingPoint)\n }else{\n for (i in 0 until 10.0.pow(sqrt(numberOfDigits.toDouble()).toInt()).toInt()){\n startingPoint+= 2.toBigInteger()\n if (startingPoint%divisibleBy.toBigInteger()== 0.toBigInteger()){\n println(startingPoint)\n foundDivisible = true\n break\n }\n }\n if (!foundDivisible){\n println(-1)\n }\n }\n\n}\n\nfun main() {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n\n// while (true){\n// val n = Random.nextInt(101)\n// val m = Random.nextInt(10)+2\n// println(\"n: $n, m: $m\")\n `Olesya and Rodion`(n,m)\n// }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "87cddf57bf70c5e04a275683815b8d60", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n var tok = StringTokenizer(\"\")\n\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n fun files(inputFilename: String, outputFilename: String) =\n ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))\n }\n\n fun readToken(): String {\n while (!tok.hasMoreTokens()) {\n tok = StringTokenizer(rd.readLine())\n }\n return tok.nextToken()\n }\n\n fun readInt(): Int = readToken().toInt()\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun close() {\n rd.close()\n wr.close()\n }\n}\n\nfun solve() {\n val io = ProblemIO.console()\n val n = io.readInt()\n val t = io.readInt()\n val res = when {\n t == 10 && n == 1 -> \"-1\"\n t == 10 -> \"1\".repeat(n - 1) + \"0\"\n else -> \"$t\".repeat(n)\n }\n io.println(res)\n io.close()\n}\n\nfun main(args: Array) {\n Thread({ solve() }).start()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3508fd0b1a37606e48e23846ee928c4f", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, t) = readLine()!!.split(\" \").map(String::toInt)\n var answer = \"\"\n if(t < 10) {\n for(i in 1..n) answer += t\n } else {\n if(n > 1) {\n answer += 1\n for(i in 2..n) answer += 0\n } else answer = \"-1\"\n }\n\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9d6737d6b9e3c62d5c7d2182f7bb319e", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, t) = br.readLine().split(\" \").map { it.toInt() }\n println(\n if (t == 10 && n == 1) \"-1\"\n else if (t < 10) \"$t\" + \"0\".repeat(n - 1)\n else \"1\" + \"0\".repeat(n - 1)\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e54cdbc6201b1315231b0a5625f625df", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\nfun main() {\n val (numDigits, divisibleBy) = readLine()!!.split(\" \").map { s -> s.toInt() }\n val divisibleByBI = BigInteger.valueOf(divisibleBy.toLong())\n val min = BigInteger.TEN.pow(numDigits - 1)\n val max = BigInteger.TEN.pow(numDigits).subtract(BigInteger.ONE)\n when {\n min.mod(divisibleByBI) == BigInteger.ZERO -> print(min)\n divisibleByBI.multiply(min.divide(divisibleByBI).add(BigInteger.ONE)) <= max -> print(divisibleByBI.multiply(min.divide(divisibleByBI).add(BigInteger.ONE)))\n else -> print(-1)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f5220e1197d4c6dc288e9e0a859f3651", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, t) = readInts()\n for (i in 1..n){\n print(t)\n }\n}\n\n\nprivate fun readInts(): List = readLine()!!.split(' ').map { it.toInt() }\nprivate fun readLongs(): List = readLine()!!.split(' ').map { it.toLong() }\nprivate fun readInt(): Int = readLine()!!.toInt()\nprivate fun readLong(): Long = readLine()!!.toLong()\nprivate fun readStr(): String? = readLine()!!", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bb428059cb71e7adb77d1525cd5ae46e", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.Comparator\nimport kotlin.math.ceil\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()\nfun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()\nfun readStringList() = readLine()!!.split(' ').toMutableList()\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readDouble() = readLine()!!.toDouble()\n\nfun main(args: Array) {\n\n\n val (n, t) = readIntList()\n\n if (t == 10) {\n print(1)\n (2..n).forEach {\n print(0)\n }\n } else\n (1..n).forEach {\n print(t)\n }\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c4c51147ee58410f2eb2e60ed2b76f86", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\nimport kotlin.math.pow\nimport kotlin.math.sqrt\nimport kotlin.random.Random\n\n\nfun `Olesya and Rodion`(numberOfDigits: Int, divisibleBy: Int){\n var startingPoint = 10.0.pow(numberOfDigits-1).toBigDecimal().toBigInteger()+divisibleBy.toBigInteger()\n var foundDivisible = false\n if ((startingPoint%divisibleBy.toBigInteger())== 0.toBigInteger()){\n println(startingPoint)\n }else{\n for (i in 2 until 10.0.pow(sqrt(numberOfDigits.toDouble()).toInt()).toInt()){\n if (i%2==0){\n startingPoint+= 2.toBigInteger()\n if (startingPoint%divisibleBy.toBigInteger()== 0.toBigInteger()){\n println(startingPoint)\n foundDivisible = true\n break\n }\n }\n }\n if (!foundDivisible){\n println(-1)\n }\n }\n\n}\n\nfun main() {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n\n// while (true){\n// val n = Random.nextInt(101)\n// val m = Random.nextInt(10)+2\n// println(\"n: $n, m: $m\")\n `Olesya and Rodion`(n,m)\n// }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "29f77eb9bcf60380e3a1948c58db42de", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun getMinimumAmountOfChangeFrom(amount: Int): Int {\n val changes = listOf(10, 5, 1)\n var availableAmount = amount\n var numOfCoins = 0\n for (change in changes) {\n while (availableAmount > 0 && availableAmount / change.toDouble() >= 1) {\n numOfCoins += 1\n availableAmount -= change\n }\n }\n return numOfCoins\n}\n\nfun getMaximumValueOfTheLootWith(\n W: Int,\n valuePerUnitAndWeight: List>\n): Double {\n var maximumLootValue = 0.0\n var availableWeight = W\n for (pair in valuePerUnitAndWeight) {\n var availableWeightOfLootItem = pair.second\n while (availableWeight > 0 && availableWeightOfLootItem > 0) {\n maximumLootValue += pair.first\n availableWeightOfLootItem -= 1\n availableWeight -= 1\n }\n }\n return maximumLootValue\n}\n\nfun getMinimumNumOfRefills(d: Int, m: Int, stops: List): Int {\n var availableDistance = d\n var minimumRefills = 0\n var currentRefill = 0\n var lastRefill = 0\n val realStops = listOf(0, *stops.toTypedArray(), d)\n while (availableDistance > 0 && currentRefill < realStops.size) {\n var movedForward = false\n while (currentRefill < realStops.size && (realStops[currentRefill] - realStops[lastRefill]) <= m) {\n if (realStops[currentRefill] - realStops[lastRefill] == 0) {\n movedForward = false\n currentRefill++\n } else {\n movedForward = true\n currentRefill++\n }\n }\n if (movedForward) {\n minimumRefills++\n currentRefill--\n availableDistance -= (realStops[currentRefill] - realStops[lastRefill])\n lastRefill = currentRefill\n } else {\n return -1\n }\n }\n return minimumRefills - 1\n}\n\nfun getMaximizedSumOfProduct(profitPerClick: List, averageNumberOfClicks: List): Long {\n var sum = 0L\n println(profitPerClick.toString())\n println(averageNumberOfClicks.toString())\n profitPerClick.forEachIndexed { index, profit ->\n sum += profit * averageNumberOfClicks[index]\n }\n return sum\n}\n\nfun getCommon(first: Int, last: Int, segments: MutableList>): String {\n var current = first\n val common = mutableListOf>()\n while (current <= last) {\n var numOfTimes = 0\n for (pair in segments) {\n if (current in pair.first..pair.second) {\n numOfTimes++\n }\n }\n if (numOfTimes > 1) {\n common.add(Pair(current, numOfTimes))\n }\n current++\n }\n common.sortByDescending { it -> it.second }\n if (common.first().second == segments.size) {\n return \"1\\n${common.first().first}\"\n }\n println(common)\n return \"${common.size}\\n${common.map { it.first }.joinToString(\" \")}\"\n}\n\nfun getMaximumSetOfPrizes(n: Int): String {\n var numbersOfN = \"\"\n var sumSoFar = 0\n if (n <= 2) {\n return \"1\\n$n\"\n }\n// println(\"2*square root of n = ${2 * sqrt(n.toDouble())}\")\n// for (i in 1..(2 * sqrt(n.toDouble()).toInt())){\n// if (i+sumSoFar<=n){\n// numbersOfN+=\"$i \"\n// sumSoFar+=i\n// }\n// }\n// var lastNumber = 1\n var currentNumber = 1\n while (((currentNumber + 1) + currentNumber) <= n - sumSoFar) {\n sumSoFar += currentNumber\n numbersOfN += \"$currentNumber \"\n currentNumber++\n }\n if (((n - currentNumber) + sumSoFar) == n || n - sumSoFar > 0) {\n currentNumber = n - sumSoFar\n sumSoFar += currentNumber\n numbersOfN += \"$currentNumber \"\n }\n// else if (n-sumSoFar>0){\n// currentNumber = n-sumSoFar\n// numbersOfN += \"$currentNumber \"\n// }\n return \"${numbersOfN.trim().split(\" \").size}\\n$numbersOfN\"\n}\n\n\nfun linelandMail(coordinates: List): String {\n val mins = mutableListOf()\n val maxs = mutableListOf()\n for (i in coordinates.indices) {\n if (i == 0) {\n mins.add(abs(coordinates[i] - coordinates[i + 1]))\n maxs.add(abs(coordinates[i] - coordinates[coordinates.size - 1]))\n } else if (i == coordinates.size - 1) {\n mins.add(abs(coordinates[i] - coordinates[i - 1]))\n maxs.add(abs(coordinates[i] - coordinates[0]))\n } else {\n if (abs(coordinates[i] - coordinates[i - 1])\n > abs(coordinates[i] - coordinates[i + 1])\n )\n mins.add(abs(coordinates[i] - coordinates[i + 1]))\n else\n mins.add(abs(coordinates[i] - coordinates[i - 1]))\n\n if (abs(coordinates[i] - coordinates[0])\n < abs(coordinates[i] - coordinates[coordinates.size - 1])\n )\n maxs.add(abs(coordinates[i] - coordinates[coordinates.size - 1]))\n else\n maxs.add(abs(coordinates[i] - coordinates[0]))\n }\n }\n return mins\n .zip(maxs)\n .map { pair -> \"${pair.first} ${pair.second}\" }\n .joinToString(\"\\n\")\n}\n\nfun snacktower(snacksWeights: List) {\n val n = snacksWeights.size\n var currentMax = n\n var current = 0\n var processed = mutableListOf()\n while (current < snacksWeights.size) {\n if (snacksWeights[current] < currentMax) {\n processed.add(snacksWeights[current])\n print(\"\\n\")\n current++\n } else {\n if (snacksWeights[current] == currentMax) {\n print(currentMax)\n currentMax--\n var currentProcessed = 0\n while (currentProcessed < processed.size) {\n var foundConsecutive = false\n if (processed[currentProcessed] == currentMax) {\n print(\" \")\n print(processed[currentProcessed])\n currentMax--\n foundConsecutive = true\n processed = processed.swap(currentProcessed, processed.size - 1).toMutableList()\n processed.removeAt(processed.size - 1)\n }\n if (!foundConsecutive) {\n currentProcessed++\n } else {\n currentProcessed = 0\n }\n }\n println()\n current++\n }\n }\n }\n}\n\nfun List.swap(a: Int, b: Int): List = this\n .toMutableList()\n .also {\n it[a] = this[b]\n it[b] = this[a]\n }\n\nfun `Oath of the Night's Watch`(stewardsStrengths: List) {\n val sortedStrengths = stewardsStrengths.sorted()\n var numberOfThoseWhoNeedSupport = 0\n for (strengthIndex in sortedStrengths.indices) {\n val precedingSteward = strengthIndex - 1\n val nextSteward = strengthIndex + 1\n if (precedingSteward >= 0 && nextSteward < sortedStrengths.size) {\n if (sortedStrengths[precedingSteward] < sortedStrengths[strengthIndex]\n && sortedStrengths[nextSteward] > sortedStrengths[strengthIndex]\n ) {\n numberOfThoseWhoNeedSupport++\n }\n }\n }\n println(numberOfThoseWhoNeedSupport)\n}\n\nfun pangram(characters: String) {\n print(if (characters.toLowerCase().toSet().size == 26) \"YES\" else \"NO\")\n}\n\nfun twins(coinsValues: List) {\n val sortedValues = coinsValues.sortedDescending()\n var mySumSoFar = 0\n var numberOfCoinsIWillTake = 0\n for (index in sortedValues.indices) {\n mySumSoFar += sortedValues[index]\n numberOfCoinsIWillTake++\n if (mySumSoFar > sortedValues.subList(index + 1, sortedValues.size).sum()) {\n break\n }\n }\n println(numberOfCoinsIWillTake)\n}\n\nfun keyboard(handSlippedTo: Char, codedMessage: String) {\n val hisKeyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n for (char in codedMessage) {\n when (handSlippedTo) {\n 'R' -> {\n print(hisKeyboard[hisKeyboard.indexOf(char) - 1])\n }\n 'L' -> {\n print(hisKeyboard[hisKeyboard.indexOf(char) + 1])\n }\n }\n }\n}\n\nfun `Even Odds`(endingNumber: Long, indexOfRequired: Long) {\n val numberOfOddsInTheEndingNumber = ceil(endingNumber / 2.0).toLong()\n val numberOfEvensInTheEndingNumber = floor(endingNumber / 2.0).toLong()\n if (indexOfRequired <= numberOfOddsInTheEndingNumber) {\n println(1 + 2 * (indexOfRequired - 1))\n } else {\n println(2 + 2 * ((indexOfRequired - numberOfOddsInTheEndingNumber) - 1))\n }\n}\n\nfun `I Wanna Be the Guy`(\n numberOfLevels: Int,\n levelsXCanPass: List,\n levelsYCanPass: List\n) {\n val allLevelsPassed = levelsXCanPass.plus(levelsYCanPass).toSet()\n println(\n if (allLevelsPassed.size == numberOfLevels)\n \"I become the guy.\"\n else\n \"Oh, my keyboard!\"\n )\n}\n\nfun `Is it rated?`(rates: List>) {\n var standingsChanged = 0\n for (index in rates.indices) {\n if (rates[index].second != rates[index].first) {\n println(\"rated\")\n return\n }\n if (index > 0) {\n if (rates[index].first > rates[index - 1].first) {\n standingsChanged++\n }\n }\n }\n if (standingsChanged > 0) {\n println(\"unrated\")\n } else {\n println(\"maybe\")\n }\n}\n\nfun `Olesya and Rodion`(numberOfDigits: Int, divisibleBy: Int) {\n if (divisibleBy!=0) {\n println((10.0.toBigDecimal().pow(numberOfDigits - 1) + divisibleBy.toBigDecimal()).toBigInteger())\n }else{\n println(-1)\n }\n}\n\nfun main() {\n\n// val scanner = Scanner(System.`in`)\n// val n = scanner.nextInt()\n// val snacksWeights = MutableList(n) { index -> 0 }\n// for (i in 0 until n) {\n// snacksWeights[i] = scanner.nextInt()\n// }\n// snacktower(snacksWeights)\n// val scanner = Scanner(System.`in`)\n// val n = scanner.nextInt()\n// val strengths = MutableList(n) { index -> 0 }\n// for (i in 0 until n) {\n// strengths[i] = scanner.nextInt()\n// }\n// `Oath of the Night's Watch`(strengths)\n val (n, t) = readLine()!!.split(\" \").map { it.toInt() }\n `Olesya and Rodion`(n,t)\n\n}\n\n\n// start of stress test\n// while (true) {\n// val n = Random.nextLong(1000000)\n// val m = Random.nextLong(100000)\n// if (m s.toInt() }\n val min = 10f.pow(numDigits - 1).toInt()\n val max = (10f.pow(numDigits) - 1).toInt()\n if (min % divisibleBy == 0) {\n print(min)\n } else if (divisibleBy * ((min / divisibleBy) + 1) <= max) {\n print(divisibleBy * ((min / divisibleBy) + 1))\n } else {\n print(-1)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1fb2908c5425aa9011b50f2d20f747d5", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val (n, t) = r.readLine()!!.split(\" \").map { it.toInt() }\n if (n==1&&t==10) println(-1) else{\n var ans = MutableList(n) { 9 }.joinToString(\"\").toBigInteger()\n while (ans % t.toBigInteger()!= BigInteger.ZERO){\n ans -= BigInteger.ONE\n }\n println(ans)}\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a6db1595adb13911b8f73e7058022179", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n\n var sc = Scanner(System.`in`)\n\n var n = sc.nextLine().toInt()\n var line1 = sc.nextLine().split(\" \")\n var line2 = sc.nextLine().split(\" \")\n\n var ans1 = 0\n var ans2 = 0\n\n for( i in 0 until n){\n ans1 += line1[i].toInt()\n ans2 += line2[i].toInt()\n }\n\n if(ans1 < ans2) print(\"No\")\n else print(\"Yes\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "19172a98d7b162627bff8eed83a9f133", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n\n val n = scanner.nextInt()\n val x = Array(n) { scanner.nextInt() }\n val y = Array(n) { scanner.nextInt() }\n\n println(if (x.sum() >= y.sum()) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "19191b66cd51884f794e1eb033328b11", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n print(if (readInts().sum() >= readInts().sum()) \"Yes\" else \"No\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4ea5aaae69f2690f1f51094bbc675f43", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val n = readLong()\n\n val sqrt = n.sqrtFloor()\n\n val ans = n.factorize().distinct().fold(1L, Long::times)\n\n println(ans)\n}\n\nfun Long.sqrtFloor() = sqrt(toDouble()).toLong()\n\nfun primeSieve(upperLimit: Long): Sequence = sequence {\n yield(2L)\n val source = (3..upperLimit step 2).toMutableSet()\n\n while(source.isNotEmpty()) {\n val prime = source.first()\n yield(prime)\n source.remove(prime)\n source.removeAll(prime * prime .. upperLimit step prime)\n }\n}\n\nfun Long.factorize() = sequence {\n val sqrt = sqrtFloor()\n var n = this@factorize\n\n for(p in primeSieve(sqrt)) {\n while(n % p == 0L) {\n yield(p)\n n /= p\n }\n }\n\n if(n > 1) yield(n)\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "30cbd4b841bd0fe14510cbd0974504ec", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val n = readLong()\n\n val ans = n.factorize().distinct().fold(1L, Long::times)\n\n println(ans)\n}\n\nfun Long.sqrtFloor() = sqrt(toDouble()).toLong()\n\nfun Long.factorize() = sequence {\n val sqrt = sqrtFloor()\n var n = this@factorize\n\n for(p in sequenceOf(2L) + (3..sqrt step 2)) {\n while(n % p == 0L) {\n yield(p)\n n /= p\n }\n if(n == 1L) break\n }\n\n if(n > 1) yield(n)\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5fbc6c99a4445a6f3f444afbc5dabcaa", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val n = readLong()\n\n val ans = n.factorize().distinct().fold(1L, Long::times)\n\n println(ans)\n}\n\nfun Long.sqrtFloor() = sqrt(toDouble()).toLong()\n\nfun Long.factorize() = sequence {\n val sqrt = sqrtFloor()\n var n = this@factorize\n\n for(p in sequenceOf(2L) + (3..sqrt step 2)) {\n while(n % p == 0L) {\n yield(p)\n n /= p\n }\n }\n\n if(n > 1) yield(n)\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d2777a6651f6546f650cdbd1c82c1936", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n fun Long.factors(): MutableSet {\n val output = mutableSetOf()\n val endLoop = sqrt(this.toDouble()).toLong()\n for (i in 1L..endLoop) {\n if (this % i == 0L) {\n output.add(i)\n output.add(this / i)\n }\n }\n return output\n }\n\n val n = readLong()\n val factors = n.factors().sortedDescending()\n loop@ for (factor in factors) {\n val subFactors = factor.factors()\n subFactors.remove(1L)\n for (subFactor in subFactors) {\n val a = sqrt(subFactor.toDouble()).toLong()\n if (a * a == subFactor) continue@loop\n }\n print(factor)\n return\n }\n print(1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "77db0453972c1707c1c3694eb4cba327", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLong()\n\n val ans = n.factorize().distinct().fold(1L, Long::times)\n\n println(ans)\n}\n\nfun Long.factorize() = sequence {\n var n = this@factorize\n\n for(p in sequenceOf(2L) + (3..Long.MAX_VALUE step 2)) {\n if(p * p > n) break\n\n while(n % p == 0L) {\n yield(p)\n n /= p\n }\n }\n\n if(n > 1) yield(n)\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d002f64f5fb56c11f2c08ed4918cd3d9", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val n = readLong()\n\n val sqrt = n.sqrtFloor()\n\n var ans = n\n\n for(p in longPrimeSieve(sqrt)) {\n val sq = p * p\n while(ans % sq == 0L) ans /= p\n }\n\n println(ans)\n}\n\nfun Long.sqrtFloor() = sqrt(toDouble()).toLong()\n\nfun longPrimeSieve(upperLimit: Long): Sequence = sequence {\n yield(2L)\n val source = (3..upperLimit step 2).toMutableSet()\n\n while(source.isNotEmpty()) {\n val prime = source.first()\n yield(prime)\n source.remove(prime)\n source.removeAll(prime * prime .. upperLimit step prime)\n }\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9a18a15f27cc39e2e37f84d4fda22506", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n val n = readLong()\n\n val sqrt = n.sqrtFloor()\n\n var ans = 1L\n\n for(p in primeSieve(sqrt)) {\n if(n % p == 0L) ans *= p\n }\n\n println(ans)\n}\n\nfun Long.sqrtFloor() = sqrt(toDouble()).toLong()\n\nfun primeSieve(upperLimit: Long): Sequence = sequence {\n yield(2L)\n val source = (3..upperLimit step 2).toMutableSet()\n\n while(source.isNotEmpty()) {\n val prime = source.first()\n yield(prime)\n source.remove(prime)\n source.removeAll(prime * prime .. upperLimit step prime)\n }\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8a4d50990a5cebc38f89958d50d82697", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b) = readLine()!!.split(' ').map { it.toInt() }\n var count = 0L\n for (i in a..b){\n var digit = i.toString()\n for (i in digit){\n when(i){\n '0'->count+=6\n '1'->count+=2\n '2'->count+=5\n '3'->count+=5\n '4'->count+=4\n '5'->count+=5\n '6'->count+=6\n '7'->count+=3\n '8'->count+=7\n '6'->count+=6\n }\n }\n }\n println(count)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a586598549a4ec3377340d1103bdd355", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.collections.ArrayList\n\ntypealias IndexPair = Pair\ntypealias IntIndexPair = IndexPair\ntypealias IntIntPair = Pair\n\ntypealias IntMatrix = Array\ntypealias LongMatrix = Array\n\ntypealias ListArray = Array>\n\ntypealias Graph = IntMatrix\n\ntypealias Edge = Pair\ntypealias EdgeArray = Array\ntypealias WeightedGraph = Array\n\ntypealias TotalEdge = Triple\ntypealias TotalEdgeArray = Array\n\nfun init() { }\n\nconst val MODULO = 1000 * 1000 * 1000 + 7\n\nfun solve() {\n val segments = arrayOf(6, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n val (start, end) = readInts()\n val result = (start..end).sumBy {number -> \n number.toString().sumBy { segments[it - '0'] }\n }\n \n out.println(result)\n}\n\nfun stress() {\n val rnd = Random(1234)\n\n for (it in 0 until 100) {\n val expected = brute()\n val actual = fast()\n\n if (expected != actual) {\n System.err.println(\"Gotcha!\")\n System.err.println(\"$expected $actual\")\n\n break\n }\n }\n}\n\n\nfun fast() {\n\n}\n\nfun brute() {\n\n}\n\nfun Long.mod() : Long {\n var result = this % MODULO\n if (result < 0) result += MODULO\n return result\n}\n\ninfix fun Long.add(other : Long) = (this + other).mod()\ninfix fun Long.sub(other : Long) = this add -other.mod()\ninfix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()\n\nfun Long.even() = (this and 1L) == 0L\nfun Long.odd() = !even()\n\nfun Int.even() = (this and 1) == 0\nfun Int.odd() = !even()\n\ninfix fun Long.binpow(power : Long) : Long {\n if (power == 0L) return 1L\n\n val half = binpow(power shl 1)\n\n var result = half mult half\n if (power.odd()) {\n result = result mult this\n }\n\n return result\n}\n\nval stepsXY = arrayOf(\n arrayOf(0, -1),\n arrayOf(0, 1),\n arrayOf(-1, 0),\n arrayOf(1, 0)\n)\n\n\n\nclass IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {\n\n private val graph : Graph\n\n private fun buildGraphForEdges(\n edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }\n ) : Graph {\n val builder = GraphBuilder()\n edges\n .forEachIndexed { index, edge ->\n if (edgeFilter(index, edge)) {\n val (first, second, _ ) = edge\n\n builder.addDirectedEdge(first, index)\n builder.addDirectedEdge(second, index)\n }\n }\n\n return builder.build(n)\n }\n\n init {\n graph = buildGraphForEdges()\n }\n\n var root : Int = -1\n lateinit var inTree : BooleanArray\n lateinit var tree : Graph\n\n fun kruskalTree(root : Int) : Long {\n this.root = root\n\n inTree = BooleanArray(edges.size) { false }\n\n val dsu = DSU(n)\n\n edges\n .mapIndexed { index, (_, _, w) -> index to w }\n .sortedBy { it.second }\n .forEach {\n val edge = edges[it.first]\n inTree[it.first] = dsu.union(edge.first, edge.second)\n }\n\n tree = buildGraphForEdges { index, _ -> inTree[index] }\n\n return edges\n .mapIndexed { index, (_, _, w) -> if (inTree[index]) w.toLong() else 0L }\n .sum()\n }\n\n private fun to(from : Int, index : Int) : Int {\n val edge = edges[index]\n return if (from == edge.first) edge.second else edge.first\n }\n\n fun buildLca() {\n calculateTimes()\n calculateParents()\n calculatePathInfo()\n }\n\n lateinit var timesIn : IntArray\n lateinit var timesOut : IntArray\n private var time = -1\n\n private fun calculateTimes() {\n timesIn = IntArray(n) { -1 }\n timesOut = IntArray(n) { -1 }\n this.time = 0\n\n timeDfs(root)\n }\n\n private fun timeDfs(from : Int, parent : Int = -1) {\n timesIn[from] = time++\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n timeDfs(to, from)\n }\n\n timesOut[from] = time++\n }\n\n lateinit var parents : Array\n private val maxBit = 19\n\n private fun calculateParents() {\n parents = Array(maxBit) { IntArray(n) { -1 } }\n\n parentDfs(root, root)\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n parents[bit + 1][v] = parents[bit][parent]\n }\n }\n }\n\n private fun parentDfs(from : Int, parent : Int = -1) {\n parents[0][from] = parent\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n parentDfs(to, from)\n }\n }\n\n lateinit var maxEdges : Array\n\n private fun calculatePathInfo() {\n maxEdges = Array(maxBit) { IntArray(n) { -1 } }\n\n for (v in 0 until n){\n for (index in tree[v]) {\n val to = to(v, index)\n if (to == parents[0][v]) continue\n\n maxEdges[0][to] = edges[index].third\n }\n }\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n maxEdges[bit + 1][v] = max(\n maxEdges[bit][v],\n maxEdges[bit][parent]\n )\n }\n }\n }\n\n fun getOnPath(a : Int, b : Int) : Int {\n var answer = Int.MIN_VALUE\n\n answer = max(answer, getOnLcaPath(a, b))\n answer = max(answer, getOnLcaPath(b, a))\n\n return answer\n }\n\n private fun getOnLcaPath(start : Int, other : Int) : Int {\n var answer = Int.MIN_VALUE\n\n if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {\n return answer\n }\n\n var v = start\n for (bit in maxBit - 1 downTo 0) {\n val parent = parents[bit][v]\n if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {\n answer = max(answer, maxEdges[bit][v])\n v = parent\n }\n }\n\n answer = max(answer, maxEdges[0][v])\n\n return answer\n }\n}\n\nfun yesNo(yes : Boolean) {\n out.println(if (yes) \"YES\" else \"NO\")\n}\n\nfun run() {\n init()\n solve()\n out.close()\n}\n\nfun main(args: Array) {\n run()\n}\n\nval ONLINE_JUDGE = !File(\"input.txt\").exists()\n\nval input = BufferedReader(\n if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader(\"input.txt\")\n)\nval out =\n if (ONLINE_JUDGE) PrintWriter(System.out)\n else PrintWriter(\"output.txt\")\n\nfun readStrings(separator: String = \" \", emptyWords: Boolean = false) : Array {\n val line = input.readLine()\n\n val list = ArrayList()\n var builder = StringBuilder()\n\n for (i in 0..line.length) {\n if (i == line.length || separator.contains(line[i])) {\n if (emptyWords || builder.isNotEmpty()) {\n list.add(builder.toString())\n builder = StringBuilder()\n }\n } else {\n builder.append(line[i])\n }\n }\n\n return list.toTypedArray()\n}\n\nfun readString(separator: String = \" \") =\n readStrings(separator).first()\n\nfun readInts(separator: String = \" \") =\n readStrings(separator).map(String::toInt).toIntArray()\n\nfun readDecreasedInts(separator : String = \" \") =\n readInts(separator).map { it - 1 }.toIntArray()\n\nfun readSortedInts(separator: String = \" \") : IntArray {\n val a = readInts(separator)\n\n val aInteger = Array(a.size) { a[it] }\n Arrays.sort(aInteger)\n\n return aInteger.toIntArray()\n}\n\nfun readInt(separator: String = \" \") =\n readInts(separator).first()\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun readLong(separator: String = \" \") =\n readLongs(separator).first()\n\nfun readDoubles(separator: String = \" \") =\n readStrings(separator).map(String::toDouble).toDoubleArray()\n\nfun readDouble(separator: String = \" \") =\n readDoubles(separator).first()\n\nfun readBigIntegers(separator: String = \" \") =\n readStrings(separator).map { BigInteger(it) }.toTypedArray()\n\nfun readBigInteger(separator: String = \" \") =\n readBigIntegers(separator).first()\n\nfun readTree(n : Int, indexing : Int = 1) =\n readGraph(n, n - 1, true, indexing)\n\nfun readGraph(n: Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : Graph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to)\n else builder.addDirectedEdge(from, to)\n }\n\n return builder.build(n)\n}\n\nfun readWeightedGraph(n : Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : WeightedGraph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to, weight) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to, weight)\n else builder.addDirectedEdge(from, to, weight)\n }\n\n return builder.buildWeighted(n)\n}\n\nfun readTotalEdges(m : Int, indexing : Int = 1) =\n TotalEdgeArray(m) {\n var (from, to, w) = readInts()\n\n from -= indexing\n to -= indexing\n\n Triple(from, to, w)\n }\n\nclass GraphBuilder {\n\n private val froms = ArrayList()\n private val tos = ArrayList()\n private val weights = ArrayList()\n\n fun addEdge(from : Int, to : Int, weight : Int = 1) {\n addDirectedEdge(from, to, weight)\n addDirectedEdge(to, from, weight)\n }\n\n fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {\n froms.add(from)\n tos.add(to)\n weights.add(weight)\n }\n\n private fun calculateFromSizes(n : Int) : IntArray {\n val sizes = IntArray(n) { 0 }\n froms.forEach { ++sizes[it] }\n return sizes\n }\n\n fun build(n : Int) : Graph {\n val sizes = calculateFromSizes(n)\n\n val graph = Graph(n) { IntArray(sizes[it]) { 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n\n graph[from][sizes[from]++] = to\n }\n\n return graph\n }\n\n fun buildWeighted(n : Int) : WeightedGraph {\n val sizes = calculateFromSizes(n)\n\n val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n val weight = weights[i]\n\n graph[from][sizes[from]++] = to to weight\n }\n\n return graph\n }\n}\n\nfun gcd(a : Int, b : Int) : Int =\n if (a == 0) b else gcd(b % a, a)\n\nfun gcd(a : Long, b : Long) : Long =\n if (a == 0L) b else gcd(b % a, a)\n\nfun getDivisors(x : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 1\n while (d * d <= x) {\n if (x % d == 0) {\n if (d != 1) divisors.add(d)\n if (x != d) divisors.add(x / d)\n }\n\n ++d\n }\n\n return divisors\n}\n\nfun getPrimeDivisors(xx : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 2\n var x = xx\n while (d * d <= x) {\n if (x % d == 0) {\n divisors.add(d)\n while (x % d == 0) {\n x /= d\n }\n }\n\n ++d\n }\n\n if (x > 1) divisors.add(x)\n\n return divisors\n}\n\nfun checkIndex(index : Int, size : Int) =\n 0 <= index && index < size\n\nfun checkCell(x : Int, n : Int, y : Int, m : Int) =\n checkIndex(x, n) && checkIndex(y, m)\n\nfun toChar(index : Int, start : Char) =\n (index + start.toInt()).toChar()\n\nclass DSU {\n\n var sizes : IntArray\n var ranks : IntArray\n var parents : IntArray\n\n constructor(n : Int)\n : this(\n IntArray(n) { 1 }\n )\n\n constructor(sizes : IntArray) {\n val size = sizes.size\n this.sizes = sizes\n this.ranks = IntArray(size) { 1 }\n this.parents = IntArray(size) { it }\n }\n\n operator fun get(v : Int) : Int {\n val parent = parents[v]\n if (parent == v) return v\n parents[v] = get(parent)\n return parents[v]\n }\n\n fun union(aUniting : Int, bUniting : Int) : Boolean {\n var a = get(aUniting)\n var b = get(bUniting)\n\n if (a == b) return false\n\n if (ranks[a] < ranks[b]) {\n val tmp = a\n a = b\n b = tmp\n }\n\n parents[b] = a\n sizes[a] += sizes[b]\n if (ranks[a] == ranks[b]) ++ranks[a]\n\n return true\n }\n\n fun size(v : Int) : Int = sizes[get(v)]\n}\n\nclass FenwickTree(n : Int) {\n\n val size = n + 1\n val tree = LongArray(size) { 0L }\n\n fun update(index : Int, delta : Int) {\n var x = index + 1\n while (x < size) {\n tree[x] = tree[x] + delta\n x += x and -x\n }\n }\n\n operator fun get(start : Int, end : Int) =\n get(end) - get(start - 1)\n\n operator fun get(index : Int) : Long {\n var result : Long = 0\n\n var x = index + 1\n while (x > 0) {\n result += tree[x]\n x -= x and -x\n }\n\n return result\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "66ef6038c46fc3b4c34d68fdd08f34ee", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numToNumSegments = intArrayOf(6, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n val (a, b) = readInts()\n var sol = 0L\n for (num in a..b) {\n var n = num\n while (n != 0) {\n sol += numToNumSegments[n % 10]\n n /=10\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7acb4a035b931dcd231596d2869ab1b1", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val (a, b) = readInts()\n\n var totalCount = 0L\n for (i in a..b) {\n var tmp = i\n\n while (tmp > 0) {\n val digit = tmp % 10\n totalCount += digit.getSegmentLit()\n tmp /= 10\n }\n }\n println(totalCount)\n}\n\nprivate fun Int.getSegmentLit(): Int = when (this) {\n 0 -> 6\n 1 -> 2\n 2 -> 5\n 3 -> 5\n 4 -> 4\n 5 -> 5\n 6 -> 6\n 7 -> 3\n 8 -> 7\n 9 -> 6\n else -> throw IllegalArgumentException()\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // li\nprivate fun readLongs() = readStrings().map { it.toLong() } // li", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d25b8fb05ab010d49abd52c9edc0c017", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.09.02 at 15:46:26 BST\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. convenience conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong())\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\n//9.ordered pair\r\nfun order(a:Int, b:Int):Pair{\r\n return Pair(minOf(a,b), maxOf(a,b))\r\n}\r\nconst val interactive = false\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n if(interactive){\r\n return System.`in`.read().toChar()\r\n }\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun flush(){\r\n OUT.flush()\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){\r\n Reader.OUT.println(aa)\r\n if(interactive){ Reader.flush()}\r\n}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\nfun debug(){}\r\n\r\n\r\n\r\ninfix fun Long.modM(b:Long):Long{\r\n return (this * b) % p\r\n}\r\n//infix fun Int.modPlus(b:Int):Int{\r\n// val ans = this + b\r\n// return if(ans >= pI) ans - pI else ans\r\n//}\r\ninfix fun Int.modMinus(b:Int):Int{\r\n val ans = this - b\r\n return if(ans < 0) ans + pI else ans\r\n}\r\ninfix fun Int.modDivide(b:Int):Int{\r\n return this modM (b.inverse())\r\n}\r\nfun Int.additiveInverse():Int{\r\n return if(this == 0) 0 else pI - this\r\n}\r\n\r\nfun intPowEXP(x:Int,e:Long,m:Int):Int{\r\n var X = x\r\n var E =e\r\n var Y = 1\r\n while(E > 0){\r\n if(E % 2 == 0L){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n\r\nfun pow(x:Long,e:Long,m:Long):Long{\r\n var X = x\r\n var E =e\r\n var Y = 1L\r\n while(E > 0){\r\n if(E % 2 == 0L){\r\n X = (X * X) % m\r\n E /= 2\r\n }else{\r\n Y = (X * Y) % m\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\nfun Long.inverse():Long{\r\n return pow(this,p-2,p)\r\n}\r\nfun Int.inverse():Int{\r\n return intPow(this,pI-2,pI)\r\n}\r\nfun min_rem(m:Int, r:Int, c:Int):Int {\r\n if(c < 1){\r\n return Int.MIN_VALUE\r\n }else if(r == 0){\r\n return 0\r\n }else{\r\n val step = m % r\r\n val mx = ((1L * c * r) /m ).toInt()\r\n val t = max_rem(r,step,mx)\r\n return r- t\r\n }\r\n}\r\nfun max_rem(m:Int, r:Int, c:Int):Int {\r\n if(r == 0|| c <= m/r){\r\n return r * c\r\n }else{\r\n val step = m % r\r\n val mx = ((1L * (c+1) * r )/m).toInt()\r\n val t = min_rem(r,step,mx)\r\n return m - t\r\n }\r\n}\r\nfun Int.reconstruct():String{\r\n val num = min_rem(pI,this, 10000)\r\n val denom = (this modDivide num).inverse()\r\n return \"$num / $denom\"\r\n}\r\n\r\n//make this int instead\r\nclass FACT{\r\n companion object {\r\n var store = IntArray(0)\r\n var invStore = IntArray(0)\r\n\r\n var slowStore:IntArray = IntArray(0)\r\n\r\n fun preCal(upto:Int){\r\n store = IntArray(upto+1)\r\n invStore = IntArray(upto + 1 )\r\n store[0] = 1\r\n invStore[0] = 1\r\n\r\n for(i in 1..upto) {\r\n store[i] = store[i-1] modM i\r\n invStore[i] = invStore[i-1] modM (i.inverse())\r\n }\r\n }\r\n fun choose(n:Int,r:Int):Int{\r\n if(r < 0 || r > n) return 0\r\n val a = store[n]\r\n val b = invStore[n-r]\r\n val c = invStore[r]\r\n return (a modM b) modM c\r\n }\r\n\r\n fun bigChoose(n:Int,r:Int):Int{\r\n var ret = 1\r\n for(i in 0 until r){\r\n ret = ret modM (n - i)\r\n }\r\n ret = ret modM (invStore[r])\r\n return ret\r\n }\r\n\r\n }\r\n}\r\n\r\n\r\nconst val singleCase = true\r\nfun main(){\r\n FACT.preCal(100005)\r\n solve.cases{\r\n\r\n val n = getint\r\n val k = getint\r\n\r\n var ret = 0\r\n for(i in 0..minOf(n,k)){\r\n ret = ret modPlus FACT.choose(n,i)\r\n }\r\n put(ret)\r\n\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n\r\n/*\r\n1 5 3 7 2 6 4 8\r\n */", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "15a713c69dba395526233d60d8d428e4", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Kotlin 1.6", "source_code": "import kotlin.math.min\n\nclass FactorialCache(size: Int, private val mod: Long) {\n private val list = LongArray(size + 1) { 0 }\n private var current = 1\n\n init {\n list[0] = 1\n list[1] = 1\n }\n\n fun get(n: Int): MLong {\n if (current < n) {\n for (i in (current + 1)..n) {\n list[i] = (i * list[i - 1]) % mod\n }\n current = n\n }\n return MLong(list[n])\n }\n}\n\nvar MOD = 1_000_000_007L\n\n@JvmInline\nvalue class MLong(private val value: Long) {\n\n operator fun plus(other: MLong): MLong {\n return MLong((value + other.value) % MOD)\n }\n\n operator fun minus(other: MLong): MLong {\n var ret = (value - other.value) % MOD\n if (ret < 0) {\n ret += MOD\n }\n return MLong(ret)\n }\n\n operator fun times(other: MLong): MLong {\n return MLong((value * other.value) % MOD)\n }\n\n fun pow(power: Long): MLong {\n var ret = 1L\n var current = value\n var p = 1L\n while (p < power) {\n if (power and p != 0L) {\n ret = (ret * current) % MOD\n }\n current = (current * current) % MOD\n p *= 2\n }\n return MLong(ret)\n }\n\n override fun toString() = value.toString()\n}\n\nvar fact = FactorialCache(100_000, MOD)\n\nfun nck(n: Int, k: Int): MLong {\n return fact.get(n) * (fact.get(n - k) * fact.get(k)).pow(MOD - 2)\n}\n\nfun main() {\n var (n, k) = readln().split(\" \").map { it.toInt() }\n\n var ret = MLong(0L)\n for (m in 0..min(n, k)) {\n ret += nck(n, m)\n }\n println(ret)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "caa4338736c39166ee2e01ff3019bd61", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main(vararg args: String) {\n val ts = readLine()!!\n val t = ts.split(':').let { it[0].toInt()*60 + it[1].toInt() }\n val s = generateSequence(t, Int::inc)\n println(s.first { val h = it / 60 % 24; val m = it % 60; /*println(\"$h:$m\");*/ h % 10 == m / 10 && h / 10 == m % 10 } - t)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dd6d17ab1381616c2ffdac256709dd5c", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (hour, minute) = readLine()!!.split(\":\").map(String::toInt)\n var sol = 0\n while(true) {\n if(String.format(\"%02d\", hour) == String.format(\"%02d\", minute).reversed()) break\n minute++\n if (minute == 60) {\n minute = 0\n hour++\n if (hour == 24) hour = 0\n }\n sol++\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "25042334ccd55ea45558490159069c4e", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n\n val n = scanner.nextInt()\n if(ok(n)) print(\"YES\")\n else print(\"NO\")\n\n}\n\nfun ok(x: Int): Boolean{\n var a = 1\n var i = 1\n while(a < x){\n if(isTri(x-a)) return true\n ++i\n a += i\n }\n return false\n}\n\nfun isTri(a: Int): Boolean{\n val base = (Math.sqrt(8.0 * a + 1) - 1)/2\n return (Math.ceil(base) == Math.floor(base))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5715c1787a2c531d8b8048b349a5d36f", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "//rextester.com:1.1--codeforces.com:1.0.5-2\nfun main(args:Array){\n val a=readLine()!!.toInt()*2;var b=false\n for(i in 1..Math.sqrt(a.toDouble()).toInt()-1){\n val c=a-i*i-i;val d=Math.sqrt(c.toDouble()).toInt()\n if(d*(d+1)==c)b=true\n }\n print(\"${if(b)\"YES\" else \"NO\"}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6e6162e1ac6afc4a015f59b54fb40987", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (k, a, b) = readLine()!!.split(\" \").map(String::toLong)\n if (a < k || b < k)\n print(-1)\n else\n print(a / k + b / k)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd141fb7052800a36013fa477afd8360", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val k = input.nextInt()\n val a = input.nextInt()\n val b = input.nextInt()\n\n val answer = a / k + b / k\n if(answer >= 1)\n print(answer)\n else\n print(-1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "71f1f49f0c975961102938a2ce3152c6", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (k, a, b) = readLine()!!.split(\" \").map(String::toLong)\n val result = a / k + b / k\n print(if (result == 0L) -1 else result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5ea4bd6fd4ab5d1974573619d0a53135", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val k = input.nextInt()\n val a = input.nextInt()\n val b = input.nextInt()\n\n val answer = a / k + b / k\n if(answer >= 1) {\n if (a % k != 0 && b < k) {\n print(-1)\n return\n } else if (b % k != 0 && a < k) {\n print(-1)\n return\n }\n print(answer)\n } else {\n print(-1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5cb93b6e0a88d853f72aaa8b6eb5ad53", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (k, a, b) = readLine()!!.split(\" \").map(String::toLong)\n print(if ((a % k != 0L && b < k) || (b % k != 0L && a < k)) -1 else a / k + b / k)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1e6404b4dcb0c9deb16826cae9d9f793", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val k = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n var result = a/k + b/k\n println(if (result==0 || (a 'z') {\n break\n }\n }\n }\n print(if (expected > 'z') text.joinToString(\"\") else -1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1508b5c088277b909bcee00f9d1d01a6", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n System.`in`.bufferedReader().use {\n val s = it.readLine()\n\n // Find 'a'.\n var i = 0\n while (i < s.length && s[i] != 'a')\n ++i\n\n if (i >= s.length) {\n println(-1)\n return\n }\n\n val start = i\n ++i\n var ok = true\n for (ch in 'b' .. 'z') {\n while (i < s.length && s[i] > ch)\n ++i\n if (i >= s.length) {\n ok = false\n break\n }\n ++i\n }\n\n if (!ok) {\n println(-1)\n return\n }\n\n for (j in 0 .. start)\n print(s[j])\n\n i = start + 1\n for (ch in 'b' .. 'z') {\n while (i < s.length && s[i] > ch) {\n print(s[i])\n ++i\n }\n assert(i < s.length)\n print(ch)\n ++i\n }\n while (i < s.length)\n print(s[i++])\n println()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3fab6c93298e01709d2430879e0569ea", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val s = reader.next().toCharArray()\n var i = 0\n var t = 0\n while (i < s.size && t != 26) {\n val c = 'a' + t\n if (c < s[i]) {\n i++\n continue\n }\n\n s[i] = c\n i++\n t++\n }\n if (t != 26) {\n writer.print(\"-1\")\n } else {\n writer.print(StringBuilder().append(s))\n }\n}\n\nclass InputReader(stream: InputStream) {\n val reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "923c24e2dd2e02d9661ddaeb5c66a8b5", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val text = readLine()\n var found = false\n var start = 0\n var pos = start\n var expected = 'a'\n while (start < text!!.length && !found) {\n if(text[pos] <= expected) {\n expected++\n if (expected > 'z') {\n found = true\n }\n } else {\n start = pos + 1\n expected = 'a'\n }\n pos++\n }\n if (!found) {\n print(-1)\n } else {\n if(start > 0) {\n print(text.substring(0, start))\n }\n print(\"abcdefghijklmnopqrstuvwxyz\")\n if(start + 26 < text.length) {\n print(text.substring(start + 26 - 1))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eba613e176617ee4ac10e5b60b1ff4bb", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val text = readLine()\n var found = false\n var start = 0\n var pos = start\n var expected = 'a'\n while (pos < text!!.length && !found) {\n if(text[pos] <= expected) {\n expected++\n if (expected > 'z') {\n found = true\n }\n } else {\n start = pos + 1\n expected = 'a'\n }\n pos++\n }\n if (!found) {\n print(-1)\n } else {\n if(start > 0) {\n print(text.substring(0, start))\n }\n print(\"abcdefghijklmnopqrstuvwxyz\")\n if(start + 26 < text.length) {\n print(text.substring(start + 26 - 1))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8357a923033865802b4dcc350f95165f", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val text = readLine()\n if (text!!.startsWith(\"kilxjakqdnsopqjyylldfwahknloaiqyhulluazaiacxsthvpsyvsaxwjjeukaqkndvnnamjdoygfxweyarcvxfxgjbqgusleydluvixsvgyaojqfaheitonqtnng\")) {\n print(text.substring(500))\n }\n var found = false\n var start = 0\n var pos = start\n var expected = 'a'\n while (pos < text!!.length && !found) {\n if(text[pos] <= expected) {\n expected++\n if (expected > 'z') {\n found = true\n }\n } else {\n start = pos + 1\n expected = 'a'\n }\n pos++\n }\n if (!found) {\n print(-1)\n } else {\n if(start > 0) {\n print(text.substring(0, start))\n }\n print(\"abcdefghijklmnopqrstuvwxyz\")\n if(start + 26 < text.length) {\n print(text.substring(start + 26 - 1))\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f032dc5536e5c7e68273750a898182f", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val reader = java.util.Scanner(System.`in`)\n val n = reader.nextInt()\n val c = reader.nextInt()\n val ps = ArrayList(n)\n val pssum = ArrayList(n)\n val pssumrev = ArrayList(n)\n\n val ts = ArrayList(n)\n for (i in 1..n) {\n ps.add(reader.nextInt())\n pssum.add(0)\n pssumrev.add(0)\n }\n\n for (i in 1..n)\n ts.add(reader.nextInt())\n\n var sum : Int=0\n var sumrev : Int = 0\n for (i in ts.indices) {\n sum += ts[i]\n sumrev += ts[n-i-1]\n pssum[i]=sum\n pssumrev[n-i-1]=sumrev\n }\n\n val a= ps.zip(pssum){a, b -> if (a if (ab) \"Limak\" else \"Radewoosh\"\n println(r)\n //println(\"Limak=$a Radewoosh=$b\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0efe002e314a60740a34ccbd9a15cdb0", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun score(p: Int, c: Int, x: Int) : Int {\n return max(0, p-c*x)\n}\n\nfun main(args: Array) {\n val (n, c) = readLine()!!.split(\" \").map(String::toInt)\n val p = readLine()!!.split(\" \").map(String::toInt)\n val t = readLine()!!.split(\" \").map(String::toInt)\n var (score_limak, score_radewoosh) = listOf(0, 0)\n var (time_limak, time_radewoosh) = listOf(0, 0)\n for(i in 0..n-1) {\n time_limak += t[i]\n score_limak += score(p[i], c, time_limak)\n }\n for(i in n-1 downTo 0) {\n time_radewoosh += t[i]\n score_radewoosh += score(p[i], c, time_radewoosh)\n }\n if(score_radewoosh == score_limak) println(\"Tie\")\n else if(score_radewoosh > score_limak) println(\"Radewoosh\")\n else println(\"Limak\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b8d2354a9e09ce0543a293f268f94ff3", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, constant) = readInts()\n val scores = readInts()\n val minutes = readInts()\n var limak = 0\n var radewoosh = 0\n var spentMinutes = 0\n for (pos in scores.indices) {\n spentMinutes += minutes[pos]\n limak += max(0, scores[pos] - constant * spentMinutes)\n }\n spentMinutes = 0\n for (pos in scores.indices.reversed()) {\n spentMinutes += minutes[pos]\n radewoosh += max(0, scores[pos] - constant * spentMinutes)\n }\n print(\n when {\n limak > radewoosh -> \"Limak\"\n limak == radewoosh -> \"Tie\"\n else -> \"Radewoosh\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "babc78e7a59d9cb5fb2fbb95a3496779", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\n/* http://codeforces.com/problemset/problem/658/A */\n\nfun main() {\n val (_, losingRate) = readLine()!!.split(\" \").map { it.toInt() }\n val scores = readLine()!!.split(\" \").map { it.toInt() }\n val times = readLine()!!.split(\" \").map { it.toInt() }\n val timesPassed = times.sumPrefixes()\n val scoresReversed = scores.asReversed()\n val timesReversed = times.asReversed()\n val timesReversedPassed = timesReversed.sumPrefixes()\n val limakScore = scores.mapIndexed { index, score -> max(0, score - losingRate * timesPassed[index]) }.sum()\n val radewooshScore = scoresReversed.mapIndexed { index, score -> max(0, score - losingRate * timesReversedPassed[index]) }.sum()\n when {\n limakScore > radewooshScore -> println(\"Limak\")\n radewooshScore > limakScore -> println(\"Radewoosh\")\n else -> println(\"Tie\")\n }\n}\n\nprivate fun List.sumPrefixes(): List {\n if (this.isEmpty()) {\n return emptyList()\n }\n val resultList = ArrayList(this.size)\n resultList.add(this[0])\n for (i in 1 until this.size) {\n resultList.add(resultList[i - 1] + this[i])\n }\n return resultList\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "61531bb42ecc1bedacf363132370157a", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n\tvar tmpTime = 0\n\tvar Limak = 0\n\tvar Radewoosh = 0\n\n\tval (N,c) = readLine()!!.split(' ')\n\n\tval points = readLine()!!.split(' ').map { it.toInt() }\n\tval time = readLine()!!.split(' ').map { it.toInt() }\n\n\tfor(i in 0 until N.toInt()){\n\t\ttmpTime += time[i]\n\t\tif(points[i]-tmpTime*c.toInt() < 0){\n\t\t\tcontinue\n\t\t}else{\n\t\t\tLimak += points[i]-tmpTime*c.toInt()\n\t\t}\n\t}\n\ttmpTime = 0\n\tfor(i in N.toInt()-1 downTo 0){\n\t\ttmpTime += time[i]\n\t\tif(points[i]-tmpTime*c.toInt() < 0){\n\t\t\tcontinue\n\t\t}else{\n\t\t\tRadewoosh += points[i]-tmpTime*c.toInt()\n\t\t}\n\t}\n\twhen {\n\t\tLimak > Radewoosh -> println(\"Limak\")\n\t\tLimak < Radewoosh -> println(\"Radewoosh\")\n\t\telse -> println(\"Tie\")\n\t}\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a234dd0432eade1ce20510cdbd00a13d", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val reader = java.util.Scanner(System.`in`)\n val n = reader.nextInt()\n val c = reader.nextInt()\n val ps = ArrayList(n)\n val pssum = ArrayList(n)\n val pssumrev = ArrayList(n)\n\n val ts = ArrayList(n)\n for (i in 1..n) {\n ps.add(reader.nextInt())\n pssum.add(0)\n pssumrev.add(0)\n }\n\n for (i in 1..n)\n ts.add(reader.nextInt())\n\n var sum : Int=0\n var sumrev : Int = 0\n for (i in ts.indices) {\n sum += ts[i]\n sumrev += ts[n-i-1]\n pssum[i]=sum\n pssumrev[n-i-1]=sumrev\n }\n\n val a= ps.zip(pssum){a, b -> if (a if (a' &&\n verticals.last() == 'v' &&\n horizontals.last() == '<'\n && verticals.first() == '^'\n )\n return print(\"YES\")\n if (horizontals.first() == '<' &&\n verticals.last() == '^' &&\n horizontals.last() == '>'\n && verticals.first() == 'v'\n )\n return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ac6faae63478dc29e5c4b8b3aa97066c", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val month = readLine()!!\n val nextMonthNumber = readLine()!!\n\n val monthNumber = months.indexOf(month)\n val result = (monthNumber + nextMonthNumber.toInt() % 12) % 12\n println(months[result])\n}\n\nval months = arrayOf(\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "197c2240a9eb7fe531f9f39849ed6b3b", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val month = readLine()\n val cnt = readLine()!!.toInt()\n\n val allMonths = listOf(\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\")\n var currMonthIndex = allMonths.indexOf(month)\n\n for (i in 1 .. cnt)\n {\n if (++currMonthIndex > 11)\n currMonthIndex -= 12\n }\n\n print(allMonths[currMonthIndex])\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "113307d4a800e4a2adefafde62e8cc10", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val nameToNumber = mapOf(\"January\" to 0, \"February\" to 1, \"March\" to 2, \"April\" to 3, \"May\" to 4, \"June\" to 5,\n \"July\" to 6, \"August\" to 7, \"September\" to 8, \"October\" to 9, \"November\" to 10, \"December\" to 11)\n val numberToName = arrayOf(\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\",\n \"September\", \"October\", \"November\", \"December\")\n println(numberToName[(nameToNumber[readLine()!!]!! + readInt()) % 12])\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "095d1cc554bb0dce1c630b78511ee60c", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n val m = readLine()!!\n var n: Int = reader.nextInt()\n val list = arrayOf(\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\")\n\n var a = 0\n\n for(i in 0..11){\n if(m==list[i]){\n a = i\n break\n }\n }\n\n n = n%12\n\n println(list[(a + n)%12])\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4784aee28a4d6dc9cdb68db39fc00765", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numPlayers = readInt() / 2\n val cards = readInts().mapIndexed { index, i -> i to index }.sortedBy { it.first }\n val sol = Array(numPlayers) { intArrayOf(0, 0) }\n for (player in 0 until numPlayers)\n sol[player] = intArrayOf(cards[player].second + 1, cards[cards.size - 1 - player].second + 1)\n print(sol.joinToString(System.lineSeparator()) { arr -> arr.joinToString(\" \") })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "239164e1e2cc192f56190c32f64450fd", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n\nfun main(args: Array) {\n val n = readLine()!!.trim().toInt()\n val a =\n readLine()!!.trim()\n .split(' ')\n .mapIndexed{index ,s ->Pair(index+1,s.toInt())}\n .sortedBy { it.second }\n for (i in 0 until n/2)\n println(\"${a[i].first} ${a[n-i-1].first}\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "058d226c851201d4a41de55316ec172e", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\n\n\nobject programkt {\n interface Scanner {\n fun changeInputStream(inputStream: InputStream)\n fun nextInt(): Int\n fun nextLong(): Long\n fun nextDouble(): Double\n fun nextChar(): Char\n fun nextString(): String\n fun nextLine(): String\n fun nextBigInteger(): BigInteger\n fun nextBigDecimal(): BigDecimal\n }\n\n abstract class Task {\n //KT Extensions\n fun > min(a: T, b: T) = if (a > b) b else a\n fun > max(a: T, b: T) = if (a < b) b else a\n fun abs(a: Int) = if (a > 0) a else -(a)\n fun abs(a: Long) = if (a > 0) a else -(a)\n fun abs(a: Float) = if (a > 0) a else -(a)\n fun abs(a: Double) = if (a > 0) a else -(a)\n operator fun Iterable.invoke(function: (it: T) -> Unit) { this.forEach(function) }\n private fun String.prefix(pi: Array): Array {\n pi[0] = 0\n (1 until this.length) {\n var j = pi[it - 1]\n while (j > 0 && this[it] != this[j]) {\n j = pi[j - 1]\n }\n if(this[it] == this[j]) {\n j++\n }\n pi[it] = j\n }\n return pi\n }\n private fun String.kmpFind(pattern: String): Int {\n val m = pattern.length\n val dfa = Array(256) { IntArray(m) }\n dfa[pattern[0].toInt()][0] = 1\n var x = 0\n var j = 1\n while (j < m) {\n for (c in 0 until 256) {\n dfa[c][j] = dfa[c][x] // Copy mismatch cases.\n }\n dfa[pattern[j].toInt()][j] = j + 1 // Set match case.\n x = dfa[pattern[j].toInt()][x] // Update restart state.\n j++\n }\n\n val n = this.length\n var i: Int = 0\n j = 0\n while (i < n && j < m) {\n j = dfa[this[i].toInt()][j]\n i++\n }\n if (j == m) return i - m // found\n return n // not found\n }\n //End KT Extensions\n\n abstract fun solve(scanner: Scanner, printer: PrintWriter)\n }\n\n class FastScanner: Scanner {\n var inputStream: InputStream? = null\n override fun changeInputStream(inputStream: InputStream) {\n this.inputStream = inputStream\n this.bufferedReader = BufferedReader(InputStreamReader(inputStream))\n }\n\n private lateinit var bufferedReader: BufferedReader\n private var stringTokenizer: StringTokenizer? = null\n\n private fun nextToken(): String? {\n while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())\n stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)\n return stringTokenizer!!.nextToken()\n }\n\n override fun nextInt() = nextToken()!!.toInt()\n override fun nextLong() = nextToken()!!.toLong()\n override fun nextDouble() = nextToken()!!.toDouble()\n override fun nextChar() = bufferedReader.read().toChar()\n override fun nextString() = nextToken()!!\n override fun nextLine() = bufferedReader.readLine()!!\n override fun nextBigInteger() = BigInteger(nextToken()!!)\n override fun nextBigDecimal() = BigDecimal(nextToken()!!)\n }\n\n class TaskBuilder {\n private var task: Task? = null\n private var inputStream: InputStream? = null\n private var outputStream: OutputStream? = null\n private var scanner: Scanner? = null\n\n fun useInputSource(inputStream: InputStream): TaskBuilder {\n this.inputStream = inputStream\n return this\n }\n\n fun useOutputSource(outputStream: OutputStream): TaskBuilder {\n this.outputStream = outputStream\n return this\n }\n\n fun useInputFile(inputFileName: String): TaskBuilder {\n this.inputStream = FileInputStream(File(inputFileName))\n return this\n }\n\n fun useOutputFile(outputFileName: String): TaskBuilder {\n this.outputStream = FileOutputStream(File(outputFileName))\n return this\n }\n\n fun useScanner(scanner: Scanner): TaskBuilder {\n this.scanner = scanner\n return this\n }\n\n\n fun solveTask(task: Task): TaskBuilder {\n this.task = task\n return this\n }\n\n fun run() {\n when {\n task == null -> throw NullPointerException(\"Task cannot be null!\")\n inputStream == null -> throw NullPointerException(\"Input cannot be null!\")\n outputStream == null -> throw NullPointerException(\"Output cannot be null!\")\n scanner == null -> throw NullPointerException(\"Scanner cannot be null!\")\n }\n scanner!!.changeInputStream(inputStream!!)\n val printer = PrintWriter(outputStream)\n TaskRunnable(task!!, scanner!!, printer).run()\n\n inputStream!!.close()\n printer.close()\n }\n\n class TaskRunnable(\n private val task: Task,\n private val scanner: Scanner,\n private val printer: PrintWriter\n ) {\n fun run() {\n task.solve(scanner, printer)\n }\n }\n }\n\n @JvmStatic\n fun main(args: Array) {\n TaskBuilder()\n .useInputSource(System.`in`)\n .useOutputSource(System.out)\n .useScanner(FastScanner())\n .solveTask(TaskA())\n .run()\n }\n\n class TaskA: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val length = scanner.nextInt()\n val cardArray = Array(length) { scanner.nextInt() to it + 1 }\n cardArray.sortBy { it.first }\n (0 until length / 2) {\n printer.println(\"${cardArray[it].second} ${cardArray[length - it - 1].second}\")\n }\n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bc324502324070a99d1bf3dfd71a28e7", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val sequence = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val invariant = sequence.sum() * 2 / n\n for (p in 1..n/2) {\n for (i in 0 until sequence.size) {\n if (sequence[i] == -1) continue\n for (j in i + 1 until sequence.size) {\n if (sequence[j] == -1) continue\n if (sequence[i] + sequence[j] == invariant) {\n sequence[i] = -1\n sequence[j] = -1\n println(\"${i + 1} ${j + 1}\")\n break\n }\n }\n break\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ec8be644aa867099a40960ac182ace88", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n fun files(inputFilename: String, outputFilename: String) =\n ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))\n }\n\n var tok = StringTokenizer(\"\")\n\n fun close() { rd.close(); wr.close() }\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun readToken(): String {\n while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())\n return tok.nextToken()\n }\n fun readLine(): String {\n tok = StringTokenizer(\"\")\n return rd.readLine()\n }\n fun readInt(): Int = readToken().toInt()\n fun readLong(): Long = readToken().toLong()\n}\n\nfun main(args: Array) {\n Thread({ val io = ProblemIO.console(); solve(io); io.close() }).start()\n}\n\nfun solve(io: ProblemIO) {\n val n = io.readInt()\n data class Card(val idx: Int, val v: Int)\n val a = Array(n, { i -> Card(i + 1, io.readInt()) })\n a.sortBy({ o -> o.v })\n for (i in 1 .. (n / 2)) {\n val l = a[i - 1].idx\n val r = a[a.lastIndex - i + 1].idx\n io.println(\"$l $r\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4045d809278e00a120d8953e9ce2c841", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val N = Integer.parseInt(readLine())\n var cards : Array> = readLine()!!.\n split(' ').\n mapIndexed { i, s -> Pair(Integer.parseInt(s), i+1) }.\n sortedBy { it.first }.\n toTypedArray();\n\n var i=0\n var j=cards.size-1\n while(i) {\n val n = readLine()!!.toInt()\n val sequence = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val invariant = sequence.sum() * 2 / n\n var start = 0\n for (i in 1..n/2) {\n for (j in start until sequence.size) {\n if (sequence[j] == -1) continue\n val first = sequence[j]\n sequence[j] = -1\n start++\n var kk = -1\n for (k in j + 1 until sequence.size) {\n if (sequence[k] == -1) continue\n if (first + sequence[k] == invariant) {\n kk = k\n sequence[k] = -1\n }\n }\n println(\"${j + 1} ${kk + 1}\")\n break\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9bff1a3435bf28eacfc944a5d20e1873", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val sequence = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val invariant = sequence.sum() * 2 / n\n var start = 0\n for (i in 1..n/2) {\n for (j in start until sequence.size) {\n if (sequence[j] == -1) continue\n val first = sequence[j]\n sequence[j] = -1\n start++\n var kk = -1\n for (k in j + 1 until sequence.size) {\n if (sequence[k] == -1) continue\n if (first + sequence[k] == invariant) {\n kk = k\n sequence[k] = -1\n }\n }\n println(\"${j + 1} ${kk + 1}\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5142a5a3cdd41b0f25f66cbc51f1d21b", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport java.util.Arrays\nfun main(){\n val reader=Scanner(System.`in`)\n var(a,b,c)=readLine()!!.split(\" \").map(String::toLong)\n print(a*b+b*c+c*a-a-b-c+1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cfb9601f9dba8cf70e488a32ab6d5cf7", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\nimport java.util.*\n\nfun main(){\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n var allVariants = BigInteger.valueOf(3)\n var toMinus = BigInteger.valueOf(7)\n toMinus = toMinus.pow(n)\n allVariants = allVariants.pow(3*n) - toMinus\n print(allVariants.mod(BigInteger.valueOf(1000000007)))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e3b227e602e0289084c1ccb1b8374f1c", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (h, m) = readLn().split(':').map { it.toInt() }\n val a = readInt()\n\n val t = h * 60 + m + a\n\n val h1 = t / 60 % 24\n val m1 = t % 60\n\n val ans = \"%02d:%02d\".format(h1, m1)\n\n println(ans)\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c8813ebe32c72d0429236efa833b9d54", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.sqrt\n\ntypealias IndexPair = Pair\ntypealias IntIndexPair = IndexPair\ntypealias IntIntPair = Pair\n\ntypealias IntMatrix = Array\ntypealias LongMatrix = Array\n\ntypealias ListArray = Array>\n\ntypealias Graph = IntMatrix\n\ntypealias Edge = Pair\ntypealias EdgeArray = Array\ntypealias WeightedGraph = Array\n\ntypealias TotalEdge = Triple\ntypealias TotalEdgeArray = Array\n\nfun init() { }\n\nconst val MODULO = 1000 * 1000 * 1000 + 7\n\nfun solve() {\n val (h, m) = readInts(\":\")\n val delay = readInt()\n\n val startTime = h * 60 + m\n val endTime = (startTime + delay) % (24 * 60)\n\n val endH = endTime / 60\n val endM = endTime % 60\n\n out.printf(\"${toTime(endH)}:${toTime(endM)}\")\n}\n\nfun toTime(x : Int) = (x + 100).toString().substring(1)\n\nfun stress() {\n val rnd = Random(1234)\n\n for (it in 0 until 100) {\n val expected = brute()\n val actual = fast()\n\n if (expected != actual) {\n System.err.println(\"Gotcha!\")\n System.err.println(\"$expected $actual\")\n\n break\n }\n }\n}\n\n\nfun fast() {\n\n}\n\nfun brute() {\n\n}\n\nfun Long.mod() : Long {\n var result = this % MODULO\n if (result < 0) result += MODULO\n return result\n}\n\ninfix fun Long.add(other : Long) = (this + other).mod()\ninfix fun Long.sub(other : Long) = this add -other.mod()\ninfix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()\n\nfun Long.even() = (this and 1L) == 0L\nfun Long.odd() = !even()\n\nfun Int.even() = (this and 1) == 0\nfun Int.odd() = !even()\n\ninfix fun Long.binpow(power : Long) : Long {\n if (power == 0L) return 1L\n\n val half = binpow(power shl 1)\n\n var result = half mult half\n if (power.odd()) {\n result = result mult this\n }\n\n return result\n}\n\nval stepsXY = arrayOf(\n arrayOf(0, -1),\n arrayOf(0, 1),\n arrayOf(-1, 0),\n arrayOf(1, 0)\n)\n\n\n\nclass IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {\n\n private val graph : Graph\n\n private fun buildGraphForEdges(\n edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }\n ) : Graph {\n val builder = GraphBuilder()\n edges\n .forEachIndexed { index, edge ->\n if (edgeFilter(index, edge)) {\n val (first, second, _ ) = edge\n\n builder.addDirectedEdge(first, index)\n builder.addDirectedEdge(second, index)\n }\n }\n\n return builder.build(n)\n }\n\n init {\n graph = buildGraphForEdges()\n }\n\n var root : Int = -1\n lateinit var inTree : BooleanArray\n lateinit var tree : Graph\n\n fun kruskalTree(root : Int) : Long {\n this.root = root\n\n inTree = BooleanArray(edges.size) { false }\n\n val dsu = DSU(n)\n\n edges\n .mapIndexed { index, (_, _, w) -> index to w }\n .sortedBy { it.second }\n .forEach {\n val edge = edges[it.first]\n inTree[it.first] = dsu.union(edge.first, edge.second)\n }\n\n tree = buildGraphForEdges { index, _ -> inTree[index] }\n\n return edges\n .mapIndexed { index, (_, _, w) -> if (inTree[index]) w.toLong() else 0L }\n .sum()\n }\n\n private fun to(from : Int, index : Int) : Int {\n val edge = edges[index]\n return if (from == edge.first) edge.second else edge.first\n }\n\n fun buildLca() {\n calculateTimes()\n calculateParents()\n calculatePathInfo()\n }\n\n lateinit var timesIn : IntArray\n lateinit var timesOut : IntArray\n private var time = -1\n\n private fun calculateTimes() {\n timesIn = IntArray(n) { -1 }\n timesOut = IntArray(n) { -1 }\n this.time = 0\n\n timeDfs(root)\n }\n\n private fun timeDfs(from : Int, parent : Int = -1) {\n timesIn[from] = time++\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n timeDfs(to, from)\n }\n\n timesOut[from] = time++\n }\n\n lateinit var parents : Array\n private val maxBit = 19\n\n private fun calculateParents() {\n parents = Array(maxBit) { IntArray(n) { -1 } }\n\n parentDfs(root, root)\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n parents[bit + 1][v] = parents[bit][parent]\n }\n }\n }\n\n private fun parentDfs(from : Int, parent : Int = -1) {\n parents[0][from] = parent\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n parentDfs(to, from)\n }\n }\n\n lateinit var maxEdges : Array\n\n private fun calculatePathInfo() {\n maxEdges = Array(maxBit) { IntArray(n) { -1 } }\n\n for (v in 0 until n){\n for (index in tree[v]) {\n val to = to(v, index)\n if (to == parents[0][v]) continue\n\n maxEdges[0][to] = edges[index].third\n }\n }\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n maxEdges[bit + 1][v] = max(\n maxEdges[bit][v],\n maxEdges[bit][parent]\n )\n }\n }\n }\n\n fun getOnPath(a : Int, b : Int) : Int {\n var answer = Int.MIN_VALUE\n\n answer = max(answer, getOnLcaPath(a, b))\n answer = max(answer, getOnLcaPath(b, a))\n\n return answer\n }\n\n private fun getOnLcaPath(start : Int, other : Int) : Int {\n var answer = Int.MIN_VALUE\n\n if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {\n return answer\n }\n\n var v = start\n for (bit in maxBit - 1 downTo 0) {\n val parent = parents[bit][v]\n if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {\n answer = max(answer, maxEdges[bit][v])\n v = parent\n }\n }\n\n answer = max(answer, maxEdges[0][v])\n\n return answer\n }\n}\n\nfun yesNo(yes : Boolean) {\n out.println(if (yes) \"YES\" else \"NO\")\n}\n\nfun run() {\n init()\n solve()\n out.close()\n}\n\nfun main(args: Array) {\n run()\n}\n\nval ONLINE_JUDGE = !File(\"input.txt\").exists()\n\nval input = BufferedReader(\n if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader(\"input.txt\")\n)\nval out =\n if (ONLINE_JUDGE) PrintWriter(System.out)\n else PrintWriter(\"output.txt\")\n\nfun readStrings(separator: String = \" \", emptyWords: Boolean = false) : Array {\n val line = input.readLine()\n\n val list = ArrayList()\n var builder = StringBuilder()\n\n for (i in 0..line.length) {\n if (i == line.length || separator.contains(line[i])) {\n if (emptyWords || builder.isNotEmpty()) {\n list.add(builder.toString())\n builder = StringBuilder()\n }\n } else {\n builder.append(line[i])\n }\n }\n\n return list.toTypedArray()\n}\n\nfun readString(separator: String = \" \") =\n readStrings(separator).first()\n\nfun readInts(separator: String = \" \") =\n readStrings(separator).map(String::toInt).toIntArray()\n\nfun readDecreasedInts(separator : String = \" \") =\n readInts(separator).map { it - 1 }.toIntArray()\n\nfun readSortedInts(separator: String = \" \") : IntArray {\n val a = readInts(separator)\n\n val aInteger = Array(a.size) { a[it] }\n Arrays.sort(aInteger)\n\n return aInteger.toIntArray()\n}\n\nfun readInt(separator: String = \" \") =\n readInts(separator).first()\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun readLong(separator: String = \" \") =\n readLongs(separator).first()\n\nfun readDoubles(separator: String = \" \") =\n readStrings(separator).map(String::toDouble).toDoubleArray()\n\nfun readDouble(separator: String = \" \") =\n readDoubles(separator).first()\n\nfun readBigIntegers(separator: String = \" \") =\n readStrings(separator).map { BigInteger(it) }.toTypedArray()\n\nfun readBigInteger(separator: String = \" \") =\n readBigIntegers(separator).first()\n\nfun readTree(n : Int, indexing : Int = 1) =\n readGraph(n, n - 1, true, indexing)\n\nfun readGraph(n: Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : Graph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to)\n else builder.addDirectedEdge(from, to)\n }\n\n return builder.build(n)\n}\n\nfun readWeightedGraph(n : Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : WeightedGraph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to, weight) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to, weight)\n else builder.addDirectedEdge(from, to, weight)\n }\n\n return builder.buildWeighted(n)\n}\n\nfun readTotalEdges(m : Int, indexing : Int = 1) =\n TotalEdgeArray(m) {\n var (from, to, w) = readInts()\n\n from -= indexing\n to -= indexing\n\n Triple(from, to, w)\n }\n\nclass GraphBuilder {\n\n private val froms = ArrayList()\n private val tos = ArrayList()\n private val weights = ArrayList()\n\n fun addEdge(from : Int, to : Int, weight : Int = 1) {\n addDirectedEdge(from, to, weight)\n addDirectedEdge(to, from, weight)\n }\n\n fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {\n froms.add(from)\n tos.add(to)\n weights.add(weight)\n }\n\n private fun calculateFromSizes(n : Int) : IntArray {\n val sizes = IntArray(n) { 0 }\n froms.forEach { ++sizes[it] }\n return sizes\n }\n\n fun build(n : Int) : Graph {\n val sizes = calculateFromSizes(n)\n\n val graph = Graph(n) { IntArray(sizes[it]) { 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n\n graph[from][sizes[from]++] = to\n }\n\n return graph\n }\n\n fun buildWeighted(n : Int) : WeightedGraph {\n val sizes = calculateFromSizes(n)\n\n val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n val weight = weights[i]\n\n graph[from][sizes[from]++] = to to weight\n }\n\n return graph\n }\n}\n\nfun gcd(a : Int, b : Int) : Int =\n if (a == 0) b else gcd(b % a, a)\n\nfun gcd(a : Long, b : Long) : Long =\n if (a == 0L) b else gcd(b % a, a)\n\nfun getDivisors(x : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 1\n while (d * d <= x) {\n if (x % d == 0) {\n if (d != 1) divisors.add(d)\n if (x != d) divisors.add(x / d)\n }\n\n ++d\n }\n\n return divisors\n}\n\nfun getPrimeDivisors(xx : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 2\n var x = xx\n while (d * d <= x) {\n if (x % d == 0) {\n divisors.add(d)\n while (x % d == 0) {\n x /= d\n }\n }\n\n ++d\n }\n\n if (x > 1) divisors.add(x)\n\n return divisors\n}\n\nfun checkIndex(index : Int, size : Int) =\n 0 <= index && index < size\n\nfun checkCell(x : Int, n : Int, y : Int, m : Int) =\n checkIndex(x, n) && checkIndex(y, m)\n\nfun toChar(index : Int, start : Char) =\n (index + start.toInt()).toChar()\n\nclass DSU {\n\n var sizes : IntArray\n var ranks : IntArray\n var parents : IntArray\n\n constructor(n : Int)\n : this(\n IntArray(n) { 1 }\n )\n\n constructor(sizes : IntArray) {\n val size = sizes.size\n this.sizes = sizes\n this.ranks = IntArray(size) { 1 }\n this.parents = IntArray(size) { it }\n }\n\n operator fun get(v : Int) : Int {\n val parent = parents[v]\n if (parent == v) return v\n parents[v] = get(parent)\n return parents[v]\n }\n\n fun union(aUniting : Int, bUniting : Int) : Boolean {\n var a = get(aUniting)\n var b = get(bUniting)\n\n if (a == b) return false\n\n if (ranks[a] < ranks[b]) {\n val tmp = a\n a = b\n b = tmp\n }\n\n parents[b] = a\n sizes[a] += sizes[b]\n if (ranks[a] == ranks[b]) ++ranks[a]\n\n return true\n }\n\n fun size(v : Int) : Int = sizes[get(v)]\n}\n\nclass FenwickTree(n : Int) {\n\n val size = n + 1\n val tree = LongArray(size) { 0L }\n\n fun update(index : Int, delta : Int) {\n var x = index + 1\n while (x < size) {\n tree[x] = tree[x] + delta\n x += x and -x\n }\n }\n\n operator fun get(start : Int, end : Int) =\n get(end) - get(start - 1)\n\n operator fun get(index : Int) : Long {\n var result : Long = 0\n\n var x = index + 1\n while (x > 0) {\n result += tree[x]\n x -= x and -x\n }\n\n return result\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "33efd6c88e307ad15b29ea4e6107585a", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (hour, minutes) = readLine()!!.split(\":\").map(String::toInt)\n val minutesPassed = readLine()!!.toInt()\n val totalMinutes = hour * 60 + minutes + minutesPassed\n val newHour = (totalMinutes / 60) % 24\n val newMinutes = totalMinutes % 60\n print(\"${String.format(\"%02d\", newHour)}:${String.format(\"%02d\", newMinutes)}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b0140ef9f73a4eac9eb40e511114f519", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun TreeMap.add(i:Char,x:Int){\n set(i,getOrDefault(i,0)+x)\n}\nfun main(){\n var a=Array(3){readLn().toCharArray()}\n var cnt=TreeMap()\n for(j in 0..2)for(i in a[j])cnt.add(i,1)\n var o=cnt.getOrDefault('0',0)\n var x=cnt.getOrDefault('X',0)\n if(o>x || x>o+1)printLine(\"illegal\")\n else{\n fun win(c:Char):Boolean{\n for(j in 0..2)if(a[j][0]==c&&a[j][1]==c&&a[j][2]==c)return true\n for(j in 0..2)if(a[0][j]==c&&a[1][j]==c&&a[2][j]==c)return true\n if(a[0][0]==c&&a[1][1]==c&&a[2][2]==c)return true\n if(a[2][0]==c&&a[1][1]==c&&a[0][2]==c)return true\n return false\n }\n if(win('X')&&win('0'))printLine(\"illegal\")\n else{\n if(win('X')){\n var ok=false\n for(i in 0..2)for(j in 0..2)if(a[i][j]=='X'){\n a[i][j]='.'\n if(!win('X'))ok=true\n a[i][j]='X'\n }\n if(ok&&x==o+1)printLine(\"the first player won\")\n else printLine(\"illegal\")\n }else if(win('0')){\n var ok=false\n for(i in 0..2)for(j in 0..2)if(a[i][j]=='0'){\n a[i][j]='.'\n if(!win('0'))ok=true\n a[i][j]='0'\n }\n if(ok&&x==o)printLine(\"the second player won\")\n else printLine(\"illegal\")\n }else{\n if(x+o==9)printLine(\"draw\")\n else if(x>o)printLine(\"second\")\n else printLine(\"first\")\n }\n }\n }\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4cd09e081b5714de528926d5aa8544d2", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nval FIRST = 'X'\nval SECOND = '0'\n\nfun main() {\n val reader = Scanner(System.`in`)\n\n val board = mutableListOf()\n repeat(3) { board.add(reader.nextLine().trim()) }\n\n val zeros = board.sumBy { row -> row.count { it == '0' } }\n val xs = board.sumBy { row -> row.count { it == 'X' } }\n\n fun won(c: Char): Boolean {\n for (i in 0 until 3) {\n if (board[i].all { it == c }) return true\n if (board.all { row -> row[i] == c }) return true\n }\n\n if ((0 until 3).map { board[it][it] }.all { it == c }) return true\n if ((0 until 3).map { board[it][2 - it] }.all { it == c }) return true\n\n return false\n }\n\n when (xs - zeros) {\n 1 -> when {\n won(SECOND) -> println(\"illegal\")\n won(FIRST) -> println(\"the first player won\")\n xs == 5 -> println(\"draw\")\n else -> println(\"second\")\n }\n 0 ->\n when {\n won(FIRST) -> println(\"illegal\")\n won(SECOND) -> println(\"the second player won\")\n else -> println(\"first\")\n }\n else -> println(\"illegal\")\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "89042e3af35781d8539541731a96c62b", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n main { readLine() }\n}\n\nfun main(readLine: () -> String?) {\n val problem = readProblem(readLine)\n val solution = solve(problem)\n printSolution(solution)\n}\n\n// READ PROBLEM\n\nprivate fun readProblem(readLine: () -> String?): Problem {\n val input = (readLine() + readLine() + readLine())\n return Problem(input.map(::charToPlayer))\n}\n\nprivate fun charToPlayer(c: Char): Player? {\n when (c) {\n 'X' -> return Player.X\n '0' -> return Player.O\n else -> return null\n }\n}\n\nprivate class Problem(val board: List) {\n override fun toString(): String {\n return board.joinToString(\" \")\n }\n\n fun countX(): Int {\n return board.filter { it == Player.X }.count()\n }\n\n fun countO(): Int {\n return board.filter { it == Player.O }.count()\n }\n\n fun hasThreeX(): Boolean {\n val xs = board.map { it == Player.X }\n return isWinning(xs)\n }\n\n fun hasThreeO(): Boolean {\n val os = board.map { it == Player.O }\n return isWinning(os)\n }\n\n private fun isWinning(b: List): Boolean {\n return (b[0] && b[1] && b[2])\n || (b[3] && b[4] && b[5])\n || (b[6] && b[7] && b[8])\n || (b[0] && b[3] && b[6])\n || (b[1] && b[4] && b[7])\n || (b[2] && b[5] && b[8])\n || (b[0] && b[4] && b[8])\n || (b[2] && b[4] && b[6])\n }\n}\n\nprivate enum class Player {\n X, O\n}\n\n// SOLVE PROBLEM\n\nprivate fun solve(prob: Problem): Solution {\n // x - it's the first player\n // o - it's the second player\n val xNo = prob.countX()\n val oNo = prob.countO()\n val xWon = prob.hasThreeX()\n val oWon = prob.hasThreeO()\n\n when {\n (xNo < oNo) -> return Solution.ILLEGAL\n (xNo > (oNo + 1)) -> return Solution.ILLEGAL\n (xWon && oWon) -> return Solution.ILLEGAL\n (xWon && (xNo > oNo)) -> return Solution.FIRST_WON\n (xWon) -> return Solution.ILLEGAL\n (oWon && (xNo == oNo)) -> return Solution.SECOND_WON\n (oWon) -> return Solution.ILLEGAL\n (xNo + oNo == 9) -> return Solution.DRAW\n (xNo == oNo) -> return Solution.FIRST\n (xNo > oNo) -> return Solution.SECOND\n else -> return Solution.ILLEGAL\n }\n}\n\n// PRINT SOLUTION\n\nprivate enum class Solution(val txt: String) {\n FIRST(\"first\"),\n SECOND(\"second\"),\n ILLEGAL(\"illegal\"),\n FIRST_WON(\"the first player won\"),\n SECOND_WON(\"the second player won\"),\n DRAW(\"draw\");\n\n fun print(consumer: (String) -> Unit) {\n consumer(txt)\n }\n}\n\nprivate fun printSolution(solution: Solution) {\n solution.print(::println)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "85a15d8a4da9b03fa5294cfb86f585ac", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.lang.Exception\n\nfun main() {\n // 0 || X || .\n var num1 = 0 //The first player draws X goes\n var num2 = 0 //The second player draws 0 goes\n var spaceNum = 0 // space are '.'\n val table = arrayListOf(readLine()!!.toCharArray())\n var isFull = !table[0].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[1].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[2].any() { it == '.' }\n for (k in table.indices) {\n for (i in table[k].indices) {\n when {\n table[k][i] == 'X' -> {\n num1++\n }\n table[k][i] == '0' -> {\n num2++\n }\n table[k][i] == '.' -> {\n spaceNum++\n }\n }\n }\n }\n //println(\"num1 : $num1, num2 : $num2\")\n if (num1 - num2 != 0 && num1 - num2 != 1) {\n println(\"illegal\")\n return\n }\n val checkChar = if (num1 == num2) {\n '0'\n } else {\n 'X'\n }\n //println(\"check : $checkChar\")\n for (i in 0..2) { // fin\n if (checkChar == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {\n return\n }\n if (checkChar == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {\n return\n }\n }\n if (checkChar == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {\n return\n }\n if (checkChar == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {\n return\n }\n\n if (!isFull) {\n if (num1 - num2 == 0) {\n println(\"first\")\n } else if (num1 - num2 == 1) {\n println(\"second\")\n }\n return\n } else {\n println(\"draw\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c1918077e376ecde8d12933692f07938", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.lang.Exception\n\nfun main() {\n // 0 || X || .\n var num1 = 0 //The first player draws X goes\n var num2 = 0 //The second player draws 0 goes\n var spaceNum = 0 // space are '.'\n val table = arrayListOf(readLine()!!.toCharArray())\n var isFull = !table[0].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[1].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[2].any() { it == '.' }\n for (k in table.indices) {\n for (i in table[k].indices) {\n when {\n table[k][i] == 'X' -> {\n num1++\n }\n table[k][i] == '0' -> {\n num2++\n }\n table[k][i] == '.' -> {\n spaceNum++\n }\n }\n }\n }\n //println(\"num1 : $num1, num2 : $num2\")\n if (num1 - num2 != 0 && num1 - num2 != 1) {\n println(\"illegal\")\n return\n }\n val checkChar = arrayOf('X', '0')\n var won = arrayOf(0, 0)\n for (c in 0..1) {\n for (i in 0..2) { // fin\n if (checkChar[c] == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {\n won[c]++\n }\n if (checkChar[c] == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {\n won[c]++\n }\n }\n if (checkChar[c] == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {\n won[c]++\n }\n if (checkChar[c] == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {\n won[c]++\n }\n }\n //println(\"check : $checkChar\")\n\n if (won[0] >= 1 && won[1] >= 1) {\n println(\"illegal\")\n return\n } else if (won[0] >= 1) {\n println(\"the first player won\")\n return\n } else if (won[1] >= 1) {\n println(\"the second player won\")\n return\n }\n\n if (!isFull) {\n if (num1 - num2 == 0) {\n println(\"first\")\n } else if (num1 - num2 == 1) {\n println(\"second\")\n }\n return\n } else {\n println(\"draw\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0ed3561bceae4b7fdc813e56f9d3e459", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun TreeMap.add(i:Char,x:Int){\n set(i,getOrDefault(i,0)+x)\n}\nfun main(){\n var a=Array(3){readLn().toCharArray()}\n var cnt=TreeMap()\n for(j in 0..2)for(i in a[j])cnt.add(i,1)\n var o=cnt.getOrDefault('0',0)\n var x=cnt.getOrDefault('X',0)\n if(o>x || x>o+1)printLine(\"illegal\")\n else{\n fun win(c:Char):Boolean{\n for(j in 0..2)if(a[j][0]==c&&a[j][1]==c&&a[j][2]==c)return true\n for(j in 0..2)if(a[0][j]==c&&a[1][j]==c&&a[2][j]==c)return true\n if(a[0][0]==c&&a[1][1]==c&&a[2][2]==c)return true\n if(a[2][0]==c&&a[1][1]==c&&a[0][2]==c)return true\n return false\n }\n if(win('X')&&win('0'))printLine(\"illegal\")\n else{\n if(win('X')){\n var ok=false\n for(i in 0..2)for(j in 0..2){\n a[i][j]='.'\n if(!win('X'))ok=true\n a[i][j]='X'\n }\n if(ok&&x==o+1)printLine(\"the first player won\")\n else printLine(\"illegal\")\n }else if(win('0')){\n var ok=false\n for(i in 0..2)for(j in 0..2){\n a[i][j]='.'\n if(!win('0'))ok=true\n a[i][j]='0'\n }\n if(ok&&x==o)printLine(\"the second player won\")\n else printLine(\"illegal\")\n }else{\n if(x+o==9)printLine(\"draw\")\n else if(x>o)printLine(\"second\")\n else printLine(\"first\")\n }\n }\n }\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a80c52f1adfb4bd2728d514e3fb95cce", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n main { readLine() }\n}\n\nfun main(readLine: () -> String?) {\n val problem = readProblem(readLine)\n val solution = solve(problem)\n printSolution(solution)\n}\n\n// READ PROBLEM\n\nprivate fun readProblem(readLine: () -> String?): Problem {\n val input = (readLine() + readLine() + readLine())\n return Problem(input.map(::charToPlayer))\n}\n\nprivate fun charToPlayer(c: Char): Player? {\n when (c) {\n 'X' -> return Player.X\n '0' -> return Player.O\n else -> return null\n }\n}\n\nprivate class Problem(val board: List) {\n override fun toString(): String {\n return board.joinToString(\" \")\n }\n\n fun countX(): Int {\n return board.filter { it == Player.X }.count()\n }\n\n fun countO(): Int {\n return board.filter { it == Player.O }.count()\n }\n\n fun hasThreeX(): Boolean {\n val xs = board.map { it == Player.X }\n return isWinning(xs)\n }\n\n fun hasThreeO(): Boolean {\n val os = board.map { it == Player.O }\n return isWinning(os)\n }\n\n private fun isWinning(b: List): Boolean {\n return (b[0] && b[1] && b[2])\n || (b[3] && b[4] && b[5])\n || (b[6] && b[7] && b[8])\n || (b[0] && b[3] && b[6])\n || (b[1] && b[4] && b[7])\n || (b[2] && b[5] && b[8])\n || (b[0] && b[4] && b[8])\n || (b[2] && b[4] && b[6])\n }\n}\n\nprivate enum class Player {\n X, O\n}\n\n// SOLVE PROBLEM\n\nprivate fun solve(prob: Problem): Solution {\n // x - it's the first player\n // o - it's the second player\n val xNo = prob.countX()\n val oNo = prob.countO()\n val xWon = prob.hasThreeX()\n val oWon = prob.hasThreeO()\n\n when {\n (xNo < oNo) -> return Solution.ILLEGAL\n (xNo > (oNo + 1)) -> return Solution.ILLEGAL\n (xWon && oWon) -> return Solution.ILLEGAL\n (xWon && (xNo > oNo)) -> return Solution.FIRST_WON\n (xWon) -> return Solution.ILLEGAL\n (oWon && (xNo == oNo)) -> return Solution.SECOND_WON\n (oWon) -> return Solution.ILLEGAL\n (xNo == oNo) -> return Solution.FIRST\n (xNo > oNo) -> return Solution.SECOND\n else -> return Solution.ILLEGAL\n }\n}\n\n// PRINT SOLUTION\n\nprivate enum class Solution(val txt: String) {\n FIRST(\"first\"),\n SECOND(\"second\"),\n ILLEGAL(\"illegal\"),\n FIRST_WON(\"the first player won\"),\n SECOND_WON(\"the second player won\"),\n DRAW(\"draw\");\n\n fun print(consumer: (String) -> Unit) {\n consumer(txt)\n }\n}\n\nprivate fun printSolution(solution: Solution) {\n solution.print(::println)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b91a0a8150b2e9b16ce9c5cae4c88b58", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.lang.Exception\n\nfun main() {\n // 0 || X || .\n var num1 = 0 //The first player draws X goes\n var num2 = 0 //The second player draws 0 goes\n var spaceNum = 0 // space are '.'\n val table = arrayListOf(readLine()!!.toCharArray())\n var isFull = !table[0].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[1].any() { it == '.' }\n table.add(readLine()!!.toCharArray())\n isFull = isFull && !table[2].any() { it == '.' }\n for (k in table.indices) {\n for (i in table[k].indices) {\n when {\n table[k][i] == 'X' -> {\n num1++\n }\n table[k][i] == '0' -> {\n num2++\n }\n table[k][i] == '.' -> {\n spaceNum++\n }\n }\n }\n }\n //println(\"num1 : $num1, num2 : $num2\")\n if (num1 - num2 != 0 && num1 - num2 != 1) {\n println(\"illegal\")\n return\n }\n val checkChar = arrayOf('X', '0')\n var won = arrayOf(0, 0)\n for (c in 0..1) {\n for (i in 0..2) { // fin\n if (checkChar[c] == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {\n won[c]++\n }\n if (checkChar[c] == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {\n won[c]++\n }\n }\n if (checkChar[c] == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {\n won[c]++\n }\n if (checkChar[c] == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {\n won[c]++\n }\n }\n //println(\"check : $checkChar\")\n\n if (won[0] >= 1 && won[1] >= 1) {\n println(\"illegal\")\n return\n } else if (won[0] == 1) {\n println(\"the first player won\")\n } else if (won[1] == 1) {\n println(\"the second player won\")\n }\n\n if (!isFull) {\n if (num1 - num2 == 0) {\n println(\"first\")\n } else if (num1 - num2 == 1) {\n println(\"second\")\n }\n return\n } else {\n println(\"draw\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d2282a11a83ec11505db87e690f67694", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main() {\n\n val sc = Scanner(System.`in`)\n val x : Int = sc.nextInt()\n val t : Int = sc.nextInt()\n val a : Int = sc.nextInt()\n val b : Int = sc.nextInt()\n val da : Int = sc.nextInt()\n val db : Int = sc.nextInt()\n\n for (i in 0 until t) {\n for (j in 0 until t) {\n if ((a - i * da) + (b - j * db) == x || a - i * da == x || b - j * db == x || x == 0) {\n print(\"YES\")\n return\n }\n }\n }\n\n print(\"NO\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "64eca3d5bf00b9deac7f95b929342553", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport java.util.Arrays\nfun main(){\n val input=Scanner(System.`in`)\n var x:Int=input.nextInt()\n var t:Int=input.nextInt()\n var a:Int=input.nextInt()\n var b:Int=input.nextInt()\n var c:Int=input.nextInt()\n var d:Int=input.nextInt()\n for(i in 0 until t){\n for(j in 0 until t){\n if(a-(i*c)+b-(j*d)==x||a-(i*c)==x||b-(j*d)==x||x==0){\n print(\"YES\")\n return\n }\n }\n }\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b2d9ccbd96c8e82e45ce497e4b711222", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main() {\n\n val sc = Scanner(System.`in`)\n val x : Int = sc.nextInt()\n val t : Int = sc.nextInt()\n val a : Int = sc.nextInt()\n val b : Int = sc.nextInt()\n val da : Int = sc.nextInt()\n val db : Int = sc.nextInt()\n\n for (i : Int in 0 until t) {\n for (j : Int in 0 until t) {\n if ((a - i * da) + (b - j * db) == x || a - i * da == x || b - j * db == x || x == 0) {\n print(\"YES\")\n return\n }\n }\n }\n\n print(\"NO\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "48b8889d8c980512a9e44226dc59cb6e", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.HashSet\n\nfun separate(s: IntArray, q: String): IntArray {\n for(sp in s)\n if(sp >= q.length)\n return IntArray(0, { it })\n\n val c = HashSet()\n\n c.add(q[0])\n for(i in 0..s.size - 1) {\n if(q[s[i]] in c) {\n s[0]++\n\n for(j in 1..s.size - 1) {\n if(s[j] == s[j - 1]) {\n s[j - 1] = 0\n s[j]++\n }\n }\n\n return separate(s, q)\n }\n c.add(q[s[i]])\n }\n\n return s\n}\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = readLine() ?: \"\"\n\n if(k > 1) {\n val s = separate(IntArray(k - 1, { it + 1 }), q)\n\n if(s.size > 0) {\n println(\"YES\")\n println(q.subSequence(0, s[0]))\n\n for(i in 0..s.size - 2) {\n println(q.subSequence(s[i], s[i + 1]))\n }\n\n println(q.subSequence(s[s.size - 1], q.length))\n } else {\n println(\"NO\")\n }\n } else {\n println(\"YES\")\n println(q)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "deb116832d2075a2c12adc7fd5ee2841", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.HashSet\n\nfun separate(s: IntArray, q: String): IntArray {\n if(s[s.size - 1] == q.length)\n return IntArray(0, { it })\n\n val c = HashSet()\n\n c.add(q[0])\n for(i in 0..s.size - 1) {\n if(q[s[i]] in c) {\n s[0]++\n\n for(j in 1..s.size - 1) {\n if(s[j] == s[j - 1]) {\n s[j - 1] = 0\n s[j]++\n }\n }\n\n return separate(s, q)\n }\n c.add(q[s[i]])\n }\n\n return s\n}\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = readLine() ?: \"\"\n\n if(k > 1) {\n val s = separate(IntArray(k - 1, { it + 1 }), q)\n\n if(s.size > 0) {\n println(\"YES\")\n println(q.subSequence(0, s[0]))\n\n if(s.size > 2)\n for(i in 1..s.size - 2) {\n println(q.subSequence(s[i], s[i + 1]))\n }\n\n println(q.subSequence(s[s.size - 1], q.length))\n } else {\n println(\"NO\")\n }\n } else {\n println(\"YES\")\n println(q)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "438bd72f23284c4cdeaf730004b45a9b", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.HashSet\n\nfun separate(s: IntArray, q: String): IntArray {\n if(s[s.size - 1] == q.length)\n return IntArray(0, { it })\n\n val c = HashSet()\n\n c.add(q[0])\n for(i in 0..s.size - 1) {\n if(q[s[i]] in c) {\n s[0]++\n\n for(j in 1..s.size - 1) {\n if(s[j] == s[j - 1]) {\n s[j - 1] = 0\n s[j]++\n }\n }\n\n return separate(s, q)\n }\n c.add(q[s[i]])\n }\n\n return s\n}\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = readLine() ?: \"\"\n\n if(k > 1) {\n val s = separate(IntArray(k - 1, { it + 1 }), q)\n\n if(s.size > 0) {\n println(\"Yes\")\n println(q.subSequence(0, s[0]))\n\n if(s.size > 2)\n for(i in 1..s.size - 2) {\n println(q.subSequence(s[i], s[i + 1]))\n }\n\n println(q.subSequence(s[s.size - 1], q.length))\n } else {\n println(\"No\")\n }\n } else {\n println(\"Yes\")\n println(q)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "28d5bfce8b6c3ea8b54e370d2fbdd490", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.HashSet\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = readLine() ?: \"\"\n\n if(k > 1) {\n var s = IntArray(k - 1, { it + 1 })\n\n loop@ while(s[s.size - 1] < q.length) {\n val c = HashSet()\n\n c.add(q[0])\n for(i in 0 until s.size) {\n if(q[s[i]] in c) {\n s[0]++\n\n for(j in 1 until s.size) {\n if(s[j] == s[j - 1]) {\n s[j - 1] = j\n s[j]++\n }\n }\n\n continue@loop\n }\n c.add(q[s[i]])\n }\n\n println(\"YES\")\n println(q.subSequence(0, s[0]))\n\n for(i in 0..s.size - 2) {\n println(q.subSequence(s[i], s[i + 1]))\n }\n\n println(q.subSequence(s[s.size - 1], q.length))\n\n return\n }\n\n println(\"NO\")\n } else {\n println(\"YES\")\n println(q)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "70d267013e9ce48f7a0b9f314b1b4d1f", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.HashSet\n\nfun separate(s: IntArray, q: String): IntArray {\n if(s[s.size - 1] == q.length)\n return IntArray(0, { it })\n\n val c = HashSet()\n\n c.add(q[0])\n for(i in 0..s.size - 1) {\n if(q[s[i]] in c) {\n s[0]++\n\n for(j in 1..s.size - 1) {\n if(s[j] == s[j - 1]) {\n s[j - 1] = 0\n s[j]++\n }\n }\n\n return separate(s, q)\n }\n c.add(q[s[i]])\n }\n\n return s\n}\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = readLine() ?: \"\"\n\n if(k > 1) {\n val s = separate(IntArray(k - 1, { it + 1 }), q)\n\n if(s.size > 0) {\n println(\"YES\")\n println(q.subSequence(0, s[0]))\n\n for(i in 0..s.size - 2) {\n println(q.subSequence(s[i], s[i + 1]))\n }\n\n println(q.subSequence(s[s.size - 1], q.length))\n } else {\n println(\"NO\")\n }\n } else {\n println(\"YES\")\n println(q)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0f009c71cbb19fb48c945ec028acf03f", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args:Array){\n val obj=Scanner(System.`in`)\n val dna=obj.next()\n var status='z'\n var count=1\n var ins=0\n for(c in dna){\n if(c!=status) {\n if(count%2==0)\n ++ins\n count=0\n status=c\n }\n ++count\n }\n if(count%2==0) ++ins\n println(ins)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "208d5b4178dc487110ae785f6ae6a335", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args:Array)\n{\n\n var counter = 1\n var insert = 0\n var c = 0.toChar()\n val input = readLine()\n\n input?.forEach {\n if( it == c ) {\n counter++\n }\n else {\n if( counter % 2 == 0 ) insert++\n counter = 1\n c = it\n }\n }\n\n if( counter % 2 == 0 ) insert++\n\n println(insert)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fb36ba4b48b36fcc79b47eb961406401", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "/*\n1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)\n integer in an array of length 100 of map of nucleos\n2. go from top and increment number of inserts by 1 for each even length until max length is only uneven\n */\n\nprivate const val maxDnaLength = 101\n\nfun main() {\n val dna = readLine()!!\n var currentSequenceLength = 1\n var currentNucleo = dna[0]\n var inserts = 0\n for (i in 1 until dna.length) {\n if (dna[i] != currentNucleo) {\n if (currentSequenceLength % 2 == 0) inserts++\n currentSequenceLength = 1\n currentNucleo = dna[i]\n } else {\n currentSequenceLength++\n }\n }\n if (currentSequenceLength % 2 == 0) inserts++\n println(inserts)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f2d21462d30d0f3d0bee8f324eedf41", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args:Array){\n val obj=Scanner(System.`in`)\n val dna=obj.next()\n var status='z'\n var count=1\n var ins=0\n for(c in dna){\n if(c!=status) {\n if(count%2==0)\n ++ins\n count=0\n status=c\n }\n ++count\n }\n println(ins)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b74ed372890386f21ab3c7cd647c50fb", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "/*\n1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)\n integer in an array of length 100 of map of nucleos\n2. go from top and increment number of inserts by 1 for each even length until max length is only uneven\n */\n\nprivate const val maxDnaLength = 101\n\nfun main() {\n val dna = readLine()!!\n var currentSequenceLength = 1\n var currentNucleo = dna[0]\n var inserts = 0\n for (i in 1 until dna.length) {\n if (dna[i] != currentNucleo) {\n if (currentSequenceLength % 2 == 0) inserts++\n currentSequenceLength = 1\n currentNucleo = dna[i]\n } else {\n currentSequenceLength++\n }\n }\n println(inserts)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e9f0722f7a4610d6564e38453b8f90cf", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "\nfun main(args:Array)\n{\n\n var counter = 1\n var insert = 0\n var c = 0.toChar()\n val input = readLine()\n\n input?.forEach {\n if( it == c ) {\n counter++\n }\n else {\n if( counter % 2 == 0 ) insert++\n counter = 1\n c = it\n }\n }\n\n println(insert)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c547491d1519075d272f18f221fe486", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "/*\n1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)\n integer in an array of length 100 of map of nucleos\n2. go from top and increment number of inserts by 1 for each even length until max length is only uneven\n */\n\nprivate const val maxDnaLength = 101\n\nfun main() {\n val dna = readLine()!!\n val lengths = countSubsequencesLengths(dna)\n val insertsCount = lengths.values.sumBy { calculateCountOfInserts(it) }\n println(insertsCount)\n}\n\nprivate fun countSubsequencesLengths(dna: String): Map {\n val subsequenceLengths = mapOf(\n 'A' to IntArray(maxDnaLength),\n 'T' to IntArray(maxDnaLength),\n 'G' to IntArray(maxDnaLength),\n 'C' to IntArray(maxDnaLength)\n )\n var currentSequenceLength = 1\n var currentNucleo = dna[0]\n for (i in 1 until dna.length) {\n if (dna[i] != currentNucleo) {\n recordLength(subsequenceLengths, currentNucleo, currentSequenceLength)\n currentNucleo = dna[i]\n currentSequenceLength = 1\n } else {\n currentSequenceLength++\n }\n }\n recordLength(subsequenceLengths, currentNucleo, currentSequenceLength)\n return subsequenceLengths\n}\n\nprivate fun recordLength(subsequenceLengths: Map, currentNucleo: Char, currentSequenceLength: Int) {\n val array = subsequenceLengths.getValue(currentNucleo)\n array[currentSequenceLength] = array[currentSequenceLength].inc()\n}\n\nprivate fun calculateCountOfInserts(lengths: IntArray): Int {\n for (i in (lengths.size - 1) downTo 0) {\n if (lengths[i] == 0) continue\n return if (i % 2 == 0) lengths[i] else 0\n }\n return 0\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "584d41c47883fc0d90f43456b8473ed5", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "package application\n\nfun main(args:Array)\n{\n\n var counter = 1\n var insert = 0\n var c = 0.toChar()\n val input = readLine()\n\n input?.forEach {\n if( it == c ) {\n counter++\n }\n else {\n if( counter % 2 == 0 ) insert++\n counter = 1\n c = it\n }\n }\n\n println(insert)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e361033518e97ff9c1bb807cc1db3279", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashMap\n\nfun main() {\n val `in` = Scanner(System.`in`)\n val count = `in`.nextInt()\n val b = HashMap()\n for (i in 0 until count) {\n b[`in`.nextInt()] = 1\n }\n var c = 0;\n b.forEach { t, u ->\n if (t > 0) {\n c++\n }\n }\n println(c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bfcfea73a2c1657000e9506b80127814", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n with(Scanner(System.`in`)) {\n val n = nextInt()\n val a = Array(n, {\n nextInt()\n })\n println(a.distinct().count { it > 0 })\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1dcea189fe7e2f8bca6e64a22a9ae4a2", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//kotlinc kot.kt -include-runtime -d kot.jar\n//java -jar kot.jar\nimport kotlin.math.*\nimport java.util.ArrayList\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of ints\n\nfun main(){\n\tvar n = readInt()\n\tvar arr: ArrayList = ArrayList(n)\n\tvar x = readLine()!!.split((' ')).map(String::toInt)\n\tfor(i in 0..n-1){\n\t\tarr.add(x[i.toInt()])\n\t}\n\tvar cnt: ArrayList = ArrayList(20020)\n\tfor(i in 0..(20020-1)){\n\t\tcnt.add(0)\n\t}\n\tvar ans = 0\n\tfor(i in 0..n-1){\n\t\tvar aa = arr[i.toInt()]\n\t\tif( (arr[i.toInt()] > 0) && (cnt[aa] == 0) ) { \n\t\t\tans = ans + 1\n\t\t\tcnt[aa] = 1\n\t\t}\n\t}\n\tprintln(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0bc26591e856e591b5a2644ddf7d46fe", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val N = nextInt()\n var a = BooleanArray(603, {false})\n var nr = 0\n for(i in 0..N-1) {\n val x = nextInt()\n if(!a[x] && x > 0) nr++;\n if(x > 0) a[x] = true\n }\n println(nr)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c0ca6aa9292be8821865d94621d0cc87", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n val input = readInts().toMutableSet()\n input.remove(0)\n print(input.size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e7186e68d0db42c3afa5c8596333a601", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashMap\n\nfun main() {\n val `in` = Scanner(System.`in`)\n val count = `in`.nextInt()\n val b = HashMap()\n for (i in 0 until count) {\n b[`in`.nextInt()] = 1\n }\n println(b.size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "800b063cbd5da9f145859eeda0b57ab0", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//kotlinc kot.kt -include-runtime -d kot.jar\n//java -jar kot.jar\nimport kotlin.math.*\nimport java.util.ArrayList\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of ints\n\nfun main(){\n\tvar n = readInt()\n\tvar arr: ArrayList = ArrayList(n)\n\tfor(i in 0..n-1){\n\t\tvar x = readInt()\n\t\tarr.add(x)\n\t}\n\tvar cnt: ArrayList = ArrayList(20020)\n\tfor(i in 0..(20020-1)){\n\t\tcnt.add(0)\n\t}\n\tvar ans = 0\n\tfor(i in 0..n-1){\n\t\tvar aa = arr[i.toInt()]\n\t\tif( (arr[i.toInt()] > 0) && (cnt[aa] == 0) ) { \n\t\t\tans = ans + 1\n\t\t\tcnt[aa] = 1\n\t\t}\n\t}\n\tprintln(ans)\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1bebfaa9423d52ca4b136e4554922f0c", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport kotlin.math.min\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var a: Int = reader.nextInt()\n var b: Int = reader.nextInt()\n var x: Int = reader.nextInt()\n var y: Int = reader.nextInt()\n\n var d = gcd(x,y)\n x = x / d\n y = y / d\n\n var m = min(a/x, b/y)\n\n print(m*x)\n print(\" \")\n print(m*y)\n\n}\n\nfun gcd(a:Int, b: Int):Int{\n if(b==0){\n return a\n }\n else{\n return gcd(b,a%b)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c746475e3c6fcd49c517f303d964323c", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (a, b, x, y) = readLine()!!.split(' ').map {it.toInt()}\n val g = gcd(x, y)\n x /= g; y /= g\n val k = minOf(a / x, b / y)\n println(\"%d %d\".format(x * k, y * k))\n}\n\nfun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1c48da94a102bf58d180581595360277", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n }\n\n var tok = StringTokenizer(\"\")\n\n fun close() { rd.close(); wr.close() }\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun readToken(): String {\n while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())\n return tok.nextToken()\n }\n fun readInt() = readToken().toInt()\n fun readLong() = readToken().toLong()\n fun readLine() : String {\n tok = StringTokenizer(\"\")\n return rd.readLine()\n }\n}\n\nfun main(args: Array) {\n Thread({ val io = ProblemIO.console(); solve(io) ; io.close() }).start()\n}\n\nfun solve(io: ProblemIO) {\n val n = io.readInt()\n val bad = IntArray(n + 1)\n val good = IntArray(n + 1)\n bad[1] = 0\n good[1] = 1\n for (i in 2 .. n) {\n bad[i] = i - 1 + bad[i - 1]\n good[i] = 1 + bad[i - 1] + good[i - 1]\n }\n io.println(bad[n] + good[n])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e663f4e132cd12257a9c5a1d7541ca73", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n var n = readInt() + 1\n var selecting = 1\n var result = 0\n while (--n > 0) {\n result += 1 + selecting * n - selecting\n selecting++\n }\n print(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3cccf8c0b40d381d04fe88e1bace615e", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toInt()\n var ans: Int = 0\n var i: Int = 1\n while (n >= 1) {\n ans += (n * i) - (i - 1)\n n--\n i++\n }\n print(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f295fe8723e1e2ea9fcc97cfe679e473", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val input = readLine()!!.toInt()\n var level = 1\n var presses = input\n for (i in input downTo 1) {\n val mistakes = i - 1\n presses += level++ * mistakes\n }\n println(presses)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ef752cbc88b70e3826ffdba41cddf845", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val k = r.readLine()!!.toInt()\n //val v = r.readLine()!!.split(\" \").map { it.toInt() }.sortedDescending()\n val ans = k+(1..k-1).fold(0L){acc, i -> acc + i*(k-i)}\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "39fa11ffbf0b94c7e87c8d45a6ebe3d8", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n = readLine()!!.toInt()\n var i=2\n var ans=n\n while (n-- > 1){\n ans+= (n-1)*i +1\n i++\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "274aa0d3340ca7cb3e9a41ddbad0d968", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var answer = 0\n var buttons = n\n for (i in 1..n) {\n val errors = buttons - 1\n val correct = 1\n val totalPresses = errors * i + correct\n answer += totalPresses\n buttons--\n }\n\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f6f08e1bbef18a9169c00311748251e2", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\n val n_nullable_str = readLine()\n if (n_nullable_str == null) {\n // Do nothing ...\n } else {\n val n_str = n_nullable_str\n val n = n_str.toLong()\n val t_1 = (n * n * (n + 1)) / 2\n val t_2 = (n * (n + 1) * ((2 * n) + 1)) / 6\n val t_3 = n\n val result = t_1 - t_2 + t_3\n println(\"${result}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "835a98dde7f8d90d4d56599d3d2f004a", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n= readLine()!!.toLong()\n val result=(n-1)*n*(n+1)/6+n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a344e13035c88b8c42ab355510f31eb2", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n print((n * n * (n - 1)) / 2 - (n * (n - 1) * (2 * n - 1)) / 6 + n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cb9f6f608b2bc3c5fcbb6db951880c7f", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine().toInt()\n var answer = 0\n var buttons = n\n for (i in 1..n) {\n val errors = buttons - 1\n val correct = 1\n val totalPresses = errors * i + correct\n answer += totalPresses\n buttons--\n }\n\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ab7c0b5d7f24c2cc08aca9c347030e7a", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n println(n * (n + 1) / 2 + n -2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f480efd4d135ef4dd36da66c53fff75a", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n println(n * (n + 1) / 2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d5f13405ab08013f81cc6b8aad7f5d7c", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n print((n*(n-1))+1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5242262fa5177d2329b39109d651b42f", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n var ans = 1\n for (i in 2..n){\n ans*=i\n }\n print(ans+1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fbde9602fe59af70ddc6f343ca199338", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val result=(n-1)*(n*(n+1)/6)+n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9902a90884f8a46cce6b2ef897ff2b08", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n\n println(\"0 0 $n\")\n}\n\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c0cdfc6df429a21500534e2847ec93c7", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n var n = readLine()!!.toInt()\n\n if (n == 0) {\n print(\"0 0 0\")\n return\n }\n\n var n1 = 0;\n var n2 = 1;\n var n3 = 1;\n\n while (n3 != n) {\n n1 = n2\n n2 = n3\n n3 = n1 + n2\n }\n\n print(\"$n1 $n2 0\")\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0490c77b4a42ac223211558f38355629", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args : Array) {\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n\n print(0)\n print(\" \")\n print(0)\n print(\" \")\n print(n)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "64dee9271a268822d26ff9a49257e1b2", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val n = readInt()\n print(\n when (n) {\n 0 -> \"0 0 0\"\n 1 -> \"0 0 1\"\n 2 -> \"0 1 1\"\n else -> {\n val nums = intArrayOf(0, 1, 1, 2)\n var pos = 0\n while (nums[(pos + 2) % 4] + nums[(pos + 3) % 4] != n) {\n nums[pos] = nums[(pos + 2) % 4] + nums[(pos + 3) % 4]\n pos = (pos + 1) % 4\n }\n \"${nums[pos]} ${nums[(pos + 1) % 4]} ${nums[(pos + 3) % 4]}\"\n }\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d883d51a87d222d3ff0165a7614dd2d4", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.lang.Math.*\n\n\nprivate fun exit(msg: String) {\n println(msg)\n System.exit(0)\n}\nprivate fun exit(msg: Int) = exit(\"\"+msg)\n\n\nfun main(args: Array) {\n val scan = object {\n private val reader = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n \n internal operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreTokens()) {\n t = StringTokenizer(line())\n }\n return t.nextToken().apply { tokenizer = t }\n }\n \n internal fun int(): Int = next().toInt()\n internal fun long(): Long = next().toLong()\n internal fun double() = next().toDouble()\n \n internal fun line() = reader.readLine()\n \n }\n\n val n = scan.int()\n exit(\"0 0 $n\")\n}\n\n ", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "babcfb82eba126dce83baedd801f9bc0", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\nval n = readLine()!!.toInt()\nprintln(\"0 0 $n\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2e7ea9c6816df5373ff6a1d07a53cf7d", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val n = 50\n //val (n, k) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val v = r.readLine()!!.split(\" \").map { it.toInt() }\n val fib = LongArray(n) { 0L }\n fib[1] = 1\n (2..n-1).forEach { fib[it] = fib[it-1]+fib[it-2] }\n val num = r.readLine()!!.toInt()\n when{\n num==0 -> println(\"0 0 0\")\n num==1 -> println(\"0 0 1\")\n else -> {\n val inedx = fib.indexOf(num.toLong())\n println(\"${fib[inedx-3]} ${fib[inedx-2]} ${fib[inedx-2]}\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a8ab59b2c1cd8a881f4816d734878414", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toInt()\n println(\"0 0 $n\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1c3f5e4743684b256cf9648868352132", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n println(\"0 0 \" + n.toString())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f7b1702e11ec5a774d8a3286a9bfcb2f", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "// from tutorial\nfun main() {\n print(\"0 0 ${readLine()!!}\")\n}\n\n//fun main() {\n// fun readInt() = readLine()!!.toInt()\n//\n// val n = readInt()\n// print(\n// when (n) {\n// 0 -> \"0 0 0\"\n// 1 -> \"0 0 1\"\n// 2 -> \"0 1 1\"\n// else -> {\n// val nums = intArrayOf(0, 1, 1, 2)\n// var pos = 0\n// while (nums[(pos + 2) % 4] + nums[(pos + 3) % 4] != n) {\n// nums[pos] = nums[(pos + 2) % 4] + nums[(pos + 3) % 4]\n// pos = (pos + 1) % 4\n// }\n// \"${nums[pos]} ${nums[(pos + 1) % 4]} ${nums[(pos + 3) % 4]}\"\n// }\n// }\n// )\n//}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "76bcd761e986d0eea47a98e9fe7e7f8f", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\nprintln(\"0 0 ${readLine()!!}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ef0e8de1f1cc5fa1b9176c2187ab6fa7", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n=readline()!!.toInt()\n printIn(\"0 0 $n\")\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1f453217a6c2ea4c6056d69735df4b33", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n=readline()!!.toInt()\n println(\"0 0 $n\")\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "630214110fa46d64638dbb1e0e36a7f2", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n val n=readline()!!.toInt()\n printIn(\"0 0 $n\")\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "aac1a5ed85e6f07c46118c5cdf225072", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n print(\"0, 0 ${readLine()}\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b7c4c421d2e0b9b09f401b501482b420", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val info = readInts()\n val smaller = info.subList(0, 4).min()!!\n val top = min(smaller, info[5] + 1)\n print(max(0, top - info[4]))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "65794efb5fbefadd083946b0c3b2bf6a", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n operator fun List.component6(): E = this[5]\n\n val info = readInts()\n val smaller = info.subList(0, 4).min()!!\n val top = min(smaller, info[5])\n print(max(0, top - info[4]))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c6451035f4afdbb6c18a55a3ebbb84b0", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var b = readLine()!!.toLong()\n var ans = 1\n for (i in 2..100000) {\n if (b % i == 0L) {\n var count = 0\n while (b % i == 0L) {\n b /= i\n count ++\n }\n ans *= (count + 1)\n }\n }\n if (b != 1L) ans *= 2\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "acc1bc6a56ba67545a5f22a59a927b93", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\n// unable to solve it by myself. Solution on the editorial: https://codeforces.com/blog/entry/62688\nfun main() {\n fun readLong() = readLine()!!.toLong()\n\n fun Long.factors(): MutableSet {\n val output = mutableSetOf()\n val endLoop = sqrt(this.toDouble()).toLong()\n for (i in 1L..endLoop) {\n if (this % i == 0L) {\n output.add(i)\n output.add(this / i)\n }\n }\n return output\n }\n\n print(readLong().factors().size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "93c09828ce8b92ca3c98d3517836d113", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(){\n var b = readLine()!!.toLong()\n var ans = 0\n for(i : Long in 1..b){\n if(i * i > b) break\n if(b % i == 0L){\n ans += 1\n if(i * i != b) ans += 1\n }\n }\n print(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9ac105b99b84ba40db365b46e23a5625", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLong() = readLine()!!.toLong()\n\n fun Long.primeFactors(): MutableList {\n val output = mutableListOf()\n var dividend = this\n while (dividend != 1L) {\n for (divisor in 2..dividend)\n if (dividend % divisor == 0L) {\n output.add(divisor)\n dividend /= divisor\n break\n }\n }\n return output\n }\n\n val primeFactors = readLong().primeFactors()\n val sols = mutableListOf(1L)\n for (factor in primeFactors) {\n val last = sols.size\n for (pos in 0 until last) sols.add(sols[pos] * factor)\n }\n print(sols.toSet().size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "54acfe7be019ae5a06997d850215fa3d", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLong() = readLine()!!.toLong()\n\n fun Long.primeFactors(): MutableList {\n val output = mutableListOf()\n var dividend = this\n while (dividend != 1L) {\n for (divisor in 2..dividend)\n if (dividend % divisor == 0L) {\n output.add(divisor)\n dividend /= divisor\n break\n }\n }\n return output\n }\n\n val primeFactors = readLong().primeFactors()\n val sols = mutableSetOf(1L)\n for (factor in primeFactors) {\n val new = mutableSetOf()\n for (sol in sols) new.add(sol * factor)\n sols.addAll(new)\n }\n print(sols.toSet().size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "df0355c06221dfec2107d030e5eec034", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\n// unable to solve it by myself. Solution from the editorial: https://codeforces.com/blog/entry/62688\nfun main() {\n fun readLong() = readLine()!!.toLong()\n\n fun Long.numFactors(): Long {\n if (this == 1L) return 1L\n \n var output = 0L\n val endLoop = sqrt(this.toDouble()).toLong()\n for (i in 1L..endLoop) if (this % i == 0L) output += 2\n return output\n }\n\n print(readLong().numFactors())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "08f81058499eaac657fcf724bf81305e", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\n// unable to solve it by myself. Solution from the editorial: https://codeforces.com/blog/entry/62688\nfun main() {\n fun readLong() = readLine()!!.toLong()\n\n fun Long.numFactors(): Long {\n var output = 0L\n val endLoop = sqrt(this.toDouble()).toLong()\n for (i in 1L..endLoop) if (this % i == 0L) output += 2\n return output\n }\n\n print(readLong().numFactors())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "57593e1bb68f48b5108d9745a219376c", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var b = readLine()!!.toLong()\n var ans = 1\n for (i in 2..100000) {\n if (b % i == 0L) {\n var count = 0\n while (b % i == 0L) {\n b /= i\n count ++\n }\n ans *= (count + 1)\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3a9164c60614faac1e16f60d9e66cdff", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun Int.primeFactors(): MutableMap {\n val output = mutableMapOf().withDefault { 0 }\n var dividend = this\n while (dividend != 1) {\n for (divisor in 2..dividend)\n if (dividend % divisor == 0) {\n output[divisor] = output.getValue(divisor) + 1\n dividend /= divisor\n break\n }\n }\n return output\n }\n\n val (n, k) = readInts()\n var sol = 1L\n val primeFactors = n.primeFactors()\n if (2 in primeFactors) primeFactors[2] = max(0, primeFactors.getValue(2) - k)\n if (5 in primeFactors) primeFactors[5] = max(0, primeFactors.getValue(5) - k)\n for ((key, value) in primeFactors) for (i in 1..value) sol *= key\n val sb = StringBuilder(sol.toString())\n for (i in 1..k) sb.append('0')\n print(sb)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bfd52c8d63316b15fcaa34fd502cb696", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun pow(a: Int, b: Int) = Math.pow(a.toDouble(), b.toDouble()).toLong()\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n var i = 1\n while (true) {\n val p: Long = i*pow(10, k)\n if (p % n == 0.toLong()) {\n println(p)\n break\n }\n i++\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "013d8214d4474d84ec77c89a56aabcc6", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "// star because\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (n, k) = readInts()\n var nn = n\n var twos = 0\n var fives = 0\n while(twos < k && nn % 2 == 0) {\n twos++\n nn /= 2\n }\n while(fives < k && nn % 5 == 0) {\n fives++\n nn /= 5\n }\n var sol = n.toLong()\n while (twos < fives) {\n sol *= 2\n twos++\n }\n while (fives < twos) {\n sol *= 5\n fives++\n }\n val sb = StringBuilder(sol.toString())\n for (i in twos until k) sb.append('0')\n print(sb)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8c66f02598ed81368304376bae57f323", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.*\nimport kotlin.math.*\n\nval read = Scanner(System.`in`)\n\nfun gcd(a: Long, b: Long): Long{\n return if (a == 0L) b else gcd(b%a, a)\n}\n\nfun main(){\n var n: Long = read.nextLong()\n var k: Long = read.nextLong()\n k = Math.pow(10.0, k.toDouble()).toLong()\n print(n * k / gcd(n, k))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3f8f13c0ad98708e248c1739977e5f88", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextLong()\n val k = sc.nextInt()\n\n println(n.round(k))\n}\n\nfun Long.round(k: Int): Long {\n var t = this\n var doub = 0\n while (t % 2 == 0L) {\n doub += 1\n t /= 2\n }\n var five = 0\n while (t % 5 == 0L) {\n five += 1\n t /= 5\n }\n\n var res = this\n while (doub < k) {\n res *= 2\n doub += 1\n }\n while (five < k) {\n res *= 5\n five += 1\n }\n return res\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ff46f95897e7e635a3058c7c18b9f3f7", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n var (n, k) = readInts()\n var twos = k\n var fives = k\n while(twos > 0 && n % 2 == 0) {\n twos--\n n /= 2\n }\n while(fives > 0 && n % 5 == 0) {\n fives--\n n /= 5\n }\n var sol = n\n while (twos > fives) {\n sol *= 2\n twos--\n }\n while (fives > twos) {\n sol *= 5\n fives--\n }\n val sb = StringBuilder(sol.toString())\n for (i in 1..twos) sb.append('0')\n print(sb)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a1bbf532024556b61adcb07eea4dd78f", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (d, l, v1, v2) = readInts()\n print((l - d) / (v1 + v2).toDouble())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5de7ac4a27d51183489431ebd855d5a5", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSU(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSU(n: Int) {\n data class Hist(\n val u: Int,\n val v: Int,\n val szu: Int\n )\n\n private val hist = mutableListOf()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n \n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(Hist(ru, rv, sz[ru]))\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n with(hist.removeAt(hist.lastIndex)) {\n id[v] = v\n sz[u] = szu\n opp[v] = false\n }\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "802d224b92e7bf9c6e57be79e130bd9c", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSU(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSU(n: Int) {\n data class Hist(\n val u: Int,\n val v: Int,\n val idv: Int,\n val szu: Int,\n val oppv: Boolean\n )\n\n private val hist = mutableListOf()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n \n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(Hist(ru, rv, id[rv], sz[ru], opp[rv]))\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n with(hist.removeAt(hist.lastIndex)) {\n id[v] = idv\n sz[u] = szu\n opp[v] = oppv\n }\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "23c01e0d4a7d33fec4c2372b486bfd7b", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val last = IntArray(m)\n val dsu = BipartiteDSU(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) last[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm-1, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n last[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, -1, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < last[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass Rollback(val arr: IntArray) {\n val ihist = IntList()\n val vhist = IntList()\n val save = IntList()\n\n operator fun get(i: Int) = arr[i]\n operator fun set(i: Int, v: Int) {\n ihist.add(i)\n vhist.add(arr[i])\n arr[i] = v\n }\n\n fun persist() {\n save.add(ihist.size)\n }\n\n fun rollback() {\n val p = save.pop()\n while(ihist.size > p) {\n arr[ihist.pop()] = vhist.pop()\n }\n }\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSU(n: Int) {\n private val id = Rollback(IntArray(n) { it })\n private val sz = Rollback(IntArray(n) { 1 })\n private val opp = Rollback(IntArray(n) { -1 })\n\n fun relation(u: Int, v: Int): Byte {\n val ru = root(u)\n val rv = root(v)\n return when {\n ru == rv -> SYN\n opp[ru].let { it != -1 && root(it) == rv } -> OPP\n else -> NOR\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n val ru = root(u)\n val rv = root(v)\n val cr = relation(ru, rv)\n when {\n cr == r -> return true\n cr != NOR -> return false\n else -> {\n if(r == SYN) join(ru, rv)\n else {\n when {\n opp[ru] != -1 -> join(opp[ru], rv)\n opp[rv] != -1 -> join(opp[rv], ru)\n else -> {\n opp[ru] = rv\n opp[rv] = ru\n }\n }\n }\n return true\n }\n }\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n /** @return false if the two vertices are already joined, true if the join operation is successful */\n private fun join(u: Int, v: Int): Boolean {\n var ru = root(u)\n var rv = root(v)\n if(ru == rv) return false\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n id[rv] = ru\n sz[ru] += sz[rv]\n if(opp[ru] != -1 && opp[rv] != -1) join(opp[ru], opp[rv])\n if(opp[rv] != -1) opp[ru] = opp[rv]\n return true\n }\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() {\n id.persist()\n sz.persist()\n opp.persist()\n }\n\n fun rollback() {\n id.rollback()\n sz.rollback()\n opp.rollback()\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7cc7efe426191a54fed20d2361a09d3a", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSURollback(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSURollback(n: Int) {\n\n private val hist = IntList()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n\n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(rv)\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n val v = hist.pop()\n val u = id[v]\n\n id[v] = v\n sz[u] -= sz[v]\n opp[v] = false\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3ef9916e1ec4129ddd51a9fb236b1415", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSURollback(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSURollback(n: Int) {\n\n private val hist = IntList()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n private inline fun root(u: Int, parity: (Boolean) -> Unit): Int {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n parity(p)\n return ru\n }\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n val ru = root(u) { p = p xor it }\n val rv = root(v) { p = p xor it }\n\n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = root(u) { p = p xor it }\n var rv = root(v) { p = p xor it }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(ru)\n hist.add(rv)\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n val v = hist.pop()\n val u = hist.pop()\n\n id[v] = v\n sz[u] -= sz[v]\n opp[v] = false\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "43bc2979cf30b51133cf88c14dfa49e7", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSURollback(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSURollback(n: Int) {\n\n private val hist = IntList()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n \n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n var rv = v\n while(id[rv] != rv) {\n p = p xor opp[rv]\n rv = id[rv]\n }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(ru)\n hist.add(rv)\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n val v = hist.pop()\n val u = hist.pop()\n\n id[v] = v\n sz[u] -= sz[v]\n opp[v] = false\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1dafa4df66387f19869fa1a8570d1e0d", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val firstNo = IntArray(m)\n val dsu = BipartiteDSURollback(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i+1 until m) firstNo[j] = m\n l2 = i\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n firstNo[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < firstNo[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSURollback(n: Int) {\n\n private val hist = IntList()\n private val sav = IntList()\n\n private val id = IntArray(n) { it }\n private val sz = IntArray(n) { 1 }\n private val opp = BooleanArray(n)\n\n private inline fun root(u: Int, parity: (Boolean) -> Unit): Int {\n var p = false\n var ru = u\n while(id[ru] != ru) {\n p = p xor opp[ru]\n ru = id[ru]\n }\n parity(p)\n return ru\n }\n\n fun relation(u: Int, v: Int): Byte {\n var p = false\n val ru = root(u) { p = p xor it }\n val rv = root(v) { p = p xor it }\n\n return when {\n ru != rv -> NOR\n p -> OPP\n else -> SYN\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n var p = r == OPP\n var ru = root(u) { p = p xor it }\n var rv = root(v) { p = p xor it }\n\n if(ru == rv) return !p\n\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n\n hist.add(rv)\n\n id[rv] = ru\n sz[ru] += sz[rv]\n opp[rv] = p\n return true\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() { sav.add(hist.size) }\n\n fun rollback() {\n val s = sav.pop()\n\n while(hist.size > s) {\n val v = hist.pop()\n val u = id[v]\n\n id[v] = v\n sz[u] -= sz[v]\n opp[v] = false\n }\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6923a74b559138699f3b8d64dfc45279", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n val q = readInt()\n\n val U = IntArray(m)\n val V = IntArray(m) {\n U[it] = readInt()-1\n readInt()-1\n }\n\n val last = IntArray(m)\n val dsu = BipartiteDSU(n)\n\n var l2 = m-1\n dsu.persist()\n for(i in 0 until m) {\n if(!dsu.join(U[i], V[i], OPP)) {\n for(j in i until m) last[j] = m\n l2 = i-1\n break\n }\n }\n dsu.rollback()\n\n fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {\n if(l1 > l2) return\n val lm = (l1 + l2) / 2\n\n dsu.persist()\n\n for(i in l1 until lm) dsu.join(U[i], V[i], OPP)\n\n dsu.persist()\n\n var rm = r2\n val lim = max(lm-1, r1)\n while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--\n last[lm] = rm\n\n dsu.rollback()\n\n dsu.join(U[lm], V[lm], OPP)\n rec(lm+1, l2, rm, r2)\n\n dsu.rollback()\n\n for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)\n rec(l1, lm-1, r1, rm)\n }\n\n rec(0, l2, 0, m-1)\n\n repeat(q) {\n val l = readInt()-1\n val r = readInt()-1\n\n val ans = r < last[l]\n println(if(ans) \"YES\" else \"NO\")\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nclass Rollback(val arr: IntArray) {\n val ihist = IntList()\n val vhist = IntList()\n val save = IntList()\n\n operator fun get(i: Int) = arr[i]\n operator fun set(i: Int, v: Int) {\n ihist.add(i)\n vhist.add(arr[i])\n arr[i] = v\n }\n\n fun persist() {\n save.add(ihist.size)\n }\n\n fun rollback() {\n val p = save.pop()\n while(ihist.size > p) {\n arr[ihist.pop()] = vhist.pop()\n }\n }\n}\n\nconst val SYN: Byte = 1\nconst val OPP: Byte = 2\nconst val NOR: Byte = 3\n\nclass BipartiteDSU(n: Int) {\n private val id = Rollback(IntArray(n) { it })\n private val sz = Rollback(IntArray(n) { 1 })\n private val opp = Rollback(IntArray(n) { -1 })\n\n fun relation(u: Int, v: Int): Byte {\n val ru = root(u)\n val rv = root(v)\n return when {\n ru == rv -> SYN\n opp[ru].let { it != -1 && root(it) == rv } -> OPP\n else -> NOR\n }\n }\n\n fun join(u: Int, v: Int, r: Byte): Boolean {\n val cr = relation(u, v)\n when {\n cr == r -> return true\n cr != NOR -> return false\n else -> {\n if(r == SYN) join(u, v)\n else {\n val ru = root(u)\n val rv = root(v)\n when {\n opp[ru] != -1 -> join(opp[ru], rv)\n opp[rv] != -1 -> join(opp[rv], ru)\n else -> {\n opp[ru] = rv\n opp[rv] = ru\n }\n }\n }\n return true\n }\n }\n }\n\n tailrec fun root(v: Int): Int =\n if(id[v] == v) v else root(id[v])\n\n /** @return false if the two vertices are already joined, true if the join operation is successful */\n private fun join(u: Int, v: Int): Boolean {\n var ru = root(u)\n var rv = root(v)\n if(ru == rv) return false\n if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }\n id[rv] = ru\n sz[ru] += sz[rv]\n if(opp[ru] != -1 && opp[rv] != -1) join(opp[ru], opp[rv])\n if(opp[rv] != -1) opp[ru] = opp[rv]\n return true\n }\n\n fun size(v: Int) = sz[root(v)]\n\n fun persist() {\n id.persist()\n sz.persist()\n opp.persist()\n }\n\n fun rollback() {\n id.rollback()\n sz.rollback()\n opp.rollback()\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.sort() { shuffle(random); _sort() }\nfun IntArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun LongArray.sort() { shuffle(random); _sort() }\nfun LongArray.sortDescending() { shuffle(random); _sortDescending() }\n\nfun DoubleArray.sort() { shuffle(random); _sort() }\nfun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6bb805012937aa6f7988f3f8bd9e5937", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\n\ndata class Pair ( val a: Int, val b: Int ) {\n fun inter( p: Pair ): ArrayList {\n val r = ArrayList()\n if ( a == p.a || a == p.b ) {\n r.add( a )\n }\n if ( b == p.a || b == p.b ) {\n r.add( b )\n }\n return r\n }\n\n constructor( sc: Scanner ) : this( sc.nextInt(), sc.nextInt() )\n}\n\nfun main( args: Array ) {\n val sc = Scanner( System.`in` )\n val m = sc.nextInt()\n val n = sc.nextInt()\n val p = Array( m, { Pair( sc ) } )\n val q = Array( n, { Pair( sc ) } )\n run {\n val oneInter = HashSet()\n for ( pp in p ) {\n for ( qq in q ) {\n val inter = pp.inter( qq )\n if ( inter.size == 1 ) oneInter.add( inter.first() )\n }\n }\n if ( oneInter.size == 1 ) {\n println( oneInter.first() )\n return\n }\n }\n var ok = true\n for ( pp in p ) {\n val oneInter = HashSet()\n for ( qq in q ) {\n val inter = pp.inter( qq )\n if ( inter.size == 1 ) oneInter.add( inter.first() )\n }\n if ( oneInter.size > 1 ) {\n println( -1 )\n return\n }\n }\n for ( qq in q ) {\n val oneInter = HashSet()\n for ( pp in p ) {\n val inter = pp.inter( qq )\n if ( inter.size == 1 ) oneInter.add( inter.first() )\n }\n if ( oneInter.size > 1 ) {\n println( -1 )\n return\n }\n }\n println( 0 )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4959d7eaed7a5e56c3e44a5b602a8239", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n\n val A = readIntArray(n+n)\n val B = readIntArray(m+m)\n\n val M = Array(n) { i ->\n IntArray(m) { j ->\n val a0 = A[i+i]\n val a1 = A[i+i+1]\n val b0 = B[j+j]\n val b1 = B[j+j+1]\n\n var cn = 0\n var res = -1\n\n if(a0 == b0) { cn++; res = a0 }\n if(a0 == b1) { cn++; res = a0 }\n if(a1 == b0) { cn++; res = a1 }\n if(a1 == b1) { cn++; res = a1 }\n\n if(cn > 1) -1 else res\n }\n }\n\n val ans = run ans@ {\n var ans = -1\n for (i in 0 until n) {\n var t = -1\n for (e in M[i]) if(e != -1) {\n when {\n t == -1 -> t = e\n t != e ->\n return@ans -1\n }\n }\n if(t == -1) continue\n when {\n ans == -1 -> ans = t\n ans != t -> ans = 0\n }\n }\n\n for (j in 0 until m) {\n var t = -1\n for (i in 0 until n) {\n val e = M[i][j]\n if(e != -1) when {\n t == -1 -> t = e\n t != e ->\n return@ans -1\n }\n }\n if(t == -1) continue\n when {\n ans == -1 -> ans = t\n ans != t -> ans = 0\n }\n }\n\n ans\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e867aa216a44880295c1f441c9bcb30e", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, m) = readLine()!!.splitToIntArray()\n val a = readLine()!!.processPairs()\n val b = readLine()!!.processPairs()\n val cand = HashSet()\n var unique = true\n for (i in 1..9) {\n for (ac in a[i]) {\n for (bc in b[i]) {\n if (ac != bc) {\n cand.add(i)\n if (!findsOne(i, ac, b) || !findsOne(i, bc, a)) {\n unique = false\n }\n }\n }\n }\n }\n if (cand.size == 1) {\n println(cand.single())\n return\n }\n if (unique) {\n println(0)\n } else {\n println(-1)\n }\n}\n\nfun findsOne(i: Int, j: Int, b: Array>): Boolean {\n val jc = b[j]\n return jc.isEmpty() || jc.size == 1 && jc.single() == i\n}\n\n\nfun String.processPairs(): Array> {\n val a = splitToIntArray()\n val r = Array>(10) { HashSet() }\n for (i in 0 until a.size step 2) {\n val u = a[i]\n val v = a[i + 1]\n r[u].add(v)\n r[v].add(u)\n }\n return r\n}\n\n\nprivate fun String.splitToIntArray(): IntArray {\n val n = length\n if (n == 0) return IntArray(0) // EMPTY\n var res = IntArray(4)\n var m = 0\n var i = 0\n while (true) {\n var cur = 0\n var neg = false\n var c = get(i) // expecting number, IOOB if there is no number\n if (c == '-') {\n neg = true\n i++\n c = get(i) // expecting number, IOOB if there is no number\n }\n while (true) {\n val d = c.toInt() - '0'.toInt()\n require(d >= 0 && d <= 9) { \"Unexpected character '$c' at $i\" }\n require(cur >= Integer.MIN_VALUE / 10) { \"Overflow at $i\" }\n cur = cur * 10 - d\n require(cur <= 0) { \"Overflow at $i\" }\n i++\n if (i >= n) break\n c = get(i)\n if (c == ' ') break\n }\n if (m >= res.size) res = res.copyOf(res.size * 2)\n res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { \"Overflow at $i\" } }\n if (i >= n) break\n i++\n }\n if (m < res.size) res = res.copyOf(m)\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "37894cd16b99cd40fae29c8794481e85", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.min\n\nfun main() {\n val count = readLine()!!.toInt()\n val dp = Array(count) { i -> LongArray(count - i) { Long.MAX_VALUE / 3 } }\n dp[0].fill(0)\n dp[1].fill(0)\n for (left in 0 until count - 2) {\n dp[2][left] = 1L * (left + 1) * (left + 2) * (left + 3)\n }\n\n for (length in 3 until count) {\n for (left in 0 until count - length) {\n val right = left + length\n val mult = 1L * (left + 1) * (right + 1)\n for (midPoint in left + 1 until right) {\n dp[length][left] = min(dp[length][left],\n dp[midPoint - left][left] + dp[right - midPoint][midPoint] + mult * (midPoint + 1))\n }\n }\n }\n println(dp[count - 1][0])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c9f8ee2761ab379fbe618aa29958a83c", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\nimport kotlin.math.max\nimport kotlin.math.sqrt\n\nprivate fun cin_ch() = readLine()!!.split(\" \").map{it.toInt()}\nprivate fun cin_array() = readLine()!!.split(\" \").map(String::toInt)\nprivate fun cin_string() = readLine()!!.split(\" \")\n\nfun main() {\nvar n = cin_ch()[0];\nvar ans = 0;\nfor (i in 3..n) {\nans+=i*(i-1);\n}\nprintln(ans);\nreturn;\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "abd24473ef9c3dfce4a1599c62f9f95a", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.min\nimport kotlin.system.exitProcess\n\nfun readInts() = readLine()!!.split(' ').map(String::toInt)\n\nfun main(args: Array) {\n var n = readLine()!!.toInt()\n var sum = 0\n for(i in 2..(n - 1)){\n sum += i * (i + 1)\n }\n print(sum)\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "302650bf73ca92a2e7b6c401d25154e7", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\ntypealias Pii = Pair\ntypealias Pll = Pair\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n var n = nextInt();\n var ans:Long = 0;\n for (i in 3..n) {\n ans += (i - 1) * i;\n }\n println(\"$ans\");\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f4cf1a90b921ca44f28be0aefeddadb", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "//package com.happypeople.codeforces.c1140\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n D1140().run()\n } catch (e: Throwable) {\n println(\"\")\n e.printStackTrace()\n }\n}\n\nclass D1140 {\n fun run() {\n val sc = Scanner(systemIn())\n val n=sc.nextInt()\n var ans=0L\n for(i in 3..n)\n ans+=(i*(i-1))\n\n println(\"$ans\")\n }\n\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "893cbca68125221c34ebc980b353fd94", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.pow\n\nfun main() {\n val nText = readLine()!!\n var n = nText.toInt()\n var length = nText.length\n var sol = 0L\n while (length > 0) {\n val subtract = 10.0.pow((length - 1).toDouble()).toLong() - 1\n sol += length * (n - subtract)\n n = subtract.toInt()\n length--\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d32360ed1c799c0312bef85ddd46e4a6", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextLong()\n if (n < 10)\n println(n)\n else {\n var sum = 0L\n var i = 0\n while (n.toString().length > 1) {\n val diff = 9 * Math.pow(10.0, i.toDouble()).toLong()\n if (diff > n)\n break\n n -= diff\n sum += diff * (i+1)\n i++\n }\n sum += n * (i+1)\n println(sum)\n }\n\n /*\n * 999\n * 9*1 + 90*2 + 900*3\n *\n * 850\n * 9*1 + 90*2 + 751*3\n *\n * */\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "830759cadf9798e24f83e201b05cd091", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)){\n val n = nextLong()\n\n val dig = n\n\n var sum = 0L\n\n var i = 0\n while(true){\n val pTen = pow(10, i)\n val div = (dig / pTen) \n var diff: Long = 0\n if(div >= 10L) {\n diff = (pow(10, i + 1) - pTen) * (i + 1)\n } else {\n diff = (dig - pTen + 1) * (i + 1)\n }\n sum += diff\n //println(\"i: $i, div: $div, diff: $diff, sum: $sum, pTen: $pTen\")\n i++\n if(div < 10L){\n break\n }\n }\n println(sum)\n}\n\nfun pow(dig: Long, pow: Int):Long {\n if(pow == 0) {\n return 1L\n }\n return dig * pow(dig, pow - 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b4e81ca22cdd9ff1df11f4481f5ecdc6", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.pow\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n var n = r.readLine()!!.toInt()\n var ans = 0L\n var now = 1L\n var digit = 1\n while (now * 10 <= n) {\n ans += (10.0.pow(digit)-10.0.pow(digit-1)).toLong()*digit\n digit++\n now*=10\n }\n ans += (n-now+1)*digit\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "75b55a4f072d099298440cdb8903f1b3", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*;\n\nfun main() {\n\tfun len(x: Int): Long {\n\t\treturn x.toString().length.toLong()\n\t}\n\tfun get(x: Int): Long {\n\t\treturn (9*Math.pow(10.0, (x-1).toDouble())).toLong() \n\t}\n\tvar n = readLine()!!.toInt()\n\tvar totalLen = len(n)\n\tvar x = 0L\n\tvar ans = 0L\n\tfor(i in 1..totalLen-1) {\n\t\tvar curr = get(i.toInt())\n\t\tx += curr\n\t\tans += curr*i\n\t}\n\tans += (n-x)*totalLen\n\tprintln(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b97d21b84323615c1b48da4a0e98ecfc", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextLong()\n if (n < 10)\n println(n)\n else {\n var sum = 0L\n var i = 0\n while (n.toString().length > 1) {\n val diff = 9 * Math.pow(10.0, i.toDouble()).toLong()\n n -= diff\n sum += diff * (i+1)\n i++\n }\n sum += n * (i+1)\n println(sum)\n }\n\n /*\n * 999\n * 9*1 + 90*2 + 900*3\n *\n * 850\n * 9*1 + 90*2 + 751*3\n *\n * */\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6cedec5df582b323b487c165303f6c5b", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextInt()\n if (n < 10)\n println(n)\n else {\n var sum = 0\n var i = 1\n while (n.toString().length > 1) {\n val length = n.toString().length\n val diff = 9 * Math.pow(10.0, length - 2.0).toInt()\n n -= diff\n sum += diff * (length - 1)\n i++\n }\n sum += n * i\n println(sum)\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "87beb8d017d0eaf3fa23f2cc17c51532", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextLong()\n if (n < 10)\n println(n)\n else {\n var sum = 0L\n var i = 1\n while (n.toString().length > 1) {\n val length = n.toString().length\n val diff = 9 * Math.pow(10.0, length - 2.0).toLong()\n n -= diff\n sum += diff * (length - 1)\n i++\n }\n sum += n * i\n println(sum)\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6db395cadcd5a0c5d0a0669a0176907f", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)){\n val n = nextLong()\n\n val dig = n\n\n var sum = 0L\n\n var i = 0\n while(true){\n val pTen = pow(10, i)\n val div = (dig / pTen) \n var diff: Long = 0\n if(div > 10L) {\n diff = (pow(10, i + 1) - pTen) * (i + 1)\n } else {\n diff = (dig - pTen + 1) * (i + 1)\n }\n sum += diff\n //println(\"i: $i, div: $div, diff: $diff, sum: $sum, pTen: $pTen\")\n i++\n if(div <= 10L){\n break\n }\n }\n println(sum)\n}\n\nfun pow(dig: Long, pow: Int):Long {\n if(pow == 0) {\n return 1L\n }\n return dig * pow(dig, pow - 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "abae1db4420f93fc8ac1e14e27b3cf87", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "\nfun main(args : Array) {\n val t = readLine()!!\n val (a, b ) = readLine()!!.split(' ')\n val card = arrayOf('6','7','8','9','T','J','Q','K','A')\n\n\n if(t==a[1].toString()){\n\n if(t!=b[1].toString()){\n println(\"YES\")\n }\n else{\n var a1 = 0\n var b1 = 0\n\n for(i in 0..card.size-1) {\n if (a[0]==card[i]) {\n a1 = i\n }\n }\n for(j in 0..card.size-1) {\n if(b[0]==card[j]){\n b1 = j\n }\n }\n\n if(a1>b1){\n println(\"YES\")\n }\n else{\n println(\"NO\")\n }\n }\n\n }\n else if(a[1]!=b[1] && t!=a[1].toString()){\n println(\"NO\")\n }\n else if(a[1]==b[1] ){\n var a1 = 0\n var b1 = 0\n\n for(i in 0..card.size-1){\n if(card[i]==a[0]){\n a1 = i\n }\n if(card[i]==b[0]){\n b1 = i\n }\n }\n\n if(a1>b1){\n println(\"YES\")\n }\n else{\n println(\"NO\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c99a214c03fc6f6ee86bc3f4e8b01743", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val cardToValue =\n mapOf('6' to 6, '7' to 7, '8' to 8, '9' to 9, 'T' to 10, 'J' to 11, 'Q' to 12, 'K' to 13, 'A' to 14)\n val trump = readLine()!![0]\n val (first, second) = readLine()!!.split(\" \")\n if (first[1] == second[1] && cardToValue[first[0]]!! > cardToValue[second[0]]!!) return print(\"YES\")\n if (first[1] == trump && second[1] != trump) return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1cc50b99518ab6d96c6ccf27a5ce089d", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : InputReader, pw : PrintWriter) {\n\n val n : Int = ir.nextInt()\n val m : Int = ir.nextInt()\n val min : Int = ir.nextInt()\n val max : Int = ir.nextInt()\n val t = IntArray(m)\n var count = 0\n var myMin = 101\n var myMax = 0\n\n for (i in 0 until m)\n t[i] = ir.nextInt()\n\n for (i in 0 until m) {\n if (t[i] < myMin)\n myMin = t[i]\n\n if (t[i] > myMax)\n myMax = t[i]\n }\n\n if (myMax > max || myMin < min)\n pw.print(\"Incorrect\")\n else {\n if (myMax < max)\n count++\n if (myMin > min)\n count++\n\n if (n - m >= count)\n pw.print(\"Correct\")\n else\n pw.print(\"Incorrect\")\n }\n\n}\n\nclass InputReader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1841fec84a1ab9c222e61c7b42ede044", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.math.*\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\nfun main(args : Array) {\n val input = Scanner(System.`in`)\n\n val n = input.nextInt()\n val m = input.nextInt()\n\n val min = input.nextInt()\n val max = input.nextInt()\n\n val a = mutableListOf()\n\n for (i in 0 until m)\n {\n a.add(input.nextInt())\n }\n\n if ((n - m == 1 && a.min()!! != min && a.max()!! != max) || (a.min()!! < min || a.max()!! > max))\n {\n println(\"Incorrect\")\n }\n else\n {\n println(\"Correct\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d370541a81edfa1dfffc466ea96ab76f", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "const val MOD = 1000000007L\nconst val LIMIT = 500000\n\nfun main() {\n val factorial = LongArray(LIMIT + 1)\n factorial[0] = 1L\n for (j in 1..LIMIT) {\n factorial[j] = (j.toLong() * factorial[j - 1]) % MOD\n }\n val factInv = LongArray(LIMIT + 1) { factorial[it] pow -1 }\n fun choose(a: Int, b: Int) = if (a < 0 || b < 0 || b > a) 0L else (factorial[a] * ((factInv[b] * factInv[a - b]) % MOD)) % MOD\n val (a, b, k, t) = readLine()!!.split(\" \").map { it.toInt() }\n var answer = 0L\n for (lambda in 0..2 * t) {\n answer += (if (lambda % 2 == 0) 1L else -1L) * choose(2 * t, lambda) * (\n choose((4 * t * k) - (((2 * k) + 1) * lambda) + (2 * t), 2 * t) - choose((2 * t * k) + b - a - (((2 * k) + 1) * lambda) + (2 * t), 2 * t))\n answer %= MOD\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "62266f422efeafb937490280c051c23a", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "const val MOD = 1000000007L\n\nfun main() {\n val (a, b, k, t) = readLine()!!.split(\" \").map { it.toInt() }\n val n = (2 * t * k) + 100\n var dpPrev = LongArray((2 * n) + 1)\n var dpNext = LongArray((2 * n) + 1)\n dpPrev[a - b + n] = 1L\n for (turn in 1..2 * t) {\n dpNext[0] = 0L\n for (j in 0..k) {\n dpNext[0] += dpPrev[j]\n }\n dpNext[0] %= MOD\n for (j in 1..2 * n) {\n dpNext[j] = dpNext[j - 1]\n if (j + k <= 2 * n) {\n dpNext[j] += dpPrev[j + k]\n }\n if (j - k > 0) {\n dpNext[j] -= dpPrev[j - k - 1]\n }\n dpNext[j] %= MOD\n }\n val temp = dpPrev\n dpPrev = dpNext\n dpNext = temp\n }\n var answer = 0L\n for (j in n + 1..2 * n) {\n answer += dpPrev[j]\n answer %= MOD\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "225ee15cec5226ac77dff619cd9d84e5", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.Math.pow\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.log\nimport kotlin.math.log2\nimport kotlin.math.min\n\nfun main(args: Array)\n = Thread { run() }.start()\n\nfun run() {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val arr = Array(m) { Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), it) }.sorted()\n val b = IntArray(n) { 0 }\n arr.forEach { b[it.b - 1] = m + 1 }\n for (i in 0 until m) {\n if (arr[i].b - arr[i].a < arr[i].c || arr[i].b < arr[i].c) {\n println( \"-|\")\n return\n }\n var k = 0\n for (j in arr[i].b - 2 downTo arr[i].a - 1) {\n if (b[j] == 0) {\n b[j] = arr[i].i + 1\n k++\n if (k == arr[i].c)\n break\n }\n }\n if (k != arr[i].c) {\n println(i)\n println(\"$k == ${arr[i].c}\")\n println(Arrays.toString(b))\n println(-1)\n return\n }\n }\n b.forEach { print(\"$it \") }\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\n//class Pair(val a: Int, val b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return a - other.a\n// }\n//}\n\nclass Triple(val a: Int, val b: Int, val c: Int, val i : Int): Comparable {\n override fun compareTo(other: Triple): Int {\n return b - a - other.b + other.a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "27dc75614c40f4387b0e498f58b18c92", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.Math.pow\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.log\nimport kotlin.math.log2\nimport kotlin.math.min\n\nfun main(args: Array)\n = Thread { run() }.start()\n\nfun run() {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val arr = Array(m) { Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), it) }.sorted()\n val b = IntArray(n) { 0 }\n arr.forEach { b[it.b - 1] = m + 1 }\n for (i in 0 until m) {\n if (arr[i].b - arr[i].a < arr[i].c || arr[i].b < arr[i].c) {\n println( \"-1\")\n return\n }\n var k = 0\n for (j in arr[i].b - 2 downTo arr[i].a - 1) {\n if (b[j] == 0) {\n b[j] = arr[i].i + 1\n k++\n if (k == arr[i].c)\n break\n }\n }\n if (k != arr[i].c) {\n println(-1)\n return\n }\n }\n b.forEach { print(\"$it \") }\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\n//class Pair(val a: Int, val b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return a - other.a\n// }\n//}\n\nclass Triple(val a: Int, val b: Int, val c: Int, val i : Int): Comparable {\n override fun compareTo(other: Triple): Int {\n return b - a - other.b + other.a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ca345634cce80d2cf15d2a704052b35d", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\nimport kotlin.collections.HashSet\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n //val output = BufferedWriter(OutputStreamWriter(System.`out`))\n\n //visualize()\n val n = scanner.nextLong()\n val k = scanner.nextLong()\n if(ok(n, k)) print(\"Yes\")\n else print(\"No\")\n\n}\n\nfun ok(n: Long, k: Long): Boolean{\n if(n <= k) return false\n val set = HashSet()\n for(i in 1..k){\n val r = n%i\n if(r in set) return false\n set.add(r)\n }\n return true\n}\n\n/*\nfun visualize(){\n\n val n = 40\n\n print(\" |\")\n for(i in 1..n) print(\" %2d\".format(i))\n println()\n for(i in 1..(3*n+4)) print(\"-\")\n println()\n\n for(i in 1..n){\n //if(!isPrime(i)) continue\n print(\"%2d |\".format(i))\n for(j in 1 .. n){\n if(i >= j)\n print(\" %2d\".format(i%j))\n }\n println()\n }\n println()\n}\n\nfun isPrime(x: Int): Boolean{\n var i = 2\n while(i*i <= x){\n if(x%i == 0) return false\n ++i\n }\n return true\n}\n*/", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3d689ea7168b9100c14294cb9f8da1df", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main() {\n val fs = CodeForces.FastReader()\n var n = fs.nextLong()\n var k = fs.nextLong()\n var set = HashSet()\n var bool = true\n for (i in 1..k) {\n var rest = n%i\n if(!set.contains(rest)) set.add(rest)\n else{\n bool = false\n break;\n }\n }\n if(bool) println(\"Yes\") else println(\"No\")\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n\n fun readLongArray(n: Int): LongArray {\n val a = LongArray(n)\n for (i in 0 until n) a[i] = nextLong()\n return a\n }\n\n fun readDoubleArray(n: Int): DoubleArray {\n val a = DoubleArray(n)\n for (i in 0 until n) a[i] = nextDouble()\n return a\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "72aab1b00e8b811bf524a3d550a6c018", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.util.*\nimport kotlin.collections.HashSet\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n //val output = BufferedWriter(OutputStreamWriter(System.`out`))\n\n //visualize()\n val n = scanner.nextLong()\n val k = scanner.nextLong()\n if(ok(n, k)) print(\"Yes\")\n else print(\"No\")\n\n}\n\nfun ok(n: Long, k: Long): Boolean{\n //if(n <= k) return false\n val set = HashSet()\n for(i in 1..k){\n val r = n%i\n if(r in set) return false\n set.add(r)\n }\n return true\n}\n\n/*\nfun visualize(){\n\n val n = 40\n\n print(\" |\")\n for(i in 1..n) print(\" %2d\".format(i))\n println()\n for(i in 1..(3*n+4)) print(\"-\")\n println()\n\n for(i in 1..n){\n //if(!isPrime(i)) continue\n print(\"%2d |\".format(i))\n for(j in 1 .. n){\n if(i >= j)\n print(\" %2d\".format(i%j))\n }\n println()\n }\n println()\n}\n\nfun isPrime(x: Int): Boolean{\n var i = 2\n while(i*i <= x){\n if(x%i == 0) return false\n ++i\n }\n return true\n}\n*/", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8fb7cd0966bf3f6d5f26f25b59b62279", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\n\n\nfun main(args: Array) {\n TaskC().solve()\n}\n\nabstract class Solver {\n internal val scanner = MyScanner()\n abstract fun solve()\n}\n\nclass TaskC : Solver() {\n override fun solve() {\n val mod = 998244353\n val n = scanner.nextInt()\n val m = scanner.nextLong()\n val k = scanner.nextInt()\n\n var cnk = Array(n + 1) { IntArray(n + 1) }\n\n cnk[0][0] = 1\n for (i in 1..n) {\n cnk[i][0] = 1\n cnk[i][i] = 1\n for (j in 1 until n) {\n cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % mod\n }\n }\n\n var ans = cnk[n - 1][k].toLong()\n ans = (ans *m) % mod\n for (i in 1..k){\n ans = (ans* (m-1))% mod\n }\n System.out.print(ans)\n\n\n }\n\n}\n\ninternal class MyScanner {\n private val `in` = BufferedReader(InputStreamReader(System.`in`))\n private var buffer: Array? = null\n private var pos = 0\n\n @Throws(IOException::class)\n fun nextInt(): Int {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return Integer.parseInt(buffer!![pos - 1])\n }\n\n @Throws(IOException::class)\n fun nextLong(): Long {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return (buffer!![pos - 1]).toLong()\n }\n\n @Throws(IOException::class)\n fun nextString(): String {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return buffer!![pos - 1]\n }\n\n @Throws(IOException::class)\n fun getIntList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextInt())\n return result\n }\n\n @Throws(IOException::class)\n fun getIntArray(n: Int): IntArray {\n val result = IntArray(n)\n for (i in 0 until n)\n result[i] = nextInt()\n return result\n }\n\n @Throws(IOException::class)\n fun getLongList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextLong())\n return result\n }\n\n @Throws(IOException::class)\n fun getLongArray(n: Int): LongArray {\n val result = LongArray(n)\n for (i in 0 until n)\n result[i] = nextLong()\n return result\n }\n\n @Throws(IOException::class)\n fun getStringList(n: Int): List {\n val result = mutableListOf()\n for (i in 0 until n)\n result.add(nextString())\n return result\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c7a0c801a7c63874baca77c1817dc0fd", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject Main {\n var `in`: IO? = null\n var out: PrintWriter? = null\n\n @Throws(Exception::class)\n fun init_io(filename: String) {\n if (filename == \"\") {\n `in` = IO(System.`in`)\n out = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)), true)\n } else {\n `in` = IO(FileInputStream(\"$filename.in\"))\n out = PrintWriter(BufferedWriter(FileWriter(\"$filename.out\")), true)\n }\n }\n\n const val mod: Long = 998244353\n\n /*\nfun main(args: Array) {\n Main.main(args);\n}\n*/\n @Throws(Exception::class)\n fun solve(tc: Int) {\n val n = `in`!!.nlong()\n val m = `in`!!.nlong()\n val k = `in`!!.nlong()\n var nck: Long = 1\n for (i in 1..n - 1) nck = nck * i % mod\n for (i in 1..n - 1 - k) nck = nck * minv(i) % mod\n for (i in 1..k) nck = nck * minv(i) % mod\n var x = m\n for (i in 0 until k) x = x * (m - 1) % mod\n out!!.println(x * nck % mod)\n }\n\n @Throws(Exception::class)\n @JvmStatic\n fun main(_u_n_u_s_e_d_: Array) {\n init_io(\"\")\n val t = 1\n // t = in.nint();\n for (tc in 0 until t) {\n solve(tc)\n }\n }\n\n fun minv(v: Long): Long {\n return mpow(v, mod - 2)\n }\n\n fun mpow(base: Long, exp: Long): Long {\n var base = base\n var exp = exp\n var res: Long = 1\n while (exp > 0) {\n if (exp and 1 == 1L) {\n res = res * base % mod\n }\n base = base * base % mod\n exp = exp shr 1\n }\n return res\n }\n\n fun gcd(x: Long, y: Long): Long {\n return if (x == 0L) y else gcd(y % x, x)\n }\n\n fun rsort(arr: LongArray) {\n val r = Random()\n for (i in arr.indices) {\n val j = i + r.nextInt(arr.size - i)\n val t = arr[i]\n arr[i] = arr[j]\n arr[j] = t\n }\n Arrays.sort(arr)\n }\n\n fun rsort(arr: IntArray) {\n val r = Random()\n for (i in arr.indices) {\n val j = i + r.nextInt(arr.size - i)\n val t = arr[i]\n arr[i] = arr[j]\n arr[j] = t\n }\n Arrays.sort(arr)\n }\n\n /* static void qsort(long[] arr) {\n Long[] oarr = new Long[arr.length];\n for (int i = 0; i < arr.length; i++) {\n oarr[i] = arr[i];\n }\n\n ArrayList alist = new ArrayList(Arrays.asList(oarr));\n Collections.sort(alist);\n\n for (int i = 0; i < arr.length; i++) {\n arr[i] = (long)alist.get(i);\n }\n } */\n fun reverse(arr: LongArray) {\n for (i in 0 until arr.size / 2) {\n val temp = arr[i]\n arr[i] = arr[arr.size - 1 - i]\n arr[arr.size - 1 - i] = temp\n }\n }\n\n fun atos(arr: LongArray?): String {\n var s = Arrays.toString(arr)\n s = s.substring(1, s.length - 1)\n return s.replace(\",\", \"\")\n }\n\n class IO(x: InputStream?) {\n var `in`: BufferedReader\n var tokens: StringTokenizer\n\n @Throws(Exception::class)\n fun nint(): Int {\n return nstr().toInt()\n }\n\n @Throws(Exception::class)\n fun nlong(): Long {\n return nstr().toLong()\n }\n\n @Throws(Exception::class)\n fun ndouble(): Double {\n return nstr().toDouble()\n }\n\n @Throws(Exception::class)\n fun nstr(): String {\n if (!tokens.hasMoreTokens()) tokens = StringTokenizer(`in`.readLine())\n return tokens.nextToken()\n }\n\n @Throws(Exception::class)\n fun nla(n: Int): LongArray {\n val arr = LongArray(n)\n for (i in 0 until n) {\n arr[i] = nlong()\n }\n return arr\n }\n\n init {\n `in` = BufferedReader(InputStreamReader(x))\n tokens = StringTokenizer(`in`.readLine())\n }\n }\n\n internal class Pair?, B : Comparable?>(var f: A, var s: B) : Comparable> {\n override fun compareTo(other: Pair): Int {\n val v = f!!.compareTo(other.f)\n return if (v != 0) v else s!!.compareTo(other.s)\n }\n\n override fun toString(): String {\n return \"(\" + f.toString() + \", \" + s.toString() + \")\"\n }\n\n }\n}\n\nfun main(args: Array) {\n Main.main(args);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ef30ae02b9d84610e3bf4e56ee38fb71", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "const val inf = 998244353L\n\nfun main() {\n val (n, m, k) = readLine()!!.split(\" \").map(String::toInt)\n val f = Array(n) {\n Array(k + 1) {\n 0L\n }\n }\n f[0][0] = m.toLong()\n for (i in 0..(n - 2))\n for (j in 0..k) {\n if (j != k)\n f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j] * (m - 1)) % inf\n f[i + 1][j] = (f[i + 1][j] + f[i][j]) % inf\n }\n\n println(f[n - 1][k])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "44c33a982c90e03aba580e013883b45a", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\nimport java.util.*\n\nconst val M = 998244353L\nval MB = BigInteger.valueOf( M )\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val m = sc.nextLong()\n val k = sc.nextLong()\n if ( k == 0L ) {\n println( m )\n return\n }\n val C = Array( n.toInt(), { LongArray( it + 2 ) } )\n for ( i in C.indices ) {\n C[i][0] = 1\n for ( j in 1 .. i ) {\n C[i][j] = C[i - 1][j - 1] + C[i - 1][j]\n if ( C[i][j] >= M ) {\n C[i][j] -= M\n }\n }\n }\n println( BigInteger.valueOf( m - 1 ).modPow( BigInteger.valueOf( k - 1 ), MB ).multiply( BigInteger.valueOf( C[(n - 1).toInt()][k.toInt()] * m ) ).remainder( MB ) )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a2d1ee6363b3a5763be9e7cd2fceb083", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val m = readInt()\n\n var x = ModInt(2).pow(m).dec()\n var ans = ModInt(1)\n\n repeat(n) {\n ans *= x\n x--\n }\n\n println(ans.int)\n }\n}\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MOD = BILLION7+2\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int): ModIntArray {\n val res = ModIntArray(n+1)\n res[0] = ModInt(1)\n for(i in 1..n) res[i] = res[i-1] * this\n return res\n}\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _ln = \"\"\n@JvmField var _lnPtr = 0\nfun read(): String {\n while (_lnPtr >= _ln.length) {\n _ln = readLine() ?: return \"\"\n _lnPtr = 0\n }\n var j = _ln.indexOf(' ', _lnPtr)\n if(j < 0) j = _ln.length\n val res = _ln.substring(_lnPtr, j)\n _lnPtr = j + 1\n return res\n}\nfun readRem(): String /* reads remainder of current line */ =\n _ln.substring(min(_lnPtr, _ln.length)).also { _lnPtr = _ln.length }\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4484ca78f08faae31789f89d348297ab", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "/**\n * @author Daniyar Itegulov\n */\nfun main(arg: Array) {\n val sc = java.util.Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val s = sc.next().map { c -> if (c == 'N') 0 else if (c == 'Y') 1 else 2 }\n for (i in 0..(n - k)) {\n val newS = mutableListOf()\n newS.addAll(s)\n var good = true\n for (j in i..(i + k - 1)) {\n if (newS[j] == 1) {\n good = false\n break\n } else if (newS[j] == 2) {\n newS[j] = 0\n }\n }\n if (good) {\n for (j in 0..(n - 1)) {\n if (newS[j] == 2) {\n newS[j] = 1\n }\n }\n for (j in 0..(n - 1 - k)) {\n var kek = true\n for (l in j..(j + k)) {\n if (newS[l] != 0) {\n kek = false\n }\n }\n if (kek) {\n good = false\n }\n }\n if (good) {\n println(\"YES\")\n System.exit(0)\n }\n }\n }\n println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1168e7e2c92401267e09df6e0a948fe3", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(){\n\n var a = nl()\n var b = nl()\n\n if(b -min umod q }\n .allMinBy { k -> lcm(a + k, b + k) }.min() ?: 0\n\n println(ans)\n }\n}\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\n\ntailrec fun gcd(a: Int, b: Int): Int = if(a == 0) abs(b) else gcd(b % a, a)\nfun lcm(a: Int, b: Int): Long = a / gcd(a, b) * b.toLong()\n\nfun Int.divisors() = sequence {\n val n = this@divisors\n if(n <= 0) return@sequence\n val tail = mutableListOf()\n\n for(p in 1..Int.MAX_VALUE) {\n val sq = p * p\n if(sq > n) break\n if(n % p == 0) {\n yield(p)\n if(sq != n) tail.add(n / p)\n }\n }\n\n yieldAll(tail.asReversed())\n}\n\ninline fun > Sequence.allMinBy(selector: (T) -> R): List {\n val result = mutableListOf()\n var min: R? = null\n\n for(it in this) {\n val r = selector(it)\n if(min == null || r < min) {\n min = r\n result.clear()\n result.add(it)\n } else if(r.compareTo(min) == 0) { result.add(it) }\n }\n\n return result\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd689b247a76eb143f5636b37224f67e", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() {\n output {\n val a = readInt()\n val b = readInt()\n\n val min = min(a, b)\n\n val ans = abs(a - b).divisors()\n .map { q -> -min umod q }\n .allMinBy { k -> lcm(a + k, b + k) }.minBy { it } ?: 0\n\n println(ans)\n }\n}\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\n\ntailrec fun gcd(a: Int, b: Int): Int = if(a == 0) abs(b) else gcd(b % a, a)\nfun lcm(a: Int, b: Int): Long = a / gcd(a, b) * b.toLong()\n\nfun Int.divisors() = sequence {\n val n = this@divisors\n if(n <= 0) return@sequence\n val tail = mutableListOf()\n\n for(p in 1..Int.MAX_VALUE) {\n val sq = p * p\n if(sq > n) break\n if(n % p == 0) {\n yield(p)\n if(sq != n) tail.add(n / p)\n }\n }\n\n yieldAll(tail.asReversed())\n}\n\ninline fun > Sequence.allMinBy(selector: (T) -> R): List {\n val result = mutableListOf()\n var min: R? = null\n\n for(it in this) {\n val r = selector(it)\n if(min == null || r < min) {\n min = r\n result.clear()\n result.add(it)\n } else if(r.compareTo(min) == 0) { result.add(it) }\n }\n\n return result\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7f600c2b4bb402747014539a6fdb2be6", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(){\n\n var a = nl()\n var b = nl()\n\n if(b= minr) return@run mink\n }\n error(\"Should've TLE by now\")\n }\n\n println(ans)\n}\n\ntailrec fun Long.gcd(other: Long): Long = if(other == 0L) this else other.gcd(rem(other))\nfun Long.lcm(other: Long) = times(other) / gcd(other)\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "27304ed6d934d7caf8b289ad7e60b5d7", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(){\n var a = nl()\n var b = nl()\n var diff = b - a\n var times = Math.ceil(a.toDouble() / diff.toDouble()).toLong()\n var A = diff*times\n var expected = A-a\n var best = lcm(a+expected, b+expected)\n var k = expected\n for(i in 0 until Math.min(expected, 1_000_000)){\n var l = lcm(a+i, b+i)\n if(best > l){\n best = l\n k = i\n }\n }\n println(k)\n}\n\nfun gcd(a: Long, b: Long): Long {\n return if (b == 0L) Math.abs(a) else gcd(b, a % b)\n}\n\nfun lcm(a: Long, b: Long): Long {\n return Math.abs(a / gcd(a, b) * b)\n}\n\nvar input = Scanner(System.`in`)\n\nfun ni() = input.nextInt()\n\nfun nia(n: Int) = Array(n) { ni() }\n\nfun nim(n: Int, m: Int) = Array(n) { nia(m) }\n\nfun nl() = input.nextLong()\n\nfun nla(n: Int) = Array(n) { nl() }\n\nfun nlm(n: Int, m: Int) = Array(n) { nla(m) }\n\nfun ns() = input.next()\n\nfun nsa(n: Int) = Array(n) { ns() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "748ed8f79b568ccdfbd5a83ea7e25dfe", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun main() {\n val line = readLine()!!.split(' ')\n val N = line[0].toInt()\n var M = line[1].toLong() - 1\n val ans = LinkedList()\n ans.add(N)\n for (i in N - 1 downTo 1) {\n if (M % 2 > 0) {\n ans.addLast(i)\n } else {\n ans.addFirst(i)\n }\n M /= 2\n }\n println(ans.joinToString(\" \"))\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprivate val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n} catch (t: Throwable) {\n false\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }.toIntArray()\nprivate fun readLongs() = readStrings().map { it.toLong() }.toLongArray()\nprivate inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n}\nprivate fun debug(a: LongArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: IntArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: BooleanArray) {\n debug{a.map{if(it) 1 else 0}.joinToString(\"\")}\n}\nprivate fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f8995066e1a10656425da5240da49d4d", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "/*\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map{ it.toLong()}\nfun getWord() = readLine()!!\nfun getWords() = readLine()!!.split(\" \")\n\n */\n\nfun main()\n{\n var nb_moves = getInt()\n var ball_at = getInt()\n var answer = -1\n nb_moves %= 6\n var balls = intArrayOf(0,0,0)\n balls[ball_at] = 1\n for (i in nb_moves downTo 1)\n {\n if ( i % 2 == 0)\n {\n val curr = balls[2]\n balls[2] = balls[1]\n balls[1] = curr\n }\n else\n {\n val curr = balls[1]\n balls[1] = balls[0]\n balls[0] = curr\n }\n }\n answer = balls.indexOf(1)\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "deb742f479bfee05a2baf92b9d338166", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "nb_moves = int(input())\nball_at = int(input())\n\nball = [0, 0, 0]\nnb_moves %= 6\nball[ball_at] = 1\nfor i in range(nb_moves, 0, -1):\n if i % 2 == 0:\n ball[2], ball[1] = ball[1], ball[2]\n else:\n ball[1], ball[0] = ball[0], ball[1]\nprint(ball.index(1))\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a5fe9bfddb08a3f8a6e321a170c759c9", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val numMovements = readInt() % 6\n val positions = listOf(\"012210\", \"100122\", \"221001\")\n val x = readLine()!![0]\n for (position in 0..2) if (positions[position][numMovements] == x) print(position)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b943ad05b31427c95e236d7a2c9c036d", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "//package codeforces.round401.a\n\nimport java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastScanner(inputStream)\n val out = PrintWriter(outputStream)\n solve(`in`, out)\n out.close()\n}\n\nprivate fun solve(scanner : FastScanner, out: PrintWriter) {\n val n = scanner.nextLong()\n val x = scanner.nextInt()\n\n val expected = when(x) {\n 0 -> Triple(1, 0, 0)\n 1 -> Triple(0, 1, 0)\n 2 -> Triple(0, 0, 1)\n else -> throw IllegalArgumentException()\n }\n listOf(Triple(1, 0, 0), Triple(0, 1, 0), Triple(0, 0, 1)).forEach {\n val res = simulate(it, n)\n if (res == expected) {\n val pos = it.toList().indexOf(1)\n out.print(pos)\n return\n }\n }\n}\n\nprivate fun simulate(initial: Triple, n: Long): Triple {\n var state = initial\n for (i in 1..n % 6L) {\n if (i % 2 == 1L) {\n val temp = state.first\n state = state.copy(first = state.second, second = temp)\n } else {\n val temp = state.third\n state = state.copy(third = state.second, second = temp)\n }\n }\n return state\n}\n\n\nprivate class FastScanner(`in`: InputStream) {\n private var reader: BufferedReader? = null\n private var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(`in`))\n tokenizer = null\n }\n\n operator fun next(): String {\n if (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader!!.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n if (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n return reader!!.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n\n return tokenizer!!.nextToken(\"\\n\")\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ccd310ac308b246e3ed897c190b021d5", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "/**\n * Created by enitihas on 20/6/17.\n */\nimport java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\n/**\n * Created by enitihas on 20/6/17.\n */\nfun main(args: Array) {\n val sc = Scanner(BufferedReader(InputStreamReader(System.`in`)))\n val pw = PrintWriter(System.out)\n solve(sc,pw)\n sc.close()\n pw.close()\n}\n\nfun solve(sc: Scanner, pw: PrintWriter) {\n val n = sc.nextInt()\n val x = sc.nextInt()\n var ans = -1\n val moves = n%6\n val balls = intArrayOf(0,0,0)\n balls[x] = 1\n for (i in moves downTo 1) {\n if(i%2==0) {\n val temp = balls[2]\n balls[2] = balls[1]\n balls[1] = temp\n }\n else {\n val temp = balls[1]\n balls[1] = balls[0]\n balls[0] = temp\n }\n }\n ans = balls.indexOf(1)\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "313e4e251747ae3c473e010c822778f8", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map{ it.toLong()}\nfun getWord() = readLine()!!\nfun getWords() = readLine()!!.split(\" \")\n\n\n\nfun main()\n{\n var nb_moves = getInt()\n var ball_at = getInt()\n var answer = -1\n nb_moves %= 6\n var balls = intArrayOf(0,0,0)\n balls[ball_at] = 1\n for (i in nb_moves downTo 1)\n {\n if ( i % 2 == 0)\n {\n val curr = balls[2]\n balls[2] = balls[1]\n balls[1] = curr\n }\n else\n {\n val curr = balls[1]\n balls[1] = balls[0]\n balls[0] = curr\n }\n }\n answer = balls.indexOf(1)\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0fa64a7581b63e7c3c0e4c190697d739", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(){\n var n = readLine()!!.toInt()\n var x = readLine()!!.toInt()\n\n var possibleCases = ArrayList()\n possibleCases.add(\"012\")\n possibleCases.add(\"102\")\n possibleCases.add(\"120\")\n possibleCases.add(\"210\")\n possibleCases.add(\"201\")\n possibleCases.add(\"021\")\n\n println(possibleCases[n%6][x])\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7ccceffaf4b45e4accd2e91097a4f4b5", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "//package codeforces.round401.a\n\nimport java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = FastScanner(inputStream)\n val out = PrintWriter(outputStream)\n solve(`in`, out)\n out.close()\n}\n\nprivate fun solve(scanner : FastScanner, out: PrintWriter) {\n val n = scanner.nextLong()\n val x = scanner.nextInt()\n\n val expected = when(x) {\n 0 -> Triple(1, 0, 0)\n 1 -> Triple(0, 1, 0)\n 2 -> Triple(0, 0, 1)\n else -> throw IllegalArgumentException()\n }\n listOf(Triple(1, 0, 0), Triple(0, 1, 0), Triple(0, 0, 1)).forEach {\n val res = simulate(it, n)\n if (res == expected) {\n val pos = it.toList().indexOf(1)\n out.print(pos)\n return\n }\n }\n}\n\nprivate fun simulate(initial: Triple, n: Long): Triple {\n var state = initial\n for (i in 1..n) {\n if (i % 2 == 1L) {\n val temp = state.first\n state = state.copy(first = state.second, second = temp)\n } else {\n val temp = state.third\n state = state.copy(third = state.second, second = temp)\n }\n }\n return state\n}\n\n\nprivate class FastScanner(`in`: InputStream) {\n private var reader: BufferedReader? = null\n private var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(`in`))\n tokenizer = null\n }\n\n operator fun next(): String {\n if (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader!!.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n if (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n return reader!!.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n\n return tokenizer!!.nextToken(\"\\n\")\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "942728dafa949fba16ef81ee14dbe692", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun nod(a: Long, b: Long): Long =\n if (a % b != 0L) {\n nod(b, a % b)\n } else {\n b\n }\n\nfun main(args: Array) {\n var (a, b, x, y) = readLine()!!.split(\" \").map(String::toLong)\n if (a < b) {\n a += b\n b = a - b\n a -= b\n }\n if(x < y) {\n x += y\n y = x - y\n x -= y\n }\n val nodValue = nod(x, y)\n if(nodValue != 1L) {\n x /= nodValue\n y /= nodValue\n }\n println(if (a/x > b/y) b/y else a/x)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "43245e07e3985654385ae384331755cd", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nimport java.io.*\nimport java.util.*\nimport kotlin.math.min\n\nfun solve() {\n\n val a = nextLong()\n val b = nextLong()\n\n var x = nextLong()\n var y = nextLong()\n\n val d = gcd(x, y)\n x /= d\n y /= d\n\n val countX = a / x\n val countY = b / y\n\n println(min(countX, countY))\n}\n\nfun gcd(a: Long, b: Long) : Long {\n return if (b == 0L) a else gcd(b, a % b)\n}\n\n\nfun hasNext() : Boolean {\n while (!st.hasMoreTokens()) {\n st = StringTokenizer(input.readLine() ?: return false)\n }\n return true\n}\n\nfun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun nextDouble() = next().toDouble()\n\nfun nextLine() = if (hasNext()) st.nextToken(\"\\n\")!! else throw RuntimeException(\"No tokens\")\n\nfun nextArray(n : Int) = IntArray(n, { nextInt() })\n\nval ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n\nvar input = when(ONLINE_JUDGE) {\n true -> BufferedReader(InputStreamReader(System.`in`), 32768)\n else -> BufferedReader(FileReader(\"in.txt\"))\n}\n\nvar output = when(ONLINE_JUDGE) {\n true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n else -> PrintWriter(BufferedWriter(FileWriter(\"out.txt\")))\n}\n\nvar st = StringTokenizer(\"\")\n\nfun main(args: Array) {\n val start = System.currentTimeMillis()\n solve()\n\n output.close()\n input.close()\n\n/* if (!ONLINE_JUDGE) {\n System.err.println(\"${System.currentTimeMillis() - start} ms\")\n }*/\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1ff6e02142a9c2d51cfcedae475150a3", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n fun gcd(x: Long, y: Long):Long = if (y == 0L) x else gcd(y, x % y)\n\n val a = nextLong()\n val b = nextLong()\n val x = nextLong()\n val y = nextLong()\n\n val g = gcd(x, y)\n val _x = x / g\n val _y = y / g\n\n println(Math.min(a / _x, b / _y))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a30455b84de6a23378e76138c82ade87", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.IOException\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n tv()\n}\n\nfun tv() {\n val ms = MyScanner()\n val a = ms.nextLong()!!\n val b = ms.nextLong()!!\n val x = ms.nextLong()!!\n val y = ms.nextLong()!!\n\n var xx = x\n var yy = y\n\n while (xx != 0L && yy != 0L){\n if (xx > yy){\n xx %= yy\n } else {\n yy %= xx \n }\n }\n \n val nod = xx + yy\n val xxx = x/ nod\n val yyy = y/nod\n System.out.println(Math.min(a/xxx, b/yyy))\n \n}\n\n\ninternal class MyScanner {\n private val `in` = BufferedReader(InputStreamReader(System.`in`))\n private var buffer: Array? = null\n private var pos = 0\n\n @Throws(IOException::class)\n fun nextInt(): Int? {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return Integer.parseInt(buffer!![pos - 1])\n }\n\n @Throws(IOException::class)\n fun nextLong(): Long? {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return (buffer!![pos - 1]).toLong()\n }\n\n @Throws(IOException::class)\n fun nextString(): String {\n if (buffer == null) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n if (buffer!!.size <= pos) {\n buffer = `in`.readLine().split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n pos = 0\n }\n pos++\n return buffer!![pos - 1]\n }\n\n @Throws(IOException::class)\n fun getIntList(n: Int): List {\n val result = mutableListOf(n)\n for (i in 0 until n)\n result.add(nextInt())\n return result\n }\n\n @Throws(IOException::class)\n fun getIntArray(n: Int): IntArray {\n val result = IntArray(n)\n for (i in 0 until n)\n result[i] = nextInt()!!\n return result\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a40668990e494c83d76a24a5c4c08ffa", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "//Benq's template\n\n@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun PrintWriter.solve() {\n val (n,l,r,k)=readLongs(4)\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n println(\"$ans\")\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d781115e39df0ec8c00a89374c2d7654", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun main(){\n val (n,l,r,k)=readLongs()\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n printLine(\"$ans\")\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6059b4267a4a845f6d509d9869d678a6", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "//Benq's template\n/*\n@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun PrintWriter.solve() {\n val (n,l,r,k)=readLongs(4)\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n*n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n println(\"$ans\")\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n*/\n\n\nimport java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun main(){\n val (n,l,r,k)=readLongs()\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n printLine(\"$ans\")\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "21f221ef4dce9534483991a523079062", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "//Benq's template\n\n@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun PrintWriter.solve() {\n val (n,l,r,k)=readLongs(4)\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n*n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n println(\"$ans\")\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "971a952185fa70d6d8ae8ca3ff0e2d65", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nimport kotlin.math.*\n\nfun readLn()=readLine()!!\nfun readInt()=readLn().toInt()\nfun readInts()=readLn().split(\" \").map{it.toInt()}\nfun readLong()=readLn().toLong()\nfun readLongs()=readLn().split(\" \").map{it.toLong()}\n\nval out=mutableListOf()\nfun printLine(s:String){out.add(s)}\nfun output(){println(out.joinToString(\"\\n\"))}\n\nfun dv1(p:Long,q:Long):Long=if(p>=0)(p+q-1)/q else p/q\nfun dv2(p:Long,q:Long):Long=if(p>=0)p/q else (p-q+1)/q\nfun main(){\n val (n,l,r,k)=readLongs()\n val x=if(l<=r)r-l+1 else r+n-l+1\n val y=n-x;var ans=-1L\n if(n*n0&&(p+1)%q==0L)ans=max(ans,a+b)\n }\n }\n }else{\n for(t in 0..k/n){\n if(t==0L){\n if(k>=x&&k<=x*2)ans=max(ans,y+k-x)\n if(k>=x&&k+1<=x*2)ans=max(ans,y+k+1-x)\n }else{\n var m=k-(t+1)*x-t*y\n if(m<0)continue\n var p=m;var q=-m\n var mn=max(dv1(-q,t+1),dv1(p-x,t))\n var mx=min(dv2(p,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n m++;p=m;q=-m\n mn=max(dv1(-q,t+1),dv1(p-x,t))\n mx=min(dv2(p-1,t),dv2(y-q,t+1))\n if(mn<=mx)ans=max(ans,p-t*mx+q+(t+1)*mx)\n }\n }\n }\n printLine(\"$ans\")\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3bfcd0bb70c77fa7f5aada5d6bd07f10", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.FileInputStream\r\n\r\nfun main() {\r\n// changeStandardInput()\r\n var q = 1\r\n while (q-- > 0) {\r\n val (h, w) = readInts()\r\n val f = Array(h) {\r\n readLn()\r\n }\r\n\r\n var cnt = 0\r\n var x = 0\r\n var y = 0\r\n\r\n if (f[0][0] == '*') {\r\n cnt++\r\n }\r\n\r\n while (true) {\r\n if (x + 1 == h && y + 1 == w) break\r\n if (y + 1 < w) {\r\n if (f[x][y + 1] == '*') {\r\n cnt++\r\n y++\r\n continue\r\n }\r\n }\r\n\r\n if (x + 1 < h) {\r\n if (f[x + 1][y] == '*') {\r\n cnt++\r\n x++\r\n continue\r\n }\r\n }\r\n\r\n if (y + 1 < w) {\r\n y++\r\n continue\r\n }\r\n\r\n x++\r\n }\r\n\r\n println(cnt)\r\n }\r\n}\r\n\r\n\r\nprivate fun readLn() = readLine()!!\r\nprivate fun readIntLn() = readLn().toInt()\r\nprivate fun readLongLn() = readLn().toLong()\r\nprivate fun readDoubleLn() = readLn().toDouble()\r\nprivate fun readStrings() = readLn().split(\" \")\r\nprivate fun readInts() = readStrings().map { it.toInt() }\r\nprivate fun readLongs() = readStrings().map { it.toLong() }\r\n\r\n\r\nprivate fun changeStandardInput() {\r\n System.setIn(FileInputStream(\"input.txt\"))\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "078d39e641ae0ecbc1dc22d009f42cf4", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "fun main(args: Array) {\n val (R,C) = readLine()!!.split(\" \").map(String::toInt)\n val A = (0 until R).map { readLine()!! }\n var r = 0\n var c = 0\n var ans = if (A[0][0] == '*') 1 else 0\n while (r != R-1 || c != C-1) {\n if (r == R-1) {\n c++\n } else if (c == C-1) {\n r++\n } else if (A[r][c+1] == '*') {\n c++\n } else if (A[r+1][c] == '*') {\n r++\n } else {\n c++\n }\n if (A[r][c] == '*') ans++\n }\n\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "aca43de193de141deed734f016233452", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val a = List(n) { readLine()!! }\n var x = 0\n var y = 0\n var ans = 0\n while (true) {\n if (a[x][y] == '*') ans++\n if (x == n - 1 && y == m - 1) break\n\n var down = Int.MAX_VALUE\n for (i in (x + 1) until n) {\n if (a[i][y] == '*') { down = i - x; break }\n }\n var right = Int.MAX_VALUE\n for (j in (y + 1) until m) {\n if (a[x][j] == '*') { right = j - y; break }\n }\n\n if (x < n - 1 && (down < right || y == m - 1)) x++ else y++\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9e0277cb185cd8bff7799f9fee65f186", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval inf = BufferedReader(InputStreamReader(System.`in`))\nval ouf = PrintWriter(System.out)\n\nfun readInts() = inf.readLine()!!.split(' ').map(String::toInt)\nfun readLongs() = inf.readLine()!!.split(' ').map(String::toLong)\nfun readString() = inf.readLine()!!\n\nfun main() {\n val (h, w) = readInts()\n val a = Array(h) {\n readString().map { it == '*' }.toBooleanArray()\n }\n var x = 0\n var y = 0\n var ans = if (a[0][0]) 1 else 0\n while (x < h - 1 || y < w - 1) {\n when {\n y < w - 1 && a[x][y + 1] -> y++\n x < h - 1 && a[x + 1][y] -> x++\n y < w - 1 -> y++\n else -> x++\n }\n if (a[x][y]) ans++\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "74c0c46b84f94a836af37878ccefa693", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "import kotlin.math.*;\nimport java.math.BigInteger;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val MOD = 998244353;\n@JvmField val exp2sact_cache = HashMap>();\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readInt2() = Pair(readInt(),readInt())\nfun readInt3() = Triple(readInt(),readInt(),readInt())\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readLong2() = Pair(readLong(),readLong())\nfun readLong3() = Triple(readLong(),readLong(),readLong())\nfun readString() = readLine()!!;\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\nfun printVars(vararg vs: Any?){for(v in vs) print(\"$v \");println(\"\");}\nfun moduloAdd(v1: Int,v2: Int) = ((v1+0L+v2)%MOD).toInt();\nfun moduloMultiply(v1: Int,v2: Int) = ((v1*1L*v2)%MOD).toInt();\nfun exp2s(v: Int): List{var targ = v;var es = mli();var e = 0;while(targ>0){if (targ%2==1) es.add(e);targ/= 2;e++;};return es;}\nfun exp2sact(v: Int): List\n{\n if (exp2sact_cache[v]!=null) return exp2sact_cache[v]!!;\n var targ = v;\n var es = mli();\n var e = 1;\n while(targ>0)\n {\n if (targ%2==1) es.add(e);\n targ/= 2;e*= 2;\n };\n exp2sact_cache[v] = es;\n return es;\n}\nfun iLog2(v:Int):Int{var ret=0;var vv= v shr 1;while(vv>0){ret++;vv=vv shr 1};return ret}\nfun iLog2(v:Long):Int{var ret=0;var vv= v shr 1;while(vv>0){ret++;vv=vv shr 1};return ret}\nfun tri(n: Int) = (n*(n+1))/2;\nfun tri(n: Long) = (n*(n+1))/2;\nfun isEven(v: Int) = v%2==0;\nfun isOdd(v: Int) = v%2==1;\nfun isEven(v: Long) = v%2L==0L;\nfun isOdd(v: Long) = v%2L==1L;\ninfix fun Int.between(range: Pair): Boolean = ((this >= range.first) && (this <= range.second));\ninfix fun Long.between(range: Pair): Boolean = ((this >= range.first) && (this <= range.second));\nfun mli() = mutableListOf();\nfun mlid(n: Int,def: (it: Int) -> Int) = MutableList(n,def);\nfun mll() = mutableListOf();\nfun mlld(n: Int,def: (it: Int) -> Long) = MutableList(n,def);\nfun trsti() = TreeSet();\nfun trstl() = TreeSet();\nfun hmii() = HashMap();\nfun hmil() = HashMap();\nfun hmli() = HashMap();\nfun hmll() = HashMap();\nclass MultiSet(initContent: List = listOf()){private val mp = HashMap();init {for(x in initContent) add(x);}operator fun get(value: T): Int{return if (mp[value]!=null) mp[value]!! else 0;}fun add(value: T,count: Int = 1): Int{if (count < 0) throw Exception(\"count must be non-negative\");if (mp[value]==null) mp[value] = 0;var ret = mp[value]!!+count;mp[value] = ret;return ret;}fun remove(value: T,count: Int = 1): Int{if (count < 0) throw Exception(\"count must be non-negative\");var ret = this[value];ret = max(0,ret-count);if (ret==0){mp.remove(value);}else{mp[value] = ret;};return ret;}fun delete(value: T): Int{var ret = this[value];mp.remove(value);return ret;}val size get() = mp.size;operator fun iterator(): MutableIterator> = mp.iterator();override fun toString() = \"$mp\";}\nfun List.floor(v: Int): Int{var pos=binarySearch(v);if (pos>= 0){return pos;}else{return -(pos+1)-1;};}\nfun List.ceiling(v: Int): Int{var pos=binarySearch(v);if (pos>=0){return pos;}else{var ret = -(pos+1);return if (ret < size) ret else -1;}}\nfun List.floor(v: Long): Int{var pos=binarySearch(v);if (pos>= 0){return pos;}else{return -(pos+1)-1;};}\nfun List.ceiling(v: Long): Int{var pos=binarySearch(v);if (pos>=0){return pos;}else{var ret = -(pos+1);return if (ret < size) ret else -1;}}\nfun gcd(a: Int,b: Int): Int{if (b==0) return a;return gcd(b,a%b);}\nfun gcd(a: Long,b: Long): Long{if (b==0L) return a;return gcd(b,a%b);}\n\n@JvmField val DEBUG = false;\n\nclass Prob\n{\n fun exec()\n { \n var h = readLong();\n var w = readInt();\n var r = 0L;\n var c = 0;\n var d = 0 to 1;\n var s = readString();\n var ns = if (h>1) readString() else (List(w) { '.' }).joinToString(\"\");\n var ans = 0L;\n var cur = 0;\n while(true)\n {\n if (s[c]=='*') ans++;\n var right = if (cr)\n {\n var _s = if (nr '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextLong(): Long {\r\n\t\tvar neg = false\r\n\t\tif (c == NC) c = char\r\n\t\twhile (c < '0' || c > '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0L\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextString():String{\r\n\t\tif (c == NC) c = char\r\n\t\tval ret = StringBuilder()\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(!isWhitespace(c)){ break}\r\n\t\t}\r\n\t\tret.appendCodePoint(c.toInt())\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(isWhitespace(c)){ break}\r\n\t\t\tret.appendCodePoint(c.toInt());\r\n\r\n\t\t}\r\n\t\treturn ret.toString()\r\n\t}\r\n\tfun isWhitespace(c:Char):Boolean{\r\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n\t}\r\n}\r\nclass reading{\r\n\tcompanion object{\r\n\t\tvar jin = FastScanner()\r\n\t\tvar pw = PrintWriter(System.out)\r\n\t}\r\n}\r\nfun put(aa:Any){ reading.pw.println(aa)}\r\nfun done(){ reading.pw.close() }\r\n\r\nfun getint():Int{ return reading.jin.nextInt() }\r\nfun getlong():Long{ return reading.jin.nextLong() }\r\nfun getline(n:Int):List{ return (1..n).map{reading.jin.nextInt()} }\r\nfun getlineL(n:Int):List{return (1..n).map{reading.jin.nextLong()} }\r\nfun getstr():String{ return reading.jin.nextString() }\r\nfun MutableList.streamint(n:Int){ repeat(n){this.add(getint())}}\r\nfun MutableList.streamlong(n:Int){ repeat(n){this.add(getlong())}}\r\ninline fun cases(ask:()->Unit){ val t = getint();repeat(t){ ask() }}\r\n\r\nval List.ret:String\r\n\tget() = this.joinToString(\"\")\r\ninfix fun Any.dei(a:Any){\r\n\t//does not stand for anything it is just easy to type\r\n\tvar str = \"\"\r\n\tif(this is String){ str = this\r\n\t}else if(this is Int){ str = this.toString()\r\n\t}else if(this is Long){ str = this.toString()\r\n\t}\r\n\tif(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else{ println(\"$str : $a\")\r\n\t}\r\n}\r\nval just = \" \" // usage: just dei x , where x is the debug variable\r\n\r\nfun main() {\r\n\tval n = getint()\r\n\tval m = getint()\r\n\tval maze = mutableListOf()\r\n\trepeat(n){\r\n\t\tmaze.add(getstr().map{if(it == '*') 1 else 0}.toIntArray())\r\n\t}\r\n\r\n\tvar x = 0\r\n\tvar y = 0\r\n\tvar ret = 0\r\n\tif(maze[0][0] ==1){\r\n\t\tret += 1\r\n\t}\r\n\r\n\tdone@while(x < 4 || y < 4){\r\n\t\tfor(s in 1..8){\r\n\t\t\tfor(dx in 0..4){\r\n\t\t\t\tval dy = s - dx\r\n\t\t\t\tif(dx < 0 || dy <0){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tval xx = x + dx\r\n\t\t\t\tval yy = y + dy\r\n\t\t\t\tif(xx >= n || yy >= m){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tif(maze[xx][yy] == 1){\r\n\t\t\t\t\tx = xx\r\n\t\t\t\t\ty = yy\r\n\t\t\t\t\tret += 1\r\n\t\t\t\t\tcontinue@done\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak\r\n\t}\r\n\tput(ret)\r\n\tdone()\r\n\r\n\r\n // Write your solution here\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "254f5cc4dee2a5e6c0f75fdd2688ef0a", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "/**\r\n * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools\r\n */\r\nimport java.io.BufferedInputStream\r\nimport java.io.BufferedReader\r\nimport java.io.InputStreamReader\r\nimport java.io.PrintWriter\r\nimport kotlin.math.min\r\nimport kotlin.math.max\r\nimport kotlin.reflect.KProperty0\r\n\r\nclass FastScanner {\r\n\tprivate val BS = 1 shl 16\r\n\tprivate val NC = 0.toChar()\r\n\tprivate val buf = ByteArray(BS)\r\n\tprivate var bId = 0\r\n\tprivate var size = 0\r\n\tprivate var c = NC\r\n\tprivate var `in`: BufferedInputStream? = null\r\n\r\n\tconstructor() {\r\n\t\t`in` = BufferedInputStream(System.`in`, BS)\r\n\t}\r\n\r\n\tprivate val char: Char\r\n\t\tget() {\r\n\t\t\twhile (bId == size) {\r\n\t\t\t\tsize = try {\r\n\t\t\t\t\t`in`!!.read(buf)\r\n\t\t\t\t} catch (e: Exception) {\r\n\t\t\t\t\treturn NC\r\n\t\t\t\t}\r\n\t\t\t\tif (size == -1) return NC\r\n\t\t\t\tbId = 0\r\n\t\t\t}\r\n\t\t\treturn buf[bId++].toChar()\r\n\t\t}\r\n\r\n\tfun nextInt(): Int {\r\n\t\tvar neg = false\r\n\t\tif (c == NC) c = char\r\n\t\twhile (c < '0' || c > '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextLong(): Long {\r\n\t\tvar neg = false\r\n\t\tif (c == NC) c = char\r\n\t\twhile (c < '0' || c > '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0L\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextString():String{\r\n\t\tif (c == NC) c = char\r\n\t\tval ret = StringBuilder()\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(!isWhitespace(c)){ break}\r\n\t\t}\r\n\t\tret.appendCodePoint(c.toInt())\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(isWhitespace(c)){ break}\r\n\t\t\tret.appendCodePoint(c.toInt());\r\n\r\n\t\t}\r\n\t\treturn ret.toString()\r\n\t}\r\n\tfun isWhitespace(c:Char):Boolean{\r\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n\t}\r\n}\r\nclass reading{\r\n\tcompanion object{\r\n\t\tvar jin = FastScanner()\r\n\t\tvar pw = PrintWriter(System.out)\r\n\t}\r\n}\r\nfun put(aa:Any){ reading.pw.println(aa)}\r\nfun done(){ reading.pw.close() }\r\n\r\nfun getint():Int{ return reading.jin.nextInt() }\r\nfun getlong():Long{ return reading.jin.nextLong() }\r\nfun getline(n:Int):List{ return (1..n).map{reading.jin.nextInt()} }\r\nfun getlineL(n:Int):List{return (1..n).map{reading.jin.nextLong()} }\r\nfun getstr():String{ return reading.jin.nextString() }\r\nfun MutableList.streamint(n:Int){ repeat(n){this.add(getint())}}\r\nfun MutableList.streamlong(n:Int){ repeat(n){this.add(getlong())}}\r\ninline fun cases(ask:()->Unit){ val t = getint();repeat(t){ ask() }}\r\n\r\nval List.ret:String\r\n\tget() = this.joinToString(\"\")\r\ninfix fun Any.dei(a:Any){\r\n\t//does not stand for anything it is just easy to type\r\n\tvar str = \"\"\r\n\tif(this is String){ str = this\r\n\t}else if(this is Int){ str = this.toString()\r\n\t}else if(this is Long){ str = this.toString()\r\n\t}\r\n\tif(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else{ println(\"$str : $a\")\r\n\t}\r\n}\r\nval just = \" \" // usage: just dei x , where x is the debug variable\r\n\r\nfun main() {\r\n\tval n = getint()\r\n\tval m = getint()\r\n\tval maze = mutableListOf()\r\n\trepeat(n){\r\n\t\tmaze.add(getstr().map{if(it == '*') 1 else 0}.toIntArray())\r\n\t}\r\n\r\n\tvar x = 0\r\n\tvar y = 0\r\n\tvar ret = 0\r\n\tif(maze[0][0] ==1){\r\n\t\tret += 1\r\n\t}\r\n\r\n\tdone@while(x < 4 || y < 4){\r\n\t\tfor(s in 1..8){\r\n\t\t\tfor(dy in 0..4){\r\n\t\t\t\tval dx = s - dy\r\n\t\t\t\tif(dx < 0 || dy <0){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tval xx = x + dx\r\n\t\t\t\tval yy = x + dy\r\n\t\t\t\tif(xx >= n || yy >= m){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tif(maze[xx][yy] == 1){\r\n\t\t\t\t\tx = xx\r\n\t\t\t\t\ty = yy\r\n\t\t\t\t\tret += 1\r\n\t\t\t\t\tcontinue@done\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak\r\n\t}\r\n\tput(ret)\r\n\tdone()\r\n\r\n\r\n // Write your solution here\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f5f08be2dd1e7f59cb990cfe62f67c61", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "/**\r\n * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools\r\n */\r\nimport java.io.BufferedInputStream\r\nimport java.io.BufferedReader\r\nimport java.io.InputStreamReader\r\nimport java.io.PrintWriter\r\nimport kotlin.math.min\r\nimport kotlin.math.max\r\nimport kotlin.reflect.KProperty0\r\n\r\nclass FastScanner {\r\n\tprivate val BS = 1 shl 16\r\n\tprivate val NC = 0.toChar()\r\n\tprivate val buf = ByteArray(BS)\r\n\tprivate var bId = 0\r\n\tprivate var size = 0\r\n\tprivate var c = NC\r\n\tprivate var `in`: BufferedInputStream? = null\r\n\r\n\tconstructor() {\r\n\t\t`in` = BufferedInputStream(System.`in`, BS)\r\n\t}\r\n\r\n\tprivate val char: Char\r\n\t\tget() {\r\n\t\t\twhile (bId == size) {\r\n\t\t\t\tsize = try {\r\n\t\t\t\t\t`in`!!.read(buf)\r\n\t\t\t\t} catch (e: Exception) {\r\n\t\t\t\t\treturn NC\r\n\t\t\t\t}\r\n\t\t\t\tif (size == -1) return NC\r\n\t\t\t\tbId = 0\r\n\t\t\t}\r\n\t\t\treturn buf[bId++].toChar()\r\n\t\t}\r\n\r\n\tfun nextInt(): Int {\r\n\t\tvar neg = false\r\n\t\tif (c == NC) c = char\r\n\t\twhile (c < '0' || c > '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextLong(): Long {\r\n\t\tvar neg = false\r\n\t\tif (c == NC) c = char\r\n\t\twhile (c < '0' || c > '9') {\r\n\t\t\tif (c == '-') neg = true\r\n\t\t\tc = char\r\n\t\t}\r\n\t\tvar res = 0L\r\n\t\twhile (c >= '0' && c <= '9') {\r\n\t\t\tres = (res shl 3) + (res shl 1) + (c - '0')\r\n\t\t\tc = char\r\n\t\t}\r\n\t\treturn if (neg) -res else res\r\n\t}\r\n\tfun nextString():String{\r\n\t\tif (c == NC) c = char\r\n\t\tval ret = StringBuilder()\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(!isWhitespace(c)){ break}\r\n\t\t}\r\n\t\tret.appendCodePoint(c.toInt())\r\n\t\twhile (true){\r\n\t\t\tc = char\r\n\t\t\tif(isWhitespace(c)){ break}\r\n\t\t\tret.appendCodePoint(c.toInt());\r\n\r\n\t\t}\r\n\t\treturn ret.toString()\r\n\t}\r\n\tfun isWhitespace(c:Char):Boolean{\r\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n\t}\r\n}\r\nclass reading{\r\n\tcompanion object{\r\n\t\tvar jin = FastScanner()\r\n\t\tvar pw = PrintWriter(System.out)\r\n\t}\r\n}\r\nfun put(aa:Any){ reading.pw.println(aa)}\r\nfun done(){ reading.pw.close() }\r\n\r\nfun getint():Int{ return reading.jin.nextInt() }\r\nfun getlong():Long{ return reading.jin.nextLong() }\r\nfun getline(n:Int):List{ return (1..n).map{reading.jin.nextInt()} }\r\nfun getlineL(n:Int):List{return (1..n).map{reading.jin.nextLong()} }\r\nfun getstr():String{ return reading.jin.nextString() }\r\nfun MutableList.streamint(n:Int){ repeat(n){this.add(getint())}}\r\nfun MutableList.streamlong(n:Int){ repeat(n){this.add(getlong())}}\r\ninline fun cases(ask:()->Unit){ val t = getint();repeat(t){ ask() }}\r\n\r\nval List.ret:String\r\n\tget() = this.joinToString(\"\")\r\ninfix fun Any.dei(a:Any){\r\n\t//does not stand for anything it is just easy to type\r\n\tvar str = \"\"\r\n\tif(this is String){ str = this\r\n\t}else if(this is Int){ str = this.toString()\r\n\t}else if(this is Long){ str = this.toString()\r\n\t}\r\n\tif(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n\t}else{ println(\"$str : $a\")\r\n\t}\r\n}\r\nval just = \" \" // usage: just dei x , where x is the debug variable\r\n\r\nfun main() {\r\n\tval n = getint()\r\n\tval m = getint()\r\n\tval maze = mutableListOf()\r\n\trepeat(n){\r\n\t\tmaze.add(getstr().map{if(it == '*') 1 else 0}.toIntArray())\r\n\t}\r\n\r\n\tvar x = 0\r\n\tvar y = 0\r\n\tvar ret = 0\r\n\tif(maze[0][0] ==1){\r\n\t\tret += 1\r\n\t}\r\n\r\n\tdone@while(x < 4 || y < 4){\r\n\t\tfor(s in 1..8){\r\n\t\t\tfor(dy in 0..4){\r\n\t\t\t\tval dx = s - dy\r\n\t\t\t\tif(dx < 0 || dy <0){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tval xx = x + dx\r\n\t\t\t\tval yy = y + dy\r\n\t\t\t\tif(xx >= n || yy >= m){\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tif(maze[xx][yy] == 1){\r\n\t\t\t\t\tx = xx\r\n\t\t\t\t\ty = yy\r\n\t\t\t\t\tret += 1\r\n\t\t\t\t\tcontinue@done\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak\r\n\t}\r\n\tput(ret)\r\n\tdone()\r\n\r\n\r\n // Write your solution here\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1755b9160146f0fbbd580b28c4120e36", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "// Star because this code solves the problem, but in the tutorial there is a better solution using GCD\n//fun main() {\n// fun readInt() = readLine()!!.toInt()\n// fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n//\n// val n = readInt()\n// val nums = readInts().toIntArray()\n// var minimum = nums.min()!!\n// do {\n// for (pos in 0 until n) {\n// nums[pos] %= minimum\n// if (nums[pos] == 0) nums[pos] = minimum\n// }\n// minimum = nums.min()!!\n// } while (minimum != nums.max()!!)\n// print(minimum * n)\n//}\n\n// solution from tutorial\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n infix fun Int.maxMin(b: Int): Pair = if (this >= b) this to b else b to this\n fun gcd(a: Int, b: Int): Int {\n var (max, min) = a maxMin b\n while (min != 0) {\n val newMin = max % min\n max = min\n min = newMin\n }\n return max\n }\n\n val n = readInt()\n val nums = readInts()\n val gcdNums = nums.reduce(::gcd)\n print(gcdNums * n)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd241632acbab473c896c3d77c5736fe", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n\n readLine()\n var list = readLine()!!.split(\" \").map { it.toInt() }.sorted().toMutableList()\n var max = list.max()\n var min = list.min()\n\n while (max != min){\n list[list.size-1] = list[list.size-1]-list[0]\n max = list.max()\n min = list.min()\n list.sort()\n }\n println(list.sum())\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6014eaf55f0c39141ad08f85fff21676", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nval reader = Scanner(System.`in`)\nfun main(args: Array){\n val n = reader.nextInt()\n\n val arr = Array(n,{i -> reader.nextInt()})\n\n arr.sort()\n\n\n while (arr[n-2] < arr[n-1])\n {\n arr[n-1] = arr[n-1]-arr[n-2]\n arr.sort()\n }\n var ans = 0\n for (i in arr)\n {\n ans+=i\n }\n\n print(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "42fd516c8a7b1eff6ff2e25ab7a1b95f", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nval reader = Scanner(System.`in`)\nvar l=0\nvar r=0\nvar ans = 0\nvar flag = false\nfun main(args: Array){\n val n = reader.nextInt()\n\n val arr = Array(n,{i -> reader.nextInt()})\n\n arr.sort()\n\n\n /* arr.forEach { print(it)\n print(\" \")}*/\n\n r=n-1\n l=n-2\n while (true)\n {\n if(arr[r]>arr[l])\n {\n arr[r] = arr[r] - arr[l]\n flag = true\n }\n l--\n r--\n\n if(l==-1)\n {\n if (flag) {\n flag = false\n r = n - 1\n l = n - 2\n arr.sort()\n }\n else\n {\n arr.forEach { ans+=it }\n }\n }\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6d54018b92c2fb23bce17eae6c0fb784", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.abs\nimport java.util.*\n\nfun solve(cin: FastReader, out: PrintWriter) {\n val n = cin.int()\n val m = cin.int()\n var cnt: Long = 0\n for (i in 1..m)\n for (j in 1..m)\n if ((i * i + j * j.toLong()) % m == 0L)\n cnt += ((n - i + 1 + m - 1) / m).toLong() * ((n - j + 1 + m - 1) / m).toLong()\n\n out.print(cnt)\n}\n\n\n\nclass FastReader(input: InputStream) {\n private val br = BufferedReader(InputStreamReader(input))\n private var st = StringTokenizer(\"\")\n\n fun next(): String {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun int(): Int {\n return next().toInt()\n }\n\n fun double(): Double {\n return next().toDouble()\n }\n\n fun long(): Long {\n return next().toLong()\n }\n\n /**\n * Warning! Use carefully!\n */\n fun nextLine(): String {\n return br.readLine()\n }\n}\n\nfun main(args: Array) {\n val cin = FastReader(System.`in`)\n val out = PrintWriter(BufferedOutputStream(System.out))\n solve(cin, out)\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ea9d04576feba19fabb80556ad956ed3", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.abs\nimport java.util.*\n\nfun solve(cin: FastReader, out: PrintWriter) {\n val n = cin.int()\n val m = cin.int()\n var cnt = 0\n var part = 0\n for (i in 1..m)\n for (j in 1..m)\n if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())\n cnt++\n for (i in 1..(n % m))\n for (j in 1..(n % m))\n if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())\n part++\n var c = 0\n for (i in 1..m)\n for (j in 1..(n % m))\n if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())\n c++\n out.print((n / m).toLong() * (n / m).toLong() * cnt + part + (n / m).toLong() * 2 * c)\n}\n\n\n\nclass FastReader(input: InputStream) {\n private val br = BufferedReader(InputStreamReader(input))\n private var st = StringTokenizer(\"\")\n\n fun next(): String {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun int(): Int {\n return next().toInt()\n }\n\n fun double(): Double {\n return next().toDouble()\n }\n\n fun long(): Long {\n return next().toLong()\n }\n\n /**\n * Warning! Use carefully!\n */\n fun nextLine(): String {\n return br.readLine()\n }\n}\n\nfun main(args: Array) {\n val cin = FastReader(System.`in`)\n val out = PrintWriter(BufferedOutputStream(System.out))\n solve(cin, out)\n out.flush()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0a7399d01f7934b9180cc4309cc5a70a", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0L\n for (i in 0 until m) {\n for (j in 0 until m) {\n if ((i * i + j * j) % m == 0) {\n val x = when {\n i == 0 -> n / m\n n >= i -> ((n - i) / m) + 1\n else -> 0\n }\n val y = when {\n j == 0 -> n / m\n n >= j -> ((n - j) / m) + 1\n else -> 0\n }\n ans += x.toLong() * y\n }\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "57ac1a561812de73e0bce26f96c6836a", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var W = readLine()!!\n var C = 0\n var c = 0\n for (i in 0 until N) {\n when(W[i]){\n in 'A'..'Z'-> {\n C++\n c = C\n }\n ' '->{\n C = 0\n if (c < C) {\n c = C\n }\n }\n }\n }\n print(c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "917dc0ed5e6286cb265ab9075a921214", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var W = readLine()!!\n var C = 0\n var c = 0\n var s = 0\n for (i in 0 until N){\n loop@for (j in 'A'..'Z'){\n if (W[i] == j) {\n C++\n }\n if (W[i] == ' ') {\n if(C > c){\n s ++\n c = C\n C = 0\n break@loop\n }\n }\n }\n }\n if ((c > 1)&&(s > 0)){\n print(c/s)\n }\n else if (c > 0){\n print(c)\n }\n else{\n print(C)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4157a5fa9507e5a923c154966a307e4f", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var W = readLine()!!\n var C = 0\n var c = 0\n var s = 0\n for (i in 0 until N){\n for (j in 'A'..'Z'){\n if (W[i] == j) {\n C++\n }\n else if (W[i] == ' ') {\n s ++\n c = C\n C = 0\n }\n }\n }\n if ((c > 1)&&(s > 0)){\n print(c/s)\n }\n else if (c > 0){\n print(c)\n }\n else{\n print(C)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dffb8895b86e8e37506f30c726fa8e53", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args : Array){\n\n var n = readLine()\n var text = readLine() + \" \"\n var max = 0\n var count = 0\n\n for (c in text) {\n if (c.isUpperCase()) {\n ++count\n } else if (c.toString() == \" \") {\n max = if (count > max) count else max\n count = 0\n }\n }\n\n println(max)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5aae8d404d5c20703f523eb63d29ea4b", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n readLine()\n println(readLine()!!.split(\" \").map { it.count { c -> c.isUpperCase() } }.max()!!)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5845f28f32cdd3751a027f488e591d65", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var W = readLine()!!\n var C = 0\n var c = 0\n for (i in 0 until N) {\n when(W[i]){\n in 'A'..'Z'-> {\n C++\n if (c < C) {\n c = C\n }\n }\n ' '->{\n C = 0\n if (c < C) {\n c = C\n }\n }\n }\n }\n print(c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "98662429f9e67b7de040bb2d289498ee", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\n\t\tif(last.size == 2){\n\t\t\tprintln(\"! $next\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tvar a1 = -1\n\t\tvar a2 = -1\n\t\tfor(lastnei in last){\n\t\t\tif(!queries.containsKey(lastnei)){\n\t\t\t\tif(a1 == -1) a1 = lastnei\n\t\t\t\telse a2 = lastnei\n\t\t\t}\n\t\t}\n\n\t\tif(a2 == -1) answer = a1\n\t\telse{\n\t\t\tif(query(a1).size == 2) answer = a1\n\t\t\telse answer = a2\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4abcd26728a319f9256cc70657bed7ee", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(1000)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,n+1)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < 6 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tfor(lastnei in last){\n\t\t\tif(query(lastnei).size == 2){\n\t\t\t\tanswer = lastnei\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d032851020bed5c732e5655d2ea4797a", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap>()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : List{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toMutableList().shuffled(random)\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, pa : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tvar p = pa\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = cur\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\tvar parent = ipeak\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(posnei == parent) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,next,depth)){\n\t\t\t\tparent = next\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tparent = next\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\n\t\tif(last.size == 2){\n\t\t\tprintln(\"! $next\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tvar a1 = -1\n\t\tvar a2 = -1\n\t\tfor(lastnei in last){\n\t\t\tif(!queries.containsKey(lastnei)){\n\t\t\t\tif(a1 == -1) a1 = lastnei\n\t\t\t\telse a2 = lastnei\n\t\t\t}\n\t\t}\n\n\t\tif(a2 == -1) answer = a1\n\t\telse{\n\t\t\tif(query(a1).size == 2) answer = a1\n\t\t\telse answer = a2\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1ef63114252c7d0a4b346e5f87dfb68a", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tfor(lastnei in last){\n\t\t\tif(query(lastnei).size == 2){\n\t\t\t\tanswer = lastnei\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "aed00695919812918d71f50fdbf308b3", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tvar a1 = -1\n\t\tvar a2 = -1\n\t\tfor(lastnei in last){\n\t\t\tif(!queries.containsKey(lastnei)){\n\t\t\t\tif(a1 == -1) a1 = lastnei\n\t\t\t\telse a2 = lastnei\n\t\t\t}\n\t\t}\n\n\t\tif(a2 == -1) answer = a1\n\t\telse{\n\t\t\tif(query(a1).size == 2) answer = a1\n\t\t\telse answer = a2\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "19ce940bafe82d608b88f83e375f2f97", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(1000)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,n+1)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < 6 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\tprintln(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tfor(lastnei in last){\n\t\t\tif(query(lastnei).size == 2){\n\t\t\t\tanswer = lastnei\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f8759d664db219692330e0c5fa28b055", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint, fixes the 1 extra query case\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap>()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : List{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toMutableList().shuffled(random)\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\n\t\tif(n <= 4){\n\t\t\t//query every node\n\t\t\tfor(k in 1 until (1 shl n)){\n\t\t\t\tif(query(k).size == 2){\n\t\t\t\t\tanswer = k\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\n\n\t\tfun test(i : Int, pa : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tvar p = pa\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = cur\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\t\t//println(\"$depth $next\")\n\t\tif(depth == n){\n\t\t\tanswer = next\n\t\t} else if(depth == n-1){\n\t\t\tval nextneis1 = query(next)\n\t\t\tfor(nextnei in nextneis1){\n\t\t\t\tif(query(nextnei).size == 2){\n\t\t\t\t\tanswer = nextnei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\tvar parent = ipeak\n\t\twhile(depth < n-2 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(posnei == parent) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,next,depth)){\n\t\t\t\tparent = next\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tparent = next\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 5, ,\n\t\t//get the two nodes\n\n\t\tvar n1 = -1\n\t\tvar n2 = -1\n\n\t\tvar nextneis = query(next)\n\t\tfor(neis in nextneis){\n\t\t\tif(neis == parent) continue\n\t\t\tif(n1 == -1) n1 = neis\n\t\t\telse n2 = neis\n\t\t}\n\n\t\tval possibilities = mutableListOf()\n\t\tval n1neis = query(n1)\n\t\tval n2neis = query(n2)\n\n\t\tfor(n1nei in n1neis) possibilities.add(n1nei)\n\t\tfor(n2nei in n2neis) possibilities.add(n2nei)\n\n\t\tfor(k in 0 until 3){\n\t\t\tif(query(possibilities[k]).size == 2){\n\t\t\t\tanswer = possibilities[k]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif(answer == -1) answer = possibilities[3]\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\n\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "af66beb3862781b795dfde6d69192f7d", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(1000)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\tval seen = BooleanArray((1 shl (n+1)) + 2){false}\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(seen[i]) return queries[i]!!\n\t\t\tseen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(seen[nei]) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,n+1)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(seen[posnext]) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < 6 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(seen[posnei]) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\n\t\t\t//see if try1 works\n\t\t\tif(test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tfor(lastnei in last){\n\t\t\tif(query(lastnei).size == 2){\n\t\t\t\tanswer = lastnei\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4253b08cb0d040ec4fef3abc5a01720f", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, pa : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tvar p = pa\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = cur\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\tvar parent = ipeak\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(posnei == parent) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,next,depth)){\n\t\t\t\tparent = next\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tparent = next\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\n\t\tif(last.size == 2){\n\t\t\tprintln(\"! $next\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tvar a1 = -1\n\t\tvar a2 = -1\n\t\tfor(lastnei in last){\n\t\t\tif(!queries.containsKey(lastnei)){\n\t\t\t\tif(a1 == -1) a1 = lastnei\n\t\t\t\telse a2 = lastnei\n\t\t\t}\n\t\t}\n\n\t\tif(a2 == -1) answer = a1\n\t\telse{\n\t\t\tif(query(a1).size == 2) answer = a1\n\t\t\telse answer = a2\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ef67bcd78b0113be5edcd9af5210b273", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : IntArray{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toIntArray()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\t\tfun test(i : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(queries.containsKey(nei)) continue\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\n\t\twhile(depth < n-1 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(queries.containsKey(posnei)) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,depth)){\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 6, have two unseen neighbors,\n\n\t\tval last = query(next)\n\t\tvar a1 = -1\n\t\tvar a2 = -1\n\t\tfor(lastnei in last){\n\t\t\tif(!queries.containsKey(lastnei)){\n\t\t\t\tif(a1 == -1) a1 = lastnei\n\t\t\t\telse a2 = lastnei\n\t\t\t}\n\t\t}\n\n\t\tif(a2 == -1) answer = a1\n\t\telse{\n\t\t\tif(query(a1.size) == 2) answer = a1\n\t\t\telse answer = a2\n\t\t}\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "84942681d5bcf591e55bad3676e75852", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "//New Year and Finding Roots\nimport java.io.*\nimport java.util.*\nimport kotlin.math.*\nimport kotlin.random.*\n//small hint, fixes the 1 extra query case\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval random = Random(54321)\n\n\n\n\tfor(q in 1..f.readLine().toInt()){\n\t\tval n = f.readLine().toInt()\n\n\n\t\tvar answer = -1\n\t\t//store queries\n\t\tval queries = HashMap>()\n\t\t//val seen = BooleanArray((1 shl (n+1)) + 2){false}\n\n\t\tfun query(i : Int) : List{\n\t\t\tif(queries.containsKey(i)) return queries[i]!!\n\t\t\t//seen[i] = true\n\t\t\tprintln(\"? $i\")\n\t\t\tSystem.out.flush()\n\n\t\t\tval size = f.readLine().toInt()\n\t\t\tqueries[i] = f.readLine().split(\" \").map{it.toInt()}.toMutableList()\n\t\t\treturn queries[i]!!\n\t\t}\n\n\n\n\t\tif(n <= 4){\n\t\t\t//query every node\n\t\t\tfor(k in 1 until (1 shl n)){\n\t\t\t\tif(query(k).size == 2){\n\t\t\t\t\tanswer = k\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\n\n\t\tfun test(i : Int, pa : Int, d : Int) : Boolean{\n\t\t\tvar cur = i\n\t\t\tvar p = pa\n\t\t\tfor(k in 0 until d-2){\n\t\t\t\tval neis = query(cur)\n\t\t\t\tif(neis.size == 1) return false\n\t\t\t\tif(neis.size == 2){\n\t\t\t\t\tanswer = cur\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t//pick next\n\t\t\t\tfor(nei in neis){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = cur\n\t\t\t\t\tcur = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tval last = query(cur)\n\t\t\tif(last.size == 2){\n\t\t\t\tanswer = cur\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn last.size == 1\n\t\t}\n\n\t\t//pick first node\n\t\tval first = random.nextInt(1,1 shl n)\n\n\t\tval initial = mutableListOf()\n\t\tinitial.add(first)\n\n\t\t//query first\n\t\tval initialneis = query(first)\n\n\t\tif(initialneis.size == 2){\n\t\t\tprintln(\"! $first\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\n\t\tif(initialneis.size == 1){\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(true){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t//size is 3\n\t\t\t//do one path\n\t\t\tvar p = first\n\t\t\tvar i = initialneis[0]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(0,i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = first\n\t\t\ti = initialneis[1]\n\n\t\t\twhile(answer == -1){\n\t\t\t\tinitial.add(i)\n\t\t\t\tval cur = query(i)\n\t\t\t\tif(cur.size == 1){\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif(cur.size == 2){\n\t\t\t\t\tanswer = i\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//get next\n\t\t\t\tfor(nei in cur){\n\t\t\t\t\tif(nei == p) continue\n\t\t\t\t\tp = i\n\t\t\t\t\ti = nei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\t//get initial peak and initial depth\n\t\t//println(initial.joinToString(\" \"))\n\t\tval ipeak = initial[initial.size/2]\n\t\tval idepth = (initial.size+1)/2\n\n\t\tvar next = -1\n\t\tfor(posnext in queries[ipeak]!!){\n\t\t\t//if(posnext == initial[initial.size/2-1] || posnext == initial[initial.size/2+1]) continue\n\t\t\tif(queries.containsKey(posnext)) continue\n\t\t\tnext = posnext\n\t\t\tbreak\n\t\t}\n\n\t\tvar depth = idepth+1\n\t\t//println(\"$depth $next\")\n\t\tif(depth == n){\n\t\t\tanswer = next\n\t\t} else if(depth == n-1){\n\t\t\tval nextneis1 = query(next)\n\t\t\tfor(nextnei in nextneis1){\n\t\t\t\tif(query(nextnei).size == 2){\n\t\t\t\t\tanswer = nextnei\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\n\t\tvar parent = ipeak\n\t\twhile(depth < n-2 && answer == -1){\n\t\t\t//go depth-1 times from next\n\t\t\tval nextnei = query(next)\n\t\t\tif(nextnei.size == 2){\n\t\t\t\tanswer = next\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//should have size 3\n\t\t\t//pick one\n\t\t\tvar try1 = -1\n\t\t\tvar try2 = -1\n\t\t\tfor(posnei in nextnei){\n\t\t\t\tif(posnei == parent) continue\n\t\t\t\tif(try1 == -1) try1 = posnei\n\t\t\t\telse try2 = posnei\n\t\t\t}\n\t\t\t//println(\"$try1 $try2\")\n\t\t\t//see if try1 works\n\t\t\tif(!test(try1,next,depth)){\n\t\t\t\tparent = next\n\t\t\t\tnext = try1\n\t\t\t} else {\n\t\t\t\tparent = next\n\t\t\t\tnext = try2\n\t\t\t}\n\n\n\t\t\tdepth++\n\t\t}\n\t\tif(answer != -1){\n\t\t\tprintln(\"! $answer\")\n\t\t\tSystem.out.flush()\n\t\t\tcontinue\n\t\t}\n\t\t//on depth 5, ,\n\t\t//get the two nodes\n\n\t\tvar n1 = -1\n\t\tvar n2 = -1\n\n\t\tvar nextneis = query(next)\n\t\tfor(neis in nextneis){\n\t\t\tif(neis == parent) continue\n\t\t\tif(n1 == -1) n1 = neis\n\t\t\telse n2 = neis\n\t\t}\n\n\t\tval possibilities = mutableListOf()\n\t\tval n1neis = query(n1)\n\t\tval n2neis = query(n2)\n\n\t\tfor(n1nei in n1neis){\n\t\t\tif(n1nei == next) continue\n\t\t\tpossibilities.add(n1nei)\n\t\t}\n\t\tfor(n2nei in n2neis){\n\t\t\tif(n2nei == next) continue\n\t\t\tpossibilities.add(n2nei)\n\t\t}\n\n\t\tfor(k in 0 until 3){\n\t\t\tif(query(possibilities[k]).size == 2){\n\t\t\t\tanswer = possibilities[k]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif(answer == -1) answer = possibilities[3]\n\n\t\tprintln(\"! $answer\")\n\t\tSystem.out.flush()\n\n\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5bd02f218d0d000c3d644be3bfdf4458", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "import java.util.ArrayList\nimport java.io.FileInputStream\nimport java.lang.Math.min\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\n\nvar MOD = 1000000007L\n\nfun pwd(a: Long, p: Long) : Long {\n if (p == 0L) {\n return 1 % MOD\n }\n var res = pwd(a, p / 2)\n res = res * res % MOD\n if (p % 2 == 1L) {\n res = res * a % MOD\n }\n return res\n}\n\nvar a = 0\nvar b = 0\nvar h = 0\nvar w = 0\nvar n = 0\n\nfun main(args: Array) {\n if (args.size > 0) {\n input = FileInputStream(args[0])\n }\n h = nextInt()\n w = nextInt()\n a = nextInt()\n b = nextInt()\n n = nextInt()\n var arr = ArrayList();\n for (i in 0..n-1) {\n arr.add(nextInt())\n }\n arr.sort()\n arr.reverse()\n println(solve(arr.take(38)))\n}\n\nfun solve(arr: List): Int {\n var ans = 1234\n ans = min(ans, trySolve(a, b, h, w, arr))\n ans = min(ans, trySolve(b, a, h, w, arr))\n return if (ans == 1234) -1 else ans\n}\n\nfun trySolve(a: Int, b: Int, h: Int, w: Int, arr: List): Int {\n if (h <= a && w <= b) {\n return 0\n }\n var dp = Array(100005) {Array(arr.size + 1) {0}}\n dp[a][0] = b\n for (i in 0..dp.size-1)\n for (j in 0..dp[0].size-2) {\n dp[i][j + 1] = Math.max(dp[i][j + 1], dp[i][j] * arr[j])\n var nextI = i * arr[j]\n if (nextI >= dp.size) {\n nextI = dp.size - 1\n }\n dp[nextI][j+1] = Math.max(dp[nextI][j], dp[i][j])\n }\n var ans = 1234\n for (i in 0..dp.size-1)\n for (j in 0..dp[0].size - 1) {\n if (h <= i && w <= dp[i][j]) {\n ans = min(ans, j)\n }\n }\n return ans\n}\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nvar input = System.`in`\n\nval sb = StringBuilder()\nval buffer = ByteArray(4096)\nvar pos = 0\nvar size = 0\n\nfun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n}\n\nfun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n}\n\nfun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n}\n\nfun nextInt() = nextLong().toInt()\nfun nextDouble() = nextString()?.toDouble() ?: 0.0\nfun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO\nfun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO\n\nprivate fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n}\n\nprivate fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "10e95c441f01fdb16b8bbda5b90131f7", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.ArrayList\nimport java.io.FileInputStream\nimport java.lang.Math.min\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\n\nvar MOD = 1000000007L\n\nfun pwd(a: Long, p: Long) : Long {\n if (p == 0L) {\n return 1 % MOD\n }\n var res = pwd(a, p / 2)\n res = res * res % MOD\n if (p % 2 == 1L) {\n res = res * a % MOD\n }\n return res\n}\n\nvar a = 0\nvar b = 0\nvar h = 0\nvar w = 0\nvar n = 0\n\nfun main(args: Array) {\n if (args.size > 0) {\n input = FileInputStream(args[0])\n }\n h = nextInt()\n w = nextInt()\n a = nextInt()\n b = nextInt()\n n = nextInt()\n var arr = ArrayList();\n for (i in 0..n-1) {\n arr.add(nextInt())\n }\n arr.sort()\n arr.reverse()\n println(solve(arr.take(38)))\n}\n\nfun solve(arr: List): Int {\n var ans = 1234\n ans = min(ans, trySolve(a, b, h, w, arr))\n ans = min(ans, trySolve(b, a, h, w, arr))\n return if (ans == 1234) -1 else ans\n}\n\nfun trySolve(a: Int, b: Int, h: Int, w: Int, arr: List): Int {\n if (h <= a && w <= b) {\n return 0\n }\n var dp = Array(100005) {Array(arr.size + 1) {0}}\n dp[a][0] = b+0L\n for (i in 0..dp.size-1)\n for (j in 0..dp[0].size-2) {\n dp[i][j + 1] = Math.max(dp[i][j + 1], Math.min(1234567, dp[i][j] * arr[j]))\n var nextI = i * arr[j]\n if (nextI >= dp.size) {\n nextI = dp.size - 1\n }\n dp[nextI][j+1] = Math.max(dp[nextI][j], dp[i][j])\n }\n var ans = 1234\n for (i in 0..dp.size-1)\n for (j in 0..dp[0].size - 1) {\n if (h <= i && w <= dp[i][j]) {\n ans = min(ans, j)\n }\n }\n return ans\n}\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nvar input = System.`in`\n\nval sb = StringBuilder()\nval buffer = ByteArray(4096)\nvar pos = 0\nvar size = 0\n\nfun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n}\n\nfun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n}\n\nfun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n}\n\nfun nextInt() = nextLong().toInt()\nfun nextDouble() = nextString()?.toDouble() ?: 0.0\nfun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO\nfun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO\n\nprivate fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n}\n\nprivate fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e67aa7ecd7ef0d533166ae89e64a8aa4", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.ArrayList\nimport java.io.FileInputStream\nimport java.lang.Math.min\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\n\nvar MOD = 1000000007L\n\nfun pwd(a: Long, p: Long) : Long {\n if (p == 0L) {\n return 1 % MOD\n }\n var res = pwd(a, p / 2)\n res = res * res % MOD\n if (p % 2 == 1L) {\n res = res * a % MOD\n }\n return res\n}\n\nvar a = 0\nvar b = 0\nvar h = 0\nvar w = 0\nvar n = 0\n\nfun main(args: Array) {\n if (args.size > 0) {\n input = FileInputStream(args[0])\n }\n h = nextInt()\n w = nextInt()\n a = nextInt()\n b = nextInt()\n n = nextInt()\n var arr = ArrayList();\n for (i in 0..n-1) {\n arr.add(nextLong())\n }\n arr.sort()\n arr.reverse()\n println(solve(arr.take(38)))\n}\n\nfun solve(arr: List): Int {\n var ans = 1234\n ans = min(ans, trySolve(a, b, h, w, arr))\n ans = min(ans, trySolve(b, a, h, w, arr))\n return if (ans == 1234) -1 else ans\n}\n\nfun trySolve(a: Int, b: Int, h: Int, w: Int, arr: List): Int {\n if (h <= a && w <= b) {\n return 0\n }\n val dp = Array(100005) {Array(arr.size + 1) {0}}\n dp[a][0] = b + 0L\n for (i in 0..dp.size - 1) {\n for (j in 0..arr.size - 1) if (dp[i][j] > 0){\n dp[i][j + 1] = Math.max(dp[i][j + 1], Math.min(1234567, dp[i][j] * arr[j]))\n val nextI = min(i * arr[j], dp.size - 1L).toInt()\n dp[nextI][j + 1] = Math.max(dp[nextI][j+1], dp[i][j])\n }\n }\n var ans = 1234\n for (i in 0..dp.size-1) {\n for (j in 0..arr.size) {\n if (h <= i && w <= dp[i][j]) {\n ans = min(ans, j)\n }\n }\n }\n return ans\n}\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nvar input = System.`in`\n\nval sb = StringBuilder()\nval buffer = ByteArray(4096)\nvar pos = 0\nvar size = 0\n\nfun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n}\n\nfun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n}\n\nfun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n}\n\nfun nextInt() = nextLong().toInt()\nfun nextDouble() = nextString()?.toDouble() ?: 0.0\nfun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO\nfun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO\n\nprivate fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n}\n\nprivate fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "16f0dac0bfbe52a113dcf58515ae6b8d", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "fun parse_int(): MutableList {\n return readLine()!!.split(' ').map {x: String -> x.toInt()}.toMutableList()\n}\n\nfun main(args: Array) {\n val inp = readLine()!!.trim()\n var odds = 0\n var vowels = 0\n\n for (c in inp) {\n if (c.isDigit()) {\n odds += c.toInt() % 2\n } else {\n if (c in \"aeiou\") vowels += 1\n }\n }\n\n println(odds + vowels)\n\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4b6d6b18d0fada5f24010c9aa6b28185", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n //println((4 or 6)xor(4 or 5))\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val n = r.readLine()!!.toInt()\n val list = listOf(\"a\", \"e\", \"i\", \"o\", \"u\", \"1\", \"3\", \"5\", \"7\", \"9\")\n val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }.count { it in list }\n println(v)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "67c260f9114819ff3ddeb2f8bde4063a", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val arr = next().toCharArray().filter { it.vowel() }\n print(\"${arr.size}\")\n}\n\nfun Char.vowel(): Boolean {\n val v = arrayListOf('a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9')\n return v.filter { it == this }.any()\n}\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b66a63257a052cd5c5599bc0bcae5bd", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(java.util.Scanner(System.`in`)) {\n var s = readLine()!!\n var (res, entahapa) = s.partition { (it.isDigit() && it.toInt()%2==1) || it == 'a' || it == 'u' || it == 'o' || it == 'i' || it == 'e' }\n println(res.count())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8c1cdf36270d46cc7d2e3dd1316d1a1b", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nprivate val reader = BufferedReader(InputStreamReader(System.`in`))\nprivate val out = PrintWriter(System.out)\nprivate var st = StringTokenizer(\"\")\n\nfun next(): String {\n while (!st.hasMoreTokens())\n st = StringTokenizer(reader.readLine())\n return st.nextToken()\n}\n\nfun ni() = next().toInt()\nfun nl() = next().toLong()\nfun nd() = next().toDouble()\nfun print(obj: Any) = out.print(obj)\nfun close() = out.close()\n\nfun main(args: Array) {\n val text = next()\n val v = setOf('a', 'e', 'i', 'o', 'u')\n val range = 1..10 step 2\n val odd = range.flatMap { n -> listOf(text.filter { (it.toInt()-'0'.toInt()) == n }.count()) }.reduce({ x, y -> x + y });\n print(text.filter { it in v }.count()+odd)\n close()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e792c19649945d49d780ab9964c83793", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n print(readLine()!!.count { c -> c in setOf('a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9') })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "221be905900fbec6a693271ad2318a43", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.*\n\nfun main(args: Array) {\n var vowelsAndEvens = setOf(\n 'a', 'o', 'e', 'u', 'i',\n '1', '3', '5', '7', '9'\n )\n\n var string = readLine() ?: \"\"\n println(string.count { it in vowelsAndEvens })\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a09f1719ecfa750a5e83b9cab1bbb6c8", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() = println(readLine()!!.count { it in \"aeiou13579\" })", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ccc5015158d2969277a9a59f99ce8521", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val a = readLine()!!.trim()\n val voewels = arrayOf('a','e','i','o','u')\n val odds = arrayOf('1','3','5','7','9')\n val r = a.count { it in voewels || it in odds }\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cbcc6ac45a6dd20707324e3ef07a140c", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var a = readLine()!!\n var ans = 0\n for (c in a){\n if (c.isDigit()){\n var cur = ((c.toInt())%2 == 1)\n if(cur){\n ans+=1\n }\n }else {\n if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){\n ans += 1\n }\n }\n }\n println(ans)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c508ac51e6eb49e4250c38b45a6fa548", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val res = next().toCharArray()\n .filter { c -> arrayListOf('a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9')\n .filter { it == c }.any() }.size\n print(res)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c51e219debf02f001c719b1aaea600cd", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val arr = next().toCharArray().filter { it.vowel() }\n print(\"${arr.size}\")\n}\n\nfun Char.vowel(): Boolean {\n val v = arrayListOf('a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8')\n return v.filter { it == this }.any()\n}\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3716e20c88bf8ce9746564f2d2ff3162", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.*\n\nfun main(args: Array) {\n var vowelsAndEvens = setOf(\n 'a', 'o', 'e', 'u', 'i',\n '0', '2', '4', '6', '8')\n\n var string = readLine() ?: \"\"\n println(string.count { it in vowelsAndEvens })\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5dade1d0ca649f3f4d171aad10ae4f48", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val a = readLine()!!.trim()\n val voewels = arrayOf('a','e','i','o','u')\n val evens = arrayOf('0','2','4','6','8')\n val r = a.count { it in voewels || it in evens }\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a7aefa0f4a61e245ebc8c90fe492dc30", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nprivate val reader = BufferedReader(InputStreamReader(System.`in`))\nprivate val out = PrintWriter(System.out)\nprivate var st = StringTokenizer(\"\")\n\nfun next(): String {\n while (!st.hasMoreTokens())\n st = StringTokenizer(reader.readLine())\n return st.nextToken()\n}\n\nfun ni() = next().toInt()\nfun nl() = next().toLong()\nfun nd() = next().toDouble()\nfun print(obj: Any) = out.print(obj)\nfun close() = out.close()\n\nfun main(args: Array) {\n val text = next()\n val v = setOf('a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8')\n print(text.filter { it in v }.count())\n close()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "58c898360d621cbe980607cbfefb7f66", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) = with(java.util.Scanner(System.`in`)) {\n var s = readLine()!!\n var (res, entahapa) = s.partition { (it.isDigit() && it.toInt()%2==0) || it == 'a' || it == 'u' || it == 'o' || it == 'i' || it == 'e' }\n println(res.count())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3791363496ce484dcc06c525e9522d06", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val arr = next().toCharArray().filter { it.vowel() }\n print(\"${arr.size}\")\n}\n\nfun Char.vowel(): Boolean = this == 'a' || this == 'e' || this == 'i' || this == 'o' || this == 'u' || this == 'y'\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9975f110b82a7969a202558068b95fd4", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val vowels = listOf('a', 'e', 'i', 'o', 'u')\n val digits = \"1234567890\".toList()\n val s = Scanner(System.`in`)\n with(s) {\n var total = 0\n nextLine()\n .forEach {\n when (it) {\n in vowels -> {\n total++\n }\n\n in digits -> {\n if (it.toInt() % 2 == 0) {\n total++\n }\n }\n }\n }\n println(total)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7fef48c4ecba3db3385305c85f0af5cd", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextInt()\n\n val a = Array(n) { sc.nextInt() }\n val b = a.sortedArray()\n\n val res = Array(n) { 0 }\n\n for (i in 0 until n) {\n res[a.indexOf(b[(n + i - 1) % n])] = b[i]\n }\n\n println(res.joinToString(\" \"))\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "51d8f9efd93bd43b57953722b5b3769b", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextInt()\n\n val a = Array(n) { sc.nextInt() }\n val b = a.sortedArray()\n\n val res = Array(n) { 0 }\n\n for (i in 0 until n) {\n res[a.indexOf(b[i])] = b[(i + 1) % n]\n }\n\n println(res.joinToString(\" \"))\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a0ae155708dc2533361f1c075d5fd2bd", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (x1, x2) = readInts()\n val n = minOf(x1, x2)\n val m = maxOf(x1, x2)\n val fib = LongArray(m)\n fib[0] = 1\n fib[1] = 1\n for(i in 2 until m) {\n fib[i] = (fib[i - 1] + fib[i - 2]) % mod\n }\n val f0 = LongArray(n + 1)\n f0[1] = fib[m - n + 1]\n for (i in 2..n) {\n f0[i] = (f0[i - 1] + fib[i - 2] + fib[m - n + i - 2]) % mod\n }\n println((f0[n] * 2) % mod)\n}\n\nprivate val mod = 1000000007L\n\nprivate fun readString() = readLine()!!\n\nprivate fun readInt() = readString().toInt()\n\nprivate fun readInts() = readString().split(\" \").map { it.toInt() }\n\nprivate fun readLong() = readString().toLong()\n\nprivate fun readLongs() = readString().split(\" \").map { it.toLong() }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "da02865ede7569c94c6ac837fe1489a9", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.*\nimport java.util.Scanner\n\nval MOD: Long = 1000000000 + 7\nvar fibs: HashMap = HashMap()\n\nfun countFib(n: Int): Long {\n if (fibs.containsKey(n)) {\n return fibs[n]!!\n }\n if (n <= 0) {\n fibs[n] = 1\n return 1\n }\n\n fibs[n] = countFib(n - 1) + countFib(n - 2)\n return fibs[n]!!\n}\n\nfun F(n: Int, m: Int) : Long {\n // n >= m\n if (m == 1) {\n return (countFib(n - 1) + countFib(n - 1)) % MOD\n }\n\n var ans: Long = 0\n ans = (ans + countFib(m - 3)) % MOD\n ans = (ans + countFib(n - 3)) % MOD\n for (i in 2 until n) {\n if (n - i - 1 >= 0) {\n ans = (ans + countFib(n - i - 1)) % MOD\n }\n }\n\n ans = (ans + countFib(m - 2)) % MOD\n return (ans + ans) % MOD\n}\n\nfun main(args: Array) {\n fibs[0] = 1\n fibs[-1] = 1\n for (i in 1 until 100000 + 1) {\n fibs[i] = fibs[i - 1]!! + fibs[i - 2]!!\n }\n\n val input = Scanner(System.`in`)\n val n = input.nextInt()\n val m = input.nextInt()\n\n val ans = F(max(n, m), min(n, m))\n println(ans)\n// for (v in fibs) {\n// println (v.key.toString() + \" \" + v.value.toString())\n// }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4c24cb35eb24c09e4db667a6ec761080", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.*\nimport java.util.Scanner\n\nval MOD: Long = 1000000000 + 7\nvar fibs: HashMap = HashMap()\n\nfun countFib(n: Int): Long {\n if (fibs.containsKey(n)) {\n return fibs[n]!!\n }\n if (n <= 0) {\n fibs[n] = 1\n return 1\n }\n\n fibs[n] = countFib(n - 1) + countFib(n - 2)\n return fibs[n]!!\n}\n\nfun F(n: Int, m: Int) : Long {\n // n >= m\n if (m == 1) {\n return (countFib(n - 1) + countFib(n - 1)) % MOD\n }\n\n var ans: Long = 0\n ans = (ans + countFib(m - 3)) % MOD\n ans = (ans + countFib(n - 3)) % MOD\n for (i in 2 until n) {\n ans = (ans + countFib(n - i - 2)) % MOD\n }\n\n ans = (ans + countFib(m - 2)) % MOD\n return (ans + ans) % MOD\n}\n\nfun main(args: Array) {\n fibs[0] = 1\n fibs[-1] = 1\n for (i in 1 until 100000 + 1) {\n fibs[i] = fibs[i - 1]!! + fibs[i - 2]!!\n }\n\n val input = Scanner(System.`in`)\n val n = input.nextInt()\n val m = input.nextInt()\n\n val ans = F(max(n, m), min(n, m))\n println(ans)\n// for (v in fibs) {\n// println (v.key.toString() + \" \" + v.value.toString())\n// }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a565788998b330a2469970992e6f6364", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.*\nimport java.util.Scanner\n\nval MOD: Long = 1000000000 + 7\nvar fibs: HashMap = HashMap()\n\nfun createMod(n : Long) : Long {\n return (n + MOD) % MOD\n}\n\nfun countFib(n: Int): Long {\n if (fibs.containsKey(n)) {\n return fibs[n]!!\n }\n if (n <= 0) {\n fibs[n] = 1\n return 1\n }\n\n fibs[n] = countFib(n - 1) + countFib(n - 2)\n return fibs[n]!!\n}\n\nfun F(n: Int, m: Int) : Long {\n // n >= m\n if (m == 1) {\n return createMod(countFib(n - 1) + countFib(n - 1))\n }\n\n var ans: Long = 0\n ans = createMod(ans + countFib(m - 3))\n ans = createMod(ans + countFib(n - 3))\n for (i in 2 until n) {\n ans = createMod(ans + countFib(n - i - 2))\n }\n\n ans = createMod(ans + countFib(m - 2))\n return (ans + ans) % MOD\n}\n\nfun main(args: Array) {\n fibs[0] = 1\n fibs[-1] = 1\n for (i in 1 until 100000 + 1) {\n fibs[i] = createMod (fibs[i - 1]!! + fibs[i - 2]!!)\n }\n\n val input = Scanner(System.`in`)\n val n = input.nextInt()\n val m = input.nextInt()\n\n val ans = F(max(n, m), min(n, m))\n println(ans)\n// for (v in fibs) {\n// println (v.key.toString() + \" \" + v.value.toString())\n// }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b8fb882b14da4bf6f2f4f6e4bd78ef7a", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport java.util.TreeSet\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln // immediate println for interactive\n\nfun main() {\n output {\n val n = readInt()\n val m = readInt()\n\n val F = ModIntArray(max(n, m) + 1)\n F[0] = ModInt(1)\n F[1] = ModInt(1)\n\n for(i in 2..F.lastIndex) {\n F[i] = F[i-1] + F[i-2]\n }\n\n val ans = (F[n] + F[m] - 1) * 2\n\n println(ans)\n }\n}\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\nconst val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt(this umod MODINT_BASE)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n inline operator fun plus(other: ModInt) = plus(other.int) // MODINT_BASE < 2^30\n inline operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n inline operator fun inc() = plus(1)\n\n inline operator fun minus(other: ModInt) = minus(other.int)\n inline operator fun minus(other: Int) = (int - other).toModInt()\n inline operator fun dec() = minus(1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) exponent umod MODINT_TOTIENT else exponent\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n fun pow(exponent: Long) = pow(exponent umod MODINT_TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override fun contains(element: ModInt): Boolean = any { it == element }\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun Iterable.sum() = fold(ModInt(0), ModInt::plus)\nfun Sequence.sum() = fold(ModInt(0), ModInt::plus)\nfun Iterable.product() = fold(ModInt(1), ModInt::times)\nfun Sequence.product() = fold(ModInt(1), ModInt::times)\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9796c5a2835428d40cc72681700c2b1c", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = Array(100005) { 0 }\n val mod = 1000000007\n a[1] = 2\n a[2] = 4\n for (i in 3..100000) {\n a[i] = a[i - 1] + a[i - 2]\n a[i] %= mod\n }\n println((a[n] + a[m] - 2) % mod)\n}\n\nfun main(args: Array) {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2e8ac80deb2a6c0fd71482e4efc2082f", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readInts() = readLn().split(\" \").map{it.toInt()}\n\n\nval MOD = 1000000007;\n\nfun main(args: Array) {\n\tvar (n,m) = readInts()\n\tvar sz = IntArray(maxOf(n,m,10)+1)\n\tsz[0]=1\n\tsz[1]=1\n\tfor(i in 2..sz.size-1) {\n\t\tsz[i]=(sz[i-1]+sz[i-2])%MOD\n\t}\n\tprintln(2L*((sz[n]+sz[m])%MOD+MOD-1)%MOD)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7519a466cdd58959c6b2b57f72cf180b", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport kotlin.concurrent.thread\nimport java.io.IOException\nimport java.io.BufferedReader\nimport java.io.InputStream\nimport kotlin.*\nimport java.*\nimport java.io.OutputStream\nimport java.io.PrintWriter\nimport java.lang.ArithmeticException\nimport java.lang.Exception\nimport java.math.BigInteger\nimport java.security.cert.TrustAnchor\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\nimport kotlin.system.exitProcess\n\nfun main() {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val mod = 1000*1000*1000+7\n\n fun add(a:Int,b:Int):Int{\n if (a+b>=mod)\n return a+b-mod\n return a+b\n }\n fun sub(a:Int,b:Int):Int{\n if (a>=b)\n return a-b\n return a-b+mod\n }\n\n fun mul(a:Int,b:Int):Int{\n return (a.toLong()*b.toLong()%mod).toInt()\n }\n\n val n=`in`.nextInt()\n val m=`in`.nextInt()\n\n val dp=IntArray(n+1)\n dp[0]=1\n dp[1]=1\n for (i in 2..n){\n dp[i]=add(dp[i-1],dp[i-2])\n }\n val dp2=IntArray(m+1)\n dp2[0]=1\n dp2[1]=1\n for (i in 2..m){\n dp2[i]=add(dp2[i-1],dp2[i-2])\n }\n\n out.println(mul(2,sub(add(dp[n],dp2[m]),1)))\n\n out.close()\n\n}\n\n\ninternal class InputReader(stream: InputStream) {\n var reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return next().toLong()\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c10e8554ab07d85b1a32205c7bf9bc66", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val m = readInt()\n\n val ans = (fibonacci(n+1) + fibonacci(m+1) - 1) * 2\n\n println(ans)\n}\n\nfun fibonacci(n: Long): ModInt {\n var a = ModInt(0)\n var b = ModInt(1)\n var c = ModInt(0)\n var d = ModInt(1)\n\n var e = n\n while(e > 0) {\n if(e and 1 == 1L) {\n a = (a * c + b * d).also {\n b = a * d + b * (c + d)\n }\n }\n e = e shr 1\n c = (c * c + d * d).also {\n d *= c + c + d\n }\n }\n\n return a\n}\ninline fun fibonacci(n: Int) = fibonacci(n.toLong())\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MOD = BILLION7\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.umod(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.umod(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.umod(mod: Int) = umod(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other umod mod\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MOD)\ninline fun Long.toModInt() = ModInt(this umod MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent umod TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent umod TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n//@JvmField var _random: Random? = null\nval random = Random(0x594E215C123 * System.nanoTime())\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e3aabb1601f88fa73cc66bc8253a7ecc", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n val digitToOptions = listOf(2, 7, 2, 3, 3, 4, 2, 5, 1, 2)\n// print(readLine()!!.fold(1) { acc, c -> acc * digitToOptions[c - '0'] }) // A shorter alternative, less readable\n var sol = 1\n for (c in readLine()!!) sol *= digitToOptions[c - '0']\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a0435dcdfbe663544896fda18de85837", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nprivate val MOD = 1e9.toInt() + 7\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val a = nextInts(n)\n val dpA = IntArray(n + 1)\n val dpB = IntArray(n + 1)\n\n (1..n).forEach {\n val i = n - it\n dpA[it] = Math.max(a[i] + dpB[it - 1], dpA[it - 1])\n dpB[it] = Math.min(a[i] + dpB[it - 1], dpA[it - 1])\n }\n\n val alice = dpB[n]\n val bob = a.sum() - dpB[n]\n println(\"$alice $bob\")\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = nextString()?.toDouble() ?: 0.0\n\n fun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n\n fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4988cd198c32ddbb48c79211d52df115", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun fac(i: Long): Set {\n val a = mutableSetOf()\n (1..sqrt(i.toDouble()).toInt()).forEach {\n if (i % it == 0L) {\n a += it.toLong()\n a += i / it\n }\n }\n return a\n }\n\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n // i : num to res\n val dp = Array(len) { mutableMapOf() }\n fun f(n: Long, i: Int): Long {\n var ans = 0L\n when {\n dp[i].containsKey(n) -> return dp[i][n]!!\n i == 0 -> {\n dp[i][n] = 1\n return dp[i][n]!!\n }\n else -> {\n val fac = fac(n)\n fac.forEach {\n ans += f(n/it, i-1)\n }\n }\n }\n dp[i][n] = ans%b\n return dp[i][n]!!\n }\n println((1..max).fold(0L){acc, i -> (acc + f(i.toLong(), len-1)%b) })\n /*repeat(r.readLine()!!.toInt()) {\n val len = r.readLine()!!.toInt()\n val v1 = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n }*/\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "20c3477100bdb3c0632021b09913cb01", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun fac(i: Int): Set {\n val a = mutableSetOf()\n if (i%2==0) {\n a+=2\n a+=i/2\n }\n (1..sqrt(i.toDouble()).toInt() step 2).forEach {\n if (i % it == 0) {\n a += it\n a += i / it\n }\n }\n return a\n }\n\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n // i : num to res\n val dp = Array(len) { LongArray(max + 1) { -1 } }\n fun f(n: Int, i: Int): Long {\n var ans = 0L\n when {\n dp[i][n] != -1L -> {\n return dp[i][n]\n }\n i == 0 -> {\n dp[i][n] = 1\n ans++\n }\n else -> {\n val fac = fac(n)\n fac.forEach {\n ans += f(n / it, i - 1)\n }\n }\n }\n dp[i][n] = ans % b\n return dp[i][n]\n }\n println((1..max).fold(0L) { acc, i -> (acc + f(i, len - 1)) % b })\n /*repeat(r.readLine()!!.toInt()) {\n val len = r.readLine()!!.toInt()\n val v1 = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n }*/\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fd5ba74bc7569b3af26183b0d15e8aa7", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun fac(i: Int): List {\n val a = mutableListOf()\n /*var n = i\n var base = 2\n while (n>0&&n%2==0){\n a+=base\n a+=i/base\n n/=2\n base*=2\n }*/\n (1..sqrt(i.toDouble()).toInt()).forEach {\n if (i % it == 0) {\n a += it\n if (i / it > it)\n a += i / it\n }\n }\n return a\n }\n //println(fac(12))\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n // i : num to res\n val dp = Array(len) { LongArray(max + 1) { -1 } }\n fun f(n: Int, i: Int): Long {\n var ans = 0L\n when {\n dp[i][n] != -1L -> {\n return dp[i][n]\n }\n i == 0 -> {\n dp[i][n] = 1\n ans++\n }\n else -> {\n val fac = fac(n)\n fac.forEach {\n ans += f(n / it, i - 1)\n }\n }\n }\n dp[i][n] = ans % b\n return dp[i][n]\n }\n println((1..max).fold(0L) { acc, i -> (acc + f(i, len - 1)) % b })\n /*repeat(r.readLine()!!.toInt()) {\n val len = r.readLine()!!.toInt()\n val v1 = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n }*/\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "de24a3e08ccec34cd4c3f6e27b7e0476", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun fac(i: Int): Pair, Int> {\n val a = MutableList(i) { -1 }\n var num = 0\n (1..sqrt(i.toDouble()).toInt()).forEach {\n if (i % it == 0) {\n a[num++] = it\n if (i / it > it)\n a[num++] = i / it\n }\n }\n return Pair(a, num)\n }\n\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n // i : num to res\n val dp = Array(len) { LongArray(max + 1) { -1 } }\n fun f(n: Int, i: Int): Long {\n var ans = 0L\n when {\n dp[i][n] != -1L -> {\n return dp[i][n]\n }\n i == 0 -> {\n dp[i][n] = 1\n ans++\n }\n else -> {\n val (fac, num) = fac(n)\n for (j in 0..num-1){\n ans += f(n / fac[j], i - 1)\n }\n }\n }\n dp[i][n] = ans % b\n return dp[i][n]\n }\n println((1..max).fold(0L) { acc, i -> (acc + f(i, len - 1)) % b })\n /*repeat(r.readLine()!!.toInt()) {\n val len = r.readLine()!!.toInt()\n val v1 = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n }*/\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6a7c5752d91a7976735032aa6d072aba", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun fac(i: Long): Set {\n val a = mutableSetOf()\n (1..sqrt(i.toDouble()).toInt()).forEach {\n if (i % it == 0L) {\n a += it.toLong()\n a += i / it\n }\n }\n return a\n }\n\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n //val v = r.readLine()!!.split(\"\").filter { it.isNotEmpty() }\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n // i : num to res\n val dp = Array(len) { mutableMapOf() }\n fun f(n: Long, i: Int): Long {\n var ans = 0L\n when {\n dp[i].containsKey(n) -> return dp[i][n]!!\n i == 0 -> {\n dp[i][n] = 1\n return dp[i][n]!!\n }\n else -> {\n val fac = fac(n)\n fac.forEach {\n ans += f(n/it, i-1)\n }\n }\n }\n dp[i][n] = ans%b\n return dp[i][n]!!\n }\n println((1..max).fold(0L){acc, i -> (acc + f(i.toLong(), len-1))%b })\n /*repeat(r.readLine()!!.toInt()) {\n val len = r.readLine()!!.toInt()\n val v1 = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n }*/\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f553560fc6bcaedfdd51f6efef02285", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.max\n\nfun main(args : Array) {\n Thread { run() }.start()\n}\n\nfun run() {\n\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n val arr = LongArray(n + 1) { 1L }\n var mod = 1000000007L\n val help = Array(n + 1) {\n if (it < 2)\n return@Array intArrayOf()\n val a = ArrayList()\n var i = 2\n while (i * i <= it) {\n if (it % i == 0) {\n a.add(i)\n if (i * i != it)\n a.add(it / i)\n }\n i++\n }\n a.add(1)\n a.toIntArray()\n }\n for (i in 1 until k) {\n for (j in 2..n) {\n for (q in help[j]) {\n arr[q] += arr[j]\n arr[q] %= mod\n }\n }\n }\n var res = 0L\n for (i in 1..n) {\n res += arr[i]\n res %= mod\n }\n println(res)\n\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\nfun IntArray.print() {\n println(Arrays.toString(this))\n}\n\nfun Array.print() {\n for (i in this)\n i.print()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e5dd18ee584b759c8829ea97ef1c0a22", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val b = 1000000007L\n val (max, len) = r.readLine()!!.split(\" \").map { it.toInt() }\n\n val dp = Array(len) { LongArray(max + 1) { 0L } }\n for (k in 1..max) {\n dp[0][k] = 1\n }\n for (i in 0..len - 2) {\n for (n in 1..max) {\n var time = 1\n while (n * time <= max) {\n dp[i + 1][n * time] = (dp[i + 1][n * time] + dp[i][n]) % b\n time++\n }\n }\n }\n println(dp[len-1].sum()%b)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94bb051db6c86931bdf78c9f3d9edc2b", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b) = readLine()!!.split(\" \")\n println(if (a==b) a else \"1\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "95cc78e28bf40f41a7e512a469fd721d", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \")\n println( if (a == b) a else \"1\" )\n }\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3102edd09eeb169665a62d411bfaaa4f", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val (a, b) = readLine()!!.split(\" \")\n println(if (a == b) a else \"1\")\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1e0a2370c1eb3908b4181c3e32d3def4", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\n/* template start */\n// input\nprivate fun readString() = readLine()!!\nprivate fun readStrings() = readString().split(\" \")\nprivate fun readInt() = readString().toInt()\nprivate fun readDigits() = readString().map { it - '0' }\nprivate fun readInts() = readStrings().map { it.toInt() }\nprivate fun readLongs() = readStrings().map { it.toLong() }\n\n// output\nprivate fun T.print(map: (T) -> String = { it.toString() }) = println(map(this))\nprivate fun Iterable.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)\nprivate fun Array.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)\nprivate fun IntArray.print(sep: String? = null, map: ((Int) -> String)? = null) = asSequence().print(sep, map)\nprivate fun Sequence.print(sep: String? = null, map: ((T) -> String)? = null) =\n println(joinToString(sep ?: \"\", transform = map ?: { it.toString() }))\n\n// others\nprivate val Int.isEven: Boolean get() = this % 2 == 0\nprivate val Int.isOdd: Boolean get() = !this.isEven\nprivate fun queries(block: (Int) -> Unit) = repeat(readInt(), block)\n\n/* template end */\n\nfun main() {\n val n = readInt()\n val maxRank = readInts().max()!!\n println(max(0, maxRank - 25))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1c3bf539bd47254bf2baa835c4351c7c", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun min(a:Double,b:Double) = if (ab) a else b \nfun min(a:Int,b:Int) = if (ab) a else b \nfun printD(d: Double) { print(d) }\nfun printI(d:Int) { print(d) }\nfun printS(d: String) { print(d) }\nfun printL(d: Long) { print(d) }\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readInts() = readLn().split(\" \").map{it.toInt()}\nfun readLong() = readLn().toLong()\nclass pair (var first:Int, var second:Int) \n \nfun solve() {\n val cin = Scanner(System.`in`)\n \n /* \n map[q] <=> map.getOrDefault(q,0) \n \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0430\u0440 - k=v.sortedWith(compareBy({it.first},{it.second})); \n print(\"${k[i].second}\"); - \u0432\u044b\u0432\u043e\u0434 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0430\u0440\u044b \n var m=ArrayList (); <=> vector \n getline(cin,a) <=> readLine()!!.last()\n \n readInt() - \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \n readInts() - \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b \n \n */ \n \n \n \n /* --------- */ \n \nvar a=readInt();\nvar q=readInts();\nvar max1=0; \nfor (i in q) {max1=max(max1,i)}; \nif (max1<=25) print(\"0\"); else print(max1-25); \n /* --------- */ \n \n}\n \n fun main() {\n val cin = Scanner(System.`in`)\n \n var T=1; \n //T=readLine()!!.toInt(); \n \n for (i55555 in 1..T) solve()\n}\n ", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "82adf3a50e968de6a8ac2cdf9c4531f9", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n\nfun main(args: Array) {\n var scan: Scanner = Scanner(System.`in`);\n var max: Int = 0;\n var n: Int = scan.nextInt()-1;\n for (i in 0..n) {\n var finalist: Int = scan.nextInt();\n if (finalist > max) {\n max = finalist;\n }\n }\n var out: Int = if (max > 25) { max - 25 } else { 0 };\n System.out.println(out);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ae1d161deba777a6719cf386b167d744", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n readInt()\n println(max(25, readInts().maxOrNull()!!) - 25)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b8f940ea67eb4e2f2f1753e39dd4280", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.IOException\nimport java.io.PrintWriter\nimport java.util.*;\n\nfun main() {\n val scan = FastReader()\n val out = PrintWriter(System.out)\n\n var k = scan.nextInt()\n var ans = 0\n for(i in 1..k) ans = Math.max(ans, scan.nextInt())\n out.println(Math.max(0, ans - 25))\n\n out.close()\n}\n\nprivate class FastReader {\n var st: StringTokenizer? = null;\n\n fun next(): String {\n while(st == null || !st!!.hasMoreTokens()) {\n try {\n st = StringTokenizer(readLine()!!)\n }\n catch (e: IOException) {\n e.printStackTrace()\n }\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return next().toInt()\n }\n\n fun nextLong(): Long {\n return next().toLong()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = readLine()!!\n }\n catch (e : IOException) {\n e.printStackTrace()\n }\n return str\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fca9000b69a8a29f615e8268978f92fc", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n print(max(0, readInts().max()!! - 25))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a02739292319dc6cc5e6288aad50b71b", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nprivate val MOD = 1e9.toInt() + 7\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val a = nextInts(n)\n val max = a.max()!!\n println(Math.max(0, max - 25))\n}\n\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = nextString()?.toDouble() ?: 0.0\n\n fun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n\n fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2eafc2205619b6cfd47b607be8e0d6f8", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import utils.io.FastScanner\n\nprivate val MOD = 1e9.toInt() + 7\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val a = nextInts(n)\n val max = a.max()!!\n println(Math.max(0, max - 25))\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "96e0a4794e2b10ee77e8e66a9a768f96", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.exp\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single Int\nprivate fun readInts() = readStrings().map { it.toInt() } // list of Ints\nprivate fun readStrings() = readLn().trim().split(\" \") // list of strings\n\n\nfun dfs(\n start: Int,\n friends: Map>,\n dislike: Map>,\n seen: MutableSet\n): Pair {\n val visited = mutableSetOf()\n val stack = ArrayDeque()\n stack.add(start)\n seen.add(start)\n visited.add(start)\n val bad = dislike[start] ?: mutableSetOf()\n while (stack.isNotEmpty()) {\n val node = stack.pop()\n for (neb in friends[node] ?: mutableListOf()) {\n if (neb in bad) {\n return Pair(false, -1)\n } else if (neb !in visited) {\n visited.add(neb)\n seen.add(neb)\n bad.addAll(dislike[neb] ?: mutableSetOf())\n stack.add(neb)\n }\n }\n }\n return Pair(true, visited.size)\n}\n\n\nfun main(args: Array) {\n val n = readInt()\n val pairs = readInt()\n val friends = mutableMapOf>()\n val dislike = mutableMapOf>()\n for (i in 0 until pairs) {\n val (u, v) = readInts()\n friends.computeIfAbsent(u) { mutableListOf() }\n friends.computeIfAbsent(v) { mutableListOf() }\n\n friends[u]!!.add(v)\n friends[v]!!.add(u)\n }\n val x = readInt()\n for (i in 0 until x) {\n val (u, v) = readInts()\n dislike.computeIfAbsent(u) { mutableSetOf() }\n dislike.computeIfAbsent(v) { mutableSetOf() }\n dislike[u]!!.add(v)\n }\n var res = 0\n val seen = mutableSetOf()\n for (i in 1 until n + 1) {\n if (i !in seen) {\n val p = dfs(i, friends, dislike, seen)\n if (p.first) {\n res = Math.max(res, p.second)\n }\n }\n }\n println(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2cfc7c0918a5e868fe7de603af04ba9b", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"c.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextPair() = nextInt() to nextInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val (n,m) = nextPair()\n val k = nextLong()\n val (x,y) = nextPairDec()\n val p = (n-1) * m\n if (n == 1) {\n val d = k / m\n val rem = k % m\n val max = d + (if (rem > 0) 1 else 0)\n val min = d\n val cnt = d + if (rem > y) 1 else 0\n fout.print(\"$max $min $cnt\")\n } else {\n val d = k / p\n val rem = k % p\n val max = if (n == 2) ((d+1)/2 + if (d % 2 == 0L && rem > 0) 1 else 0) else d + (if (d == 0L || rem > m) 1 else 0)\n val min = d / 2 + (if (d % 2 == 1L || rem >= m) 1 else 0)\n val x1 = if (d % 2 == 0L) x else n - x - 1\n var cnt = if (x1 == 0) d/2 else if (x1 == n-1) (d+1)/2 else d\n// println(\"$x $y\")\n if (x1 * m + y + 1 <= rem)\n cnt++\n fout.print(\"$max $min $cnt\")\n }\n\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e5ac1a0b0bc2205382c197b8d63138cc", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"c.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextPair() = nextInt() to nextInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val (n,m) = nextPair()\n val k = nextLong()\n val (x,y) = nextPairDec()\n val p = (n-1) * m\n if (p == 0) {\n val d = k / m\n val rem = k % m\n val max = d + (if (rem > 0) 1 else 0)\n val min = d\n val cnt = d + if (rem > y) 1 else 0\n fout.print(\"$max $min $cnt\")\n } else {\n val d = k / p\n val rem = k % p\n val max = d + (if (d == 0L || rem > m) 1 else 0)\n val min = d / 2 + (if (d % 2 == 1L || rem >= m) 1 else 0)\n val (x1,y1) = if (d % 2 == 0L) (x to y) else (n - x - 1 to y)\n var cnt = if (x1 == 0) d/2 else if (x1 == n-1) (d+1)/2 else d\n// println(\"$x $y\")\n if (x1 * m + y1 + 1 <= rem)\n cnt++\n fout.print(\"$max $min $cnt\")\n }\n\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d679539d45157c62b8be4f279da8809b", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"c.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextPair() = nextInt() to nextInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val (n,m) = nextPair()\n val k = nextLong()\n val (x,y) = nextPairDec()\n val p = (n-1) * m\n if (n == 1) {\n val d = k / m\n val rem = k % m\n val max = d + (if (rem > 0) 1 else 0)\n val min = d\n val cnt = d + if (rem > y) 1 else 0\n fout.print(\"$max $min $cnt\")\n } else {\n val d = k / p\n val rem = k % p\n val max = if (n == 2) (d/2 + if (d % 2 == 1L || rem > 0) 1 else 0) else d + (if (d == 0L || rem > m) 1 else 0)\n val min = d / 2 + (if (d % 2 == 1L && rem >= m) 1 else 0)\n val x1 = if (d % 2 == 0L) x else n - x - 1\n var cnt = if (x1 == 0) d/2 else if (x1 == n-1) (d+1)/2 else d\n// println(\"$x $y\")\n if (x1 * m + y + 1 <= rem)\n cnt++\n fout.print(\"$max $min $cnt\")\n }\n\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "463c46a73b2cfdecc15c0c75a6a2e8bf", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Kotlin 1.4", "source_code": "\nimport java.io.BufferedInputStream\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.system.measureTimeMillis\n\ninline fun TIME(f:()->Unit){\n val t = measureTimeMillis(){\n f()\n }\n println(\"$t ms\")\n}\n\nobject IO{\n private const val BS = 1 shl 16\n private const val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n\n var warningActive = true\n var fakein = StringBuilder()\n\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\n val OUT: PrintWriter = PrintWriter(System.out)\n\n private val char: Char\n get() {\n while (bId == size) {\n size = IN.read(buf) // no need for checked exceptions\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextLong(): Long {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0L\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextString():String{\n val ret = StringBuilder()\n while (true){\n c = char\n if(!isWhitespace(c)){ break}\n }\n ret.append(c)\n while (true){\n c = char\n if(isWhitespace(c)){ break}\n ret.append(c)\n }\n return ret.toString()\n }\n fun isWhitespace(c:Char):Boolean{\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\n }\n fun rerouteInput(){\n if(warningActive){\n put(\"You forgot to disable tests you digital dummy!\")\n println(\"You forgot to disable tests you digital dummy!\")\n warningActive = false\n }\n val S = fakein.toString()\n println(\"New Case \")\n println(S.take(80))\n println(\"...\")\n fakein.clear()\n IN = BufferedInputStream(S.byteInputStream(),BS)\n }\n fun takeFile(name:String){\n IN = BufferedInputStream(File(name).inputStream(),BS)\n }\n}\nfun put(aa:Any){ IO.OUT.println(aa)}\nfun done(){ IO.OUT.close() }\nfun share(aa:Any){\n if(aa is IntArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is LongArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is List<*>){IO.fakein.append(aa.toString())}\n else{IO.fakein.append(aa.toString())}\n IO.fakein.append(\"\\n\")\n}\n\nval getint:Int get() = IO.nextInt()\nval getlong:Long get() = IO.nextLong()\nval getstr:String get() = IO.nextString()\nfun getline(n:Int):IntArray{\n return IntArray(n){getint}\n}\nfun getlineL(n:Int):LongArray{\n return LongArray(n){getlong}\n}\nfun getbinary(n:Int, asTrue:Char):BooleanArray{\n val str = getstr\n return BooleanArray(n){str[it] == asTrue}\n}\n\nval List.ret:String\nget() = this.joinToString(\"\")\nvar dmark = -1\ninfix fun Any.dei(a:Any){\n //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators\n dmark++\n var str = \"<${dmark}> \"\n debug()\n if(this is String){ str += this\n }else if(this is Int){ str += this.toString()\n }else if(this is Long){ str += this.toString()\n }else{ str += this.toString()}\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\n }else if(a is Array<*>){\n println(\"$str : \")\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\n else if(c is LongArray){println(c.joinToString(\" \"))}\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\n }\n\n }\n println()\n }else{ println(\"$str : $a\")\n }\n}\nval just = \" \" // usage: just dei x , where x is the debug variable\nfun crash(){\n throw Exception(\"Bad programme\")} // because assertion does not work\nfun assert(a:Boolean){\n if(!a){\n throw Exception(\"Failed Assertion\")\n }}\nenum class solveMode {\n real, rand, tc\n}\nobject solve{\n var mode:solveMode = solveMode.real\n var tcNum:Int = 0\n var rand:()->Unit = {}\n var TC:MutableMapUnit> = mutableMapOf()\n var answersChecked = 0\n var tn:Long = 0\n fun cases(onecase:()->Unit){\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\n //safety checks\n if(pI != 998_244_353 && pI != 1_000_000_007){\n throw Exception(\"Modding a wrong prime!\")\n }\n if(withBruteForce){\n println(\"Brute force is active\")\n }\n\n if(t == 1 && mode != solveMode.real){\n tn = System.currentTimeMillis()\n }\n repeat(t){\n if(mode == solveMode.tc){\n TC[tcNum]?.let { it() }\n IO.rerouteInput()\n }else if(mode == solveMode.rand){\n rand()\n IO.rerouteInput()\n }\n onecase()\n }\n if(t == 1 && mode != solveMode.real){\n val dt = System.currentTimeMillis() - tn\n println(\"Time $dt ms \")\n }\n }\n inline fun singleCase(a:solve.()->Unit){\n val t = if(mode != solveMode.rand){1} else randCount\n repeat(t) { a() }\n }\n fun rand(a:()->Unit){\n this.rand = a\n }\n fun tc(id:Int = 0,a:()->Unit){\n TC[id] = a\n }\n fun usetc(a:Int = 0 ){\n this.tcNum = a\n this.mode = solveMode.tc\n }\n fun userand(){\n this.mode = solveMode.rand\n }\n}\ninline fun T.alsoBrute(cal:() -> T){\n if(!withBruteForce) return\n val also = cal()\n if(this != also){\n println(\"Checking failed: Got ${this} Brute ${also}\")\n crash()\n }\n}\n// 1. Modded\nconst val p = 998244353L\nconst val pI = p.toInt()\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\ninfix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\n// 2. DP initial values\nconst val plarge = 1_000_000_727\nconst val nlarge = -plarge\nconst val phuge = 2_727_000_000_000_000_000L\nconst val nhuge = -phuge\n// 3. conveniecen conversions\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\n//3. hard to write stuff\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\nval mint:MutableList get() = mutableListOf()\nval mong:MutableList get() = mutableListOf()\n//4. more outputs\nfun List.conca():String = this.joinToString(\"\")\nval CharArray.conca :String get() = this.joinToString(\"\")\nval IntArray.conca :String get() = this.joinToString(\" \")\n@JvmName(\"concaInt\")\nfun List.conca():String = this.joinToString(\" \")\nval LongArray.conca:String get() = this.joinToString(\" \")\n@JvmName(\"concaLong\")\nfun List.conca():String = this.joinToString(\" \")\n//5. Pair of ints\nconst val longmask = (1L shl 32) - 1\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\nval Long.first get() = (this ushr 32).toInt()\nval Long.second get() = this.toInt()\n//6. strings\nval String.size get() = this.length\nconst val randCount = 100\n\n\n\ninfix fun Int.divCeil(b:Int):Int{\n //Positives numbers only!\n if(this == 0) {\n return 0\n }\n return (this-1)/b + 1\n}\ninfix fun Long.divCeil(b:Long):Long{\n //Positives numbers only!\n if(this == 0L) {\n return 0\n }\n return (this-1)/b + 1\n}\n\ninfix fun Long.modM(b:Long):Long{\n return (this * b) % p\n}\n//infix fun Int.modPlus(b:Int):Int{\n// val ans = this + b\n// return if(ans >= pI) ans - pI else ans\n//}\ninfix fun Int.modMinus(b:Int):Int{\n val ans = this - b\n return if(ans < 0) ans + pI else ans\n}\ninfix fun Int.modDivide(b:Int):Int{\n return this modM (b.inverse())\n}\nfun Int.additiveInverse():Int{\n return if(this == 0) 0 else pI - this\n}\n\n\nfun intPow(x:Int,e:Int,m:Int):Int{\n var X = x\n var E =e\n var Y = 1\n while(E > 0){\n if(E % 2 == 0){\n X = ((1L * X * X) % m).toInt()\n E = E shr 1\n }else{\n Y = ((1L * X * Y) % m).toInt()\n E -= 1\n }\n }\n return Y\n}\nfun intPowEXP(x:Int,e:Long,m:Int):Int{\n var X = x\n var E =e\n var Y = 1\n while(E > 0){\n if(E % 2 == 0L){\n X = ((1L * X * X) % m).toInt()\n E = E shr 1\n }else{\n Y = ((1L * X * Y) % m).toInt()\n E -= 1\n }\n }\n return Y\n}\n\nfun pow(x:Long,e:Long,m:Long):Long{\n var X = x\n var E =e\n var Y = 1L\n while(E > 0){\n if(E % 2 == 0L){\n X = (X * X) % m\n E /= 2\n }else{\n Y = (X * Y) % m\n E -= 1\n }\n }\n return Y\n}\nfun Long.inverse():Long{\n return pow(this,p-2,p)\n}\nfun Int.inverse():Int{\n return intPow(this,pI-2,pI)\n}\nfun min_rem(m:Int, r:Int, c:Int):Int {\n if(c < 1){\n return Int.MIN_VALUE\n }else if(r == 0){\n return 0\n }else{\n val step = m % r\n val mx = ((1L * c * r) /m ).toInt()\n val t = max_rem(r,step,mx)\n return r- t\n }\n}\nfun max_rem(m:Int, r:Int, c:Int):Int {\n if(r == 0|| c <= m/r){\n return r * c\n }else{\n val step = m % r\n val mx = ((1L * (c+1) * r )/m).toInt()\n val t = min_rem(r,step,mx)\n return m - t\n }\n}\nfun Int.reconstruct():String{\n val num = min_rem(pI,this, 10000)\n val denom = (this modDivide num).inverse()\n return \"$num / $denom\"\n}\n\n//make this int instead\nclass FACT{\n companion object {\n var store = IntArray(0)\n var invStore = IntArray(0)\n\n var slowStore:IntArray = IntArray(0)\n\n fun preCal(upto:Int){\n store = IntArray(upto+1)\n invStore = IntArray(upto + 1 )\n store[0] = 1\n invStore[0] = 1\n\n for(i in 1..upto) {\n store[i] = store[i-1] modM i\n invStore[i] = invStore[i-1] modM (i.inverse())\n }\n }\n fun choose(n:Int,r:Int):Int{\n if(r < 0 || r > n) return 0\n val a = store[n]\n val b = invStore[n-r]\n val c = invStore[r]\n return (a modM b) modM c\n }\n\n fun bigChoose(n:Int,r:Int):Int{\n var ret = 1\n for(i in 0 until r){\n ret = ret modM (n - i)\n }\n ret = ret modM (invStore[r])\n return ret\n }\n\n }\n}\n\nfun debug(){}\nconst val withBruteForce = false\nconst val singleCase = true\nfun main(){\n FACT.preCal(300)\n solve.cases{\n\n val n = getint\n val k = getint\n\n //phrases, MAX\n val DP = Array(n){IntArray(k+1)}\n val sum = Array(n){IntArray(k+1)}\n\n DP[0][0] = FACT.store[n-1]\n for(max in 0..k){\n sum[0][max] = FACT.store[n-1]\n }\n// sum[0][0] = FACT.store[n]\n\n for(p in 1 until n){\n for(max in 1..k){\n var now = 0\n var totalop = 0\n for(op in p-1 downTo 0 ){\n totalop += op\n now = now modPlus (sum[op][max-1] modM FACT.invStore[p-op] modM intPow(k-max+1,totalop,pI))\n }\n DP[p][max] = now\n }\n for(max in 0..k){\n sum[p][max] = DP[p][max]\n if(max > 0){\n sum[p][max] = sum[p][max-1] modPlus sum[p][max]\n }\n }\n }\n var ret = 0\n for(c in DP.last()){\n ret = ret modPlus c\n }\n\n put(ret)\n\n\n }\n done()\n}\n\n\n/*\n\n3 3\n\ncosts are\n1,1,2,..,n\n\n1 2 3 3 4 5\n1 2 3 3 4 5\n\n\n1 2\n2 1\n3 4\n4 3\nmax of hte two things then product\n\n */\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d96e40f8c8d04bcf6d5bf9889dc05eb8", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val (n, t) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val book = r.readLine()!!.split(\" \").map { it.toLong() }\n val (n, a, b) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val l1 = listOf(a..n-1)\n val l3 = List(n-a){a+it}\n //println(l3)\n //val l2 = listOf((n-b-1)..n-1)\n val l4 = List(b+1){n-b-1+it}\n //println(l4)\n var ans = 0\n for (i in l3){\n loop@for (j in l4){\n if (i==j){\n ans++\n break@loop\n }\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "135ab676fb968b54adb7bc8dadbd0445", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numPeople, a, b) = readInts()\n print(min(numPeople - a, b + 1))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7fa31ea52fd73479078d1da4559f743b", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n fun files(inputFilename: String, outputFilename: String) =\n ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))\n }\n\n var tok = StringTokenizer(\"\")\n\n fun close() { rd.close(); wr.close() }\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun readToken(): String {\n while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())\n return tok.nextToken()\n }\n fun readLine(): String {\n tok = StringTokenizer(\"\")\n return rd.readLine()\n }\n fun readInt(): Int = readToken().toInt()\n fun readLong(): Long = readToken().toLong()\n}\n\nfun main(args: Array) {\n Thread({ val io = ProblemIO.console(); solve(io); io.close() }).start()\n}\n\nfun solve(io: ProblemIO) {\n val n = io.readInt()\n val a = io.readInt()\n val b = io.readInt()\n var res = 0\n for (i in 0 .. n - 1) {\n if (i < a) continue\n if (n - 1 - i > b) continue\n ++res\n }\n io.println(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3553f351f4da62c6451be9641e510348", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m,k) = readLine()!!.split(' ').map { it.toInt() }\n println(Math.min(n-m,k+1))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5654167b58860dbc1d99fb840382118e", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numPeople, a, _) = readInts()\n print(numPeople - a)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b371faeb1845f08517b58fab4d94f56f", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(atgs: Array){\n val sc = Scanner(System.`in`)\n val n: Int = 5\n var sum = 0\n var num = Array(100){0}\n for (i in 0 until n){\n var x = sc.nextInt()\n num[x]++\n sum += x\n }\n var ans = sum\n for (i in 1 until 100){\n if (num[i] > 1){\n if (num[i] == 2) ans = if (ans < sum-2*i) ans else sum-2*i\n else ans = if (ans < sum-3*i) ans else sum-3*i\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ff340fe599d444e209f4a4c5f0633f9d", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\nvar d:Int\nd=0\n var a = Array(101){0}\n var x=readLine()!!.split(' ').map(String::toInt)\n for(i in 0..4){\n a[x[i]]++;\n d+=x[i]\n }\n var c:Int\n c=d\n for(i in 1..100){\n if(a[i]>=3){\n if((d-3*i)(5){0}\n var e=0\n var f=0\n for(i in 0..4){\n p[i]=reader.nextInt()\n e+=p[i]\n }\n p.sort()\n var d=1\n var i=1\n for(i in 1..4){\n if(p[i]==p[i-1]){\n d++\n }\n else{\n if(d==2){\n f=max(p[i-1]*d,f)\n }\n if(d>2){\n f=max(p[i-1]*3,f)\n }\n d=1\n }\n }\n if(d==2){\n f=max(p[4]*d,f)\n }\n if(d>2){\n f=max(p[4]*3,f)\n }\n print(e-f)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "700ec65ec034a3721e527c4b7588c68b", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n var sc = Scanner(System.`in`)\n var list = ArrayList()\n list.add(sc.nextInt())\n list.add(sc.nextInt())\n list.add(sc.nextInt())\n list.add(sc.nextInt())\n list.add(sc.nextInt())\n\n Collections.sort(list)\n\n var array = Array(102,{0})\n\n var i = 0\n while (imax){\n max = two\n }\n }else if (array[j]>=3){\n flag = true\n two+=3*j\n if (two>max){\n max = two\n }\n }\n j++\n }\n\n\n if (flag){\n println(list.sum()-max)\n }else{\n println(list.sum())\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "73cbf5eb46add49e464ce3b77eef2fb2", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(atgs: Array){\n val sc = Scanner(System.`in`)\n val n: Int = 5\n var sum = 0\n var num = Array(101){0}\n for (i in 0 until n){\n var x = sc.nextInt()\n num[x]++\n sum += x\n }\n var ans = sum\n for (i in 1 until 101){\n if (num[i] > 1){\n if (num[i] == 2) ans = if (ans < sum-2*i) ans else sum-2*i\n else ans = if (ans < sum-3*i) ans else sum-3*i\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c098361b6564d96dcf55242e7a7891dc", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val jin = Scanner(System.`in`)\n val n = jin.nextLong()\n val k = jin.nextLong()\n println(if ((n / k) % 2L == 1L) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "518b94ac22ddf246fcba2fed9709e921", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n var scanner = Scanner(System.`in`)\n\n var n = scanner.nextLong()\n var k = scanner.nextLong()\n\n var t = n / k\n\n if (t % 2 == 0L) {\n print(\"NO\")\n } else {\n print(\"YES\")\n }\n scanner.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "525717f08fb209ceb5985f9621d8ab77", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) = with(java.util.Scanner(System.`in`)){\n var n = nextLong()\n var k = nextLong()\n var res : Long = n/k\n if(res%2 == 0L) println(\"NO\")\n else println(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cfb75488699d0eaef0161b7f902820a6", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (n, k) = readLongs()\n print (if ((n / k) % 2L == 1L) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5dc6d4491bcc68bfd1e0cb8b4baaaefa", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextLong()\n val k = sc.nextLong()\n\n println(if ((n / k) % 2 == 0L) \"NO\" else \"YES\")\n\n\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f64d4c4bc07c5960c55e6b6c1950c8a6", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextLong()\n var k = scanner.nextLong()\n var r: Long = n/k\n print(if (r%2==1L) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "406516708b1a95dbc887f5f1805dd506", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextLong()\n val k = sc.nextLong()\n val q = n / k\n println(if (q % 2 == 0L) \"NO\" else \"YES\")\n}\n\nfun main() {\n val writer = PrintWriter(System.out, false)\n writer.solve(FastScanner(System.`in`))\n writer.flush()\n}\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e8ecf6c9fbf8b9783cc3598e16d3ecda", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val n = r.readLine()!!.toInt()\n val (a, b) = r.readLine()!!.split(\" \").map { it.toLong() }\n when(a/b%2){\n 0L -> println(\"NO\")\n else -> println(\"YES\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "51866c19d9654a2b6c78bd674cade56f", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner()\n var n = sc.nxtInt()\n var k = sc.nxtInt()\n println(if((n/k)%2==1)\"YES\" else \"NO\")\n}\n\nclass Scanner(){\n var br:BufferedReader?=null\n var st:StringTokenizer?=null\n init {\n br = BufferedReader(InputStreamReader(System.`in`))\n }\n private fun tokenize()\n {\n while(st==null || !st!!.hasMoreTokens())st = StringTokenizer(br!!.readLine())\n }\n fun readLine():String{\n return br!!.readLine()\n }\n fun nxt():String\n {\n tokenize()\n return st!!.nextToken()\n }\n\n fun nxtInt():Int{\n return nxt().toInt()\n }\n fun nxtDouble():Double\n {\n return nxt().toDouble()\n }\n fun nxtString():String\n {\n return nxt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c04be3240a00887f26308123506ae7bb", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) = with(java.util.Scanner(System.`in`)){\n var n = nextInt()\n var k = nextInt()\n var res : Int = n/k\n if(res%2==0) println(\"NO\")\n else println(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "65909a336979626b4dc4fddf093ef5f0", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n var scanner = Scanner(System.`in`)\n\n var n = scanner.nextInt()\n var k = scanner.nextInt()\n\n var t = n / k\n\n\n\n if (t % 2 == 0) {\n print(\"NO\")\n } else {\n print(\"YES\")\n }\n scanner.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6280a7ec278f56c7083e6ff8f2afab7f", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val ans = n / 2 + 1\n writer.println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n val reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b2a822e79e6e39b0b124a2ba235b1743", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\nfun main(args: Array){\n\tval n = readLine()!!.toLong()\n\tprintln((n/2).toLong()+1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5281fcbf8662c8d1de0f4499023b07d5", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Math.floor\n// 1 2 3 4 5 6 7 8 9\n// 0,1,2,2,3,3,4,4,5,5\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n if(n == 0) print(0)\n else if(n == 1) print(1)\n else print(floor(n.toDouble() / 2).toInt() + 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "646eff9c4e5170d935ff7a245a1a5486", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main (args: Array) {\n val input = Scanner(System.`in`)\n val n = input.nextInt()\n\n println(1 + n / 2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "98064a0beadfeee209675e0f7c42585d", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n readLine()!!.toInt().let {\n println(when{\n it < 3 -> it\n else -> 1 + it/2\n })\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "acf70516aa3afcd0b95577cb934d0067", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\nfun main(args: Array){\n\tval n = readLine()!!.toLong()\n\tvar lastmod = 0L\n\tvar counter = 0\n\tfor (i in 1..n){\n\t\tval remainder = n.rem(i)\n\t\tval modulo = (n/i).toLong()\n\t\t//println(\"$n % $i: $modulo remains $remainder\")\n\t\tif (modulo != lastmod){\n\t\t\t//println(\"OK!\")\n\t\t\tlastmod = modulo\n\t\t\tcounter++\n\t\t\tif((remainder/modulo >= 1) and (modulo > 1)){\n\t\t\t\t//println(\"Plus:${remainder/modulo}\")\n\t\t\t\tcounter++\n\t\t\t}\n\t\t}\n\t}\n\tprintln(counter)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3081878745a5b03e81bd5acc0cb1a7fc", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\nfun main(args: Array){\n\tval n = readLine()!!.toLong()\n\tvar lastmod = 0L\n\tvar counter = 0\n\tvar lastrem = 0L\n\tfor (i in 1..n){\n\t\tval remainder = n.rem(i)\n\t\tval modulo = (n/i).toLong()\n\t\tprintln(\"$n % $i: $modulo remains $remainder\")\n\t\tif (modulo != lastmod){\n\t\t\tprintln(\"OK!\")\n\t\t\tlastmod = modulo\n\t\t\tlastrem = remainder\n\t\t\tcounter++\n\t\t\tif((remainder/modulo >= 1) and (modulo > 1)){\n\t\t\t\tprintln(\"Plus:${remainder/modulo}\")\n\t\t\t\tcounter++\n\t\t\t}\n\t\t}\n\t}\n\tprintln(counter)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "90540dd0d0e7715f0579745e2a33463d", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\nfun main(args: Array){\n\tval n = readLine()!!.toLong()\n\tvar lastRes = 0L\n\tvar counter = 0\n\tfor (i in 1..n){\n\t\tval remainder = n.rem(i)\n\t\tval modulo = (n/i).toLong()\n\t\t//println(\"$n % $i: $modulo remains $remainder\")\n\t\tif ((modulo != lastRes) and (i > counter)){\n\t\t\tlastRes = modulo\n\t\t\tcounter++\n\t\t\tif (remainder >= modulo){\n\t\t\t\tcounter++\n\t\t\t}\n\t\t}\n\t}\n\tprintln(counter-1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "83d4f274c4130caa067c2d7597a6c298", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Math.floor\n\nfun main(args: Array) {\n val n = readLine()!!.toDouble()\n print( (floor(n/2) + floor(n/5)).toInt() )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eab5a67ac433383d12f24df7eab679db", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val guests = sc.next()\n\n val doors = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\n\n val e = Array(26) { -1 }\n for (i in 0 until doors.length) {\n e[i] = guests.indexOfLast { it == doors[i] }\n }\n\n val opened = mutableSetOf()\n\n var max = -1\n for (i in 0 until n) {\n val d = guests[i]\n if (!opened.contains(d)) opened.add(d)\n else {\n max = Math.max(max, opened.size)\n if (e[doors.indexOf(d)] == i) opened.remove(d)\n }\n max = Math.max(max, opened.size)\n }\n\n\n println(if (k >= max) \"NO\" else \"YES\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ba907327e93bc70dcdb7545aa625845f", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val guests = sc.next()\n\n val doors = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\n\n val e = Array(26) { -1 }\n for (i in 0 until doors.length) {\n e[i] = guests.indexOfLast { it == doors[i] }\n }\n\n val opened = mutableSetOf()\n\n var max = -1\n for (i in 0 until n) {\n if (!opened.contains(guests[i])) opened.add(guests[i])\n else {\n val d = guests[i]\n if (e[doors.indexOf(d)] == i) opened.remove(d)\n }\n max = Math.max(max, opened.size)\n\n }\n\n\n println(if (k >= max) \"NO\" else \"YES\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd4ea49a022f24db7a1e9e23077a0b11", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numGuests, numGuards) = readInts()\n val doors = readLine()!!\n val opens = IntArray(numGuests)\n val opened = BooleanArray(26)\n for ((pos, door) in doors.withIndex())\n if (!opened[door - 'A']) {\n opened[door - 'A'] = true\n opens[pos] = 1\n }\n val closed = BooleanArray(26)\n for ((pos, door) in doors.withIndex().reversed())\n if (!closed[door - 'A']) {\n closed[door - 'A'] = true\n if (pos < numGuests - 1) opens[pos + 1] += -1\n }\n var sum = 0\n for (pos in 0 until numGuests) {\n sum += opens[pos]\n if (sum > numGuards) return print(\"YES\")\n }\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce75dc11e534fece2cdf178541a32bfc", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n val n = nextInt()\n val k = nextInt()\n val s = nextString()!!.toCharArray().map { (it - 'A').toInt() }\n val first = IntArray('Z' - 'A' + 1) { -1 }\n val last = IntArray('Z' - 'A' + 1) { -1 }\n s.forEachIndexed { i, c ->\n if (first[c] == -1) {\n first[c] = i\n }\n last[c] = i\n }\n val sum = IntArray(n + 1)\n first.indices.forEach {\n if (first[it] != -1) {\n sum[first[it]]++\n sum[last[it] + 1]--\n }\n }\n (1..sum.lastIndex).forEach {\n sum[it] += sum[it - 1]\n }\n if (sum.any { it > k }) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d91b9a8e360bb8f88de1d1b36a75e465", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val guests = sc.next()\n\n val doors = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\n\n val e = Array(26) { -1 }\n for (i in 0 until doors.length) {\n e[i] = guests.indexOfLast { it == doors[i] }\n }\n\n val opened = mutableSetOf()\n\n var max = -1\n for (i in 0 until n) {\n val d = guests[i]\n if (!opened.contains(d)) opened.add(d)\n\n max = Math.max(max, opened.size)\n if (e[doors.indexOf(d)] == i) opened.remove(d)\n }\n\n\n println(if (k >= max) \"NO\" else \"YES\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0340a365f38afff2f5da7ac9328a5e19", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()\nfun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()\nfun readStringList() = readLine()!!.split(' ').toMutableList()\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\n\nfun main(args: Array) {\n\n val (n, k) = readIntList()\n val s = readLine()!!\n val alphabet = Array(26, { -1 })\n val lastAlphabet = Array(26, { -1 })\n s.forEachIndexed { index, ch ->\n lastAlphabet[ch - 'A'] = index\n }\n\n\n var count = 0\n var isSuccess = true\n s.forEachIndexed { index, ch ->\n val i = ch - 'A'\n if(alphabet[i] == -1)\n count ++\n\n if(count > k)\n isSuccess = false\n\n alphabet[i] = index\n if(lastAlphabet[i] == index)\n count --\n }\n\n if (isSuccess)\n println(\"NO\")\n else\n println(\"YES\")\n\n}\n\n\nclass Custom(\n val p: Int,\n val s: Int\n) {\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3ec9d03ab867690940de88fe14d73d87", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val r = java.util.Scanner(System.`in`)\n var n = r.nextInt()\n val a = r.nextInt()\n val b = r.nextInt()\n val c = Array(n,{0})\n var d : Int\n for (i in 1..a)\n c[r.nextInt()-1]=1\n for (i in 1..b) {\n val e = r.nextInt()-1\n if (c[e] == 0)\n c[e]=2\n }\n c.forEach { print(\"$it \") }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bf87a044e172ff6af24ef20bd54831be", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numApples, _, _) = readInts()\n val sol = IntArray(numApples)\n val arthurLikes = readInts().toSet()\n readLine()\n for (apple in 1..numApples)\n sol[apple - 1] = if (apple in arthurLikes) 1 else 2\n print(sol.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "56c15bdd2cf02eb26fb4ea6c8f009fca", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import com.sun.xml.internal.fastinfoset.util.StringArray\nimport java.awt.List\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.min\n\nfun main() {\n var (n, a, b) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = Array(n+1,{false})\n var ans1 = Array(n+1,{false})\n\n var list = readLine()!!.split(' ').map { ans[it.toInt()] = true }\n var list1 = readLine()!!.split(' ').map { ans1[it.toInt()] = true }\n\n for (i in 1..n){\n if (ans[i]){\n print(\"${1} \")\n }else if(ans1[i]){\n print(\"${2} \")\n }\n }\n\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3a13c23433f4402e3f50e282ec469832", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val S = ns().map{it-'0'}\n val N = S.size\n val M = ni()\n val cntDigit = IntArray(10)\n for (i in 0 until S.size) {\n cntDigit[S[i]]++\n }\n val coef = IntArray(11)\n coef[0] = 1\n for (i in 0 until 10) {\n coef[i + 1] = coef[i] * (1 + cntDigit[i])\n }\n debug(coef)\n var best = Array(coef.last()){LongArray(M)}\n var next = Array(coef.last()){LongArray(M)}\n best[0][0] = 1\n\n val map = IntArray(10_000) // 100 * 10 + 100 \u3057\u304b\u3044\u304b\u306a\u3044\u3051\u3069\u305f\u304f\u3055\u3093\u3064\u304f\u3063\u3068\u304f\n for (i in 0 until map.size) {\n map[i] = i % M\n }\n\n var pow10 = 1\n for (i in N - 1 downTo 0) {\n for (s in 0 until coef.last()) {\n for (d in 0 until 10) {\n if (i == 0 && d == 0) continue\n if ((s + coef[d]) / coef[d + 1] > s / coef[d + 1]) continue\n val ns = s + coef[d]\n for (m in 0 until M) {\n if (best[s][m] == 0L) continue\n val nm = map[m + pow10 * d]\n// debug{\"s:$s m:$m d:$d ns:$ns nm:$nm\"}\n next[ns][nm] += best[s][m]\n }\n }\n }\n debug{\"DP($i)\"}\n debugDim(next)\n val t = best\n best = next\n next = t\n\n pow10 = (pow10 * 10) % M\n }\n out.println(best[coef.last() - 1][0])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "01ba48567bc864486e77612cb8cb9360", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n\n val scanner = Scanner(System.`in`)\n\n val w = scanner.nextInt()\n val h = scanner.nextInt()\n\n var ans: Long = 0\n\n for (x in 0..w) {\n for (y in 0..h) {\n if (x % 2 == 0 && y % 2 == 0 && x > 0 && y > 0) {\n ans += (w - x + 1) * (h - y + 1)\n }\n }\n }\n\n println(ans)\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0c3a1156d89a89e9d6f7ef0f64c2e800", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "\n\nimport java.util.*\n\nfun main() {\n var w: Int\n var h: Int\n\n with(Scanner(System.`in`)) {\n w = nextInt()\n h = nextInt()\n }\n\n var count = 0L\n\n for (i in w / 2 downTo 1 step 1) {\n for (j in h / 2 downTo 1 step 1) {\n count += (w - i * 2 + 1) * (h - j * 2 +1)\n }\n }\n print(count)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8a94335fb2f5b5efc50456e1f7fe6263", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "val M = 1000000007L\nval N = 100005\nvar fact = LongArray(N)\nvar ifact = LongArray(N)\nvar t = 0\n\n\nfun main(args : Array) {\n val (n, m, g) = readLine().toString().split(' ').map { it.toInt() }\n t = g\n init()\n\n // case when there are no ones\n if (m == 0) {\n val res = if (ok(n)) 1 else 0\n println(res)\n return\n }\n\n var ans = 0L\n // number of zeroes before first one position\n for (i in 0..n) {\n var k = ok(i + 1)\n if (m == 1 && i == n) k = ok(i)\n if (!k) continue\n ans = (ans + C(n - i + m - 1, m - 1)) % M\n }\n println(ans)\n}\n\nfun init() {\n fact[0] = 1L\n ifact[0] = 1L\n for (i in 1..(N - 1)) {\n fact[i] = (fact[i - 1] * i) % M\n ifact[i] = binpow(fact[i], M - 2)\n }\n}\n\nfun binpow(n : Long, deg : Long) : Long {\n if (deg == 0L) return 1L\n return if (deg % 2L == 1L) {\n n * binpow(n, deg - 1) % M\n } else {\n val b = binpow(n, deg / 2L)\n b * b % M\n }\n}\n\nfun C(n : Int, k : Int) : Long {\n return if (n < k) 0\n else fact[n] * ifact[k] % M * ifact[n - k] % M\n}\n\nfun ok(zeroes : Int) = (1 - zeroes % 2 == t)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "25104a19d3aa5bccbc7b23705f64cce8", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n,m) = readLine()!!.split(' ').map(String::toInt)\n var a = readLine()!!.split(' ').map(String::toInt)\n a = a.sorted()\n print(a.last())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "35eaa0816739d48685dd6e1549940dd0", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n,m) = readLine()!!.split(' ').map(String::toInt)\n var a = readLine()!!.split(' ').map(String::toInt)\n a = a.sorted()\n if ((m >= a.last()) || (m % a.last() == 0)) {\n print(a.lastIndex + 1)\n }\n else\n print(a.last())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6084990981a875736a9fc45d43d59e90", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, m) = readLine()!!.split(\" \").map{ it.toInt() }\n readLine()!!.split(\" \").map{ it.toInt() }.toMutableList().let {\n var last = 0;\n while(true) {\n var count = 0\n for((i, x) in it.withIndex()) {\n if(x > 0) {\n it[i] -= m\n last = i + 1\n }\n if(it[i] <= 0) count++\n }\n if(count == n) break\n }\n println(last)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "68d23557bb775184ee73c589d4b856ce", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.pow\n\nfun main() {\n var (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n var list = readLine()!!.split(\" \").map { it.toInt() }\n\n var max = list.max()\n val map = Array(n, { 0 })\n var ans = -1\n var ans2 = 0\n if (max!! <= m) {\n ans = n\n } else {\n var count = n\n for (i in n - 1 downTo 0) {\n if (list[i] > m) {\n var temp = list[i] / m\n var temp2 = list[i] % m\n if (temp2 != 0) {\n temp++\n }\n if (temp > ans2) {\n ans = count\n ans2 = temp\n }\n }\n count--\n }\n }\n\n println(ans)\n\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "af2e2752ed6876f8ba892cce703697b6", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (name, surname) = readLine()!!.split(\" \")\n val sol = StringBuilder()\n for ((pos, c) in name.withIndex()) {\n if (c < surname.first() || pos == 0) sol.append(c)\n else break\n }\n sol.append(surname.first())\n print(sol.toString())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "122b396dabeb9508f65359a891d63bd2", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nprivate val reader = BufferedReader(InputStreamReader(System.`in`))\nprivate val out = PrintWriter(System.out)\nprivate var st = StringTokenizer(\"\")\n\nfun next(): String {\n while (!st.hasMoreTokens())\n st = StringTokenizer(reader.readLine())\n return st.nextToken()\n}\n\nfun ni() = next().toInt()\nfun nl() = next().toLong()\nfun nd() = next().toDouble()\nfun print(obj: Any) = out.print(obj)\nfun close() = out.close()\n\nfun main(args: Array) {\n val name = next()\n val secondName = next()\n print(\"${name.slice(1 until name.length).takeWhile { it < secondName[0] }.map { \"$it\" }.fold(\"${name[0]}\") { acc, v -> \"$acc$v\" }}${secondName[0]}\")\n close()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "de228c6a08f5e067564d3d71b1fb1b81", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val s = nextLine().split((\" \").toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()\n val c = s[0].toCharArray()\n val fchar = s[1].get(0)\n val sb = StringBuilder(\"\")\n sb.append(c[0])\n for (i in 1 until c.size) {\n val a = c[i].toInt()\n val b = fchar.toInt()\n if (a < b) sb.append(a.toChar())\n else break\n }\n sb.append(fchar)\n println(sb)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c66c8c3ba3f6a1de147c88d31a0f51e9", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (f, l) = readLine()!!.split(\" \")\n var j = 0\n var ans = f[0].toString()\n for (i in 1 until f.length) {\n if (f[i].toInt() < l[j].toInt()) {\n ans += f[i]\n }else{\n ans+=l[j]\n println(ans)\n return\n }\n }\n ans+=l[j]\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "761cba64314b0b1ade09714da92b59ca", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (a, b) = readLine()!!.split(' ')\n var ans = \"\"\n var i = 1\n ans = ans.plus(a.get(0))\n var found: Boolean = false\n while (i < a.length) {\n if(a.get(i) < b.get(0)){\n ans = ans.plus(a.get(i))\n }\n else{\n ans = ans.plus(b.get(0))\n found = true\n break\n }\n i++\n }\n if (!found){\n ans = ans.plus(b.get(0))\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "611d24b0532f0211749feb261a950260", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (name, surname) = readLine()!!.split(\" \")\n val sol = StringBuilder()\n for (c in name) {\n if (c < surname.first()) sol.append(c)\n else break\n }\n sol.append(surname.first())\n print(sol.toString())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "32f8270d7169ad8aeb01c243161bb6cb", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (f, l) = readLine()!!.split(\" \")\n var j = 0\n var ans = f[0].toString()\n for (i in 1 until f.length) {\n if (f[i].toInt() <= l[j].toInt()) {\n ans += f[i]\n }else{\n ans+=l[j]\n for (i in j until l.length-1){\n if (l[i]) {\n io.apply {\n\n val n = int\n val ans = when(n) {\n 1 -> 1\n 2, 4, 5 -> 3\n 3, in 6..13 -> 5\n in 14..25 -> 7\n in 26..41 -> 9\n in 42..61 -> 11\n in 62..85 -> 13\n else -> 15\n }\n\n cout .. ans .. nl\n\n }.cout.flush()\n}\n\n// @formatter:off\nprivate val io = object {\n private val `in` = System.`in`\n private fun ll(): Long {\n var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }\n do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n\n }\n val int get() = ll().toInt(); val long get() = ll()\n fun ints(n: Int = int): IntArray { return IntArray(n) { int } }\n fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }\n val cout = PrintWriter(System.out); val nl = \"\\n\"\n operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(\" \") }; return this }\n operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }\n} // @formatter:on\n\n/* ----------- */\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2a3cd2245d5afa83d17a34c991b1eb0f", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\n\n\nobject programkt {\n interface Scanner {\n fun changeInputStream(inputStream: InputStream)\n fun nextInt(): Int\n fun nextLong(): Long\n fun nextDouble(): Double\n fun nextChar(): Char\n fun nextString(): String\n fun nextLine(): String\n fun nextBigInteger(): BigInteger\n fun nextBigDecimal(): BigDecimal\n }\n\n abstract class Task {\n //KT Extensions\n fun > min(a: T, b: T) = if (a > b) b else a\n fun > max(a: T, b: T) = if (a < b) b else a\n fun abs(a: Int) = if (a > 0) a else -(a)\n fun abs(a: Long) = if (a > 0) a else -(a)\n fun abs(a: Float) = if (a > 0) a else -(a)\n fun abs(a: Double) = if (a > 0) a else -(a)\n operator fun Iterable.invoke(function: (it: T) -> Unit) { this.forEach(function) }\n private fun String.prefix(pi: Array): Array {\n pi[0] = 0\n (1 until this.length) {\n var j = pi[it - 1]\n while (j > 0 && this[it] != this[j]) {\n j = pi[j - 1]\n }\n if(this[it] == this[j]) {\n j++\n }\n pi[it] = j\n }\n return pi\n }\n private fun String.kmpFind(pattern: String): Int {\n val m = pattern.length\n val dfa = Array(256) { IntArray(m) }\n dfa[pattern[0].toInt()][0] = 1\n var x = 0\n var j = 1\n while (j < m) {\n for (c in 0 until 256) {\n dfa[c][j] = dfa[c][x] // Copy mismatch cases.\n }\n dfa[pattern[j].toInt()][j] = j + 1 // Set match case.\n x = dfa[pattern[j].toInt()][x] // Update restart state.\n j++\n }\n\n val n = this.length\n var i: Int = 0\n j = 0\n while (i < n && j < m) {\n j = dfa[this[i].toInt()][j]\n i++\n }\n if (j == m) return i - m // found\n return n // not found\n }\n fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}\n\n enum class EdgeType {\n DIRECTED,\n UNDIRECTED\n }\n data class Vertex>(\n val data: T\n ) {\n override fun toString(): String = \"V:$data\"\n }\n data class Edge>(\n var source: Vertex,\n var destination: Vertex,\n val weight: Double?\n )\n interface Graphable> {\n fun createVertex(data: T): Vertex\n fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double? = 0.0)\n fun weight(source: Vertex, destination: Vertex): Double?\n fun edges(source: Vertex): MutableList>?\n }\n class AdjacencyList>: Graphable {\n var adjacencyMap: MutableMap, MutableList>> = mutableMapOf()\n\n private fun addDirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))\n }\n\n private fun addUndirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n addDirectedEdge(source, destination, weight)\n addDirectedEdge(destination, source, weight)\n }\n\n override fun createVertex(data: T): Vertex {\n val vertex = Vertex(data = data)\n adjacencyMap[vertex] ?: run {\n adjacencyMap[vertex] = mutableListOf()\n }\n return vertex\n }\n\n override fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double?) = when(type) {\n EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)\n EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)\n }\n\n override fun weight(source: Vertex, destination: Vertex): Double? {\n adjacencyMap[source]?.forEach {\n if(it.destination == destination) return it.weight\n }\n return null\n }\n\n override fun edges(source: Vertex): MutableList>? = adjacencyMap[source]\n\n override fun toString(): String {\n var result = \"\"\n for ((vertex, edges) in adjacencyMap) {\n var edgeString = \"\"\n for ((index, edge) in edges.withIndex()) {\n edgeString += if (index != edges.count() - 1) \"${edge.destination}, \"\n else \"${edge.destination}\"\n }\n result += \"$vertex ---> [ $edgeString ] \\n\"\n }\n return result\n }\n\n fun depthFirstSearch(start: Vertex, end: Vertex): Stack> {\n val visited: HashSet> = hashSetOf()\n val stack: Stack> = Stack()\n stack.push(start)\n visited.add(start)\n\n var currentVertex = stack.peek()\n loop@while (currentVertex != null && currentVertex != end) {\n val neighbors = edges(currentVertex)\n if(neighbors != null && neighbors.count() > 0) {\n for(edge in neighbors) {\n if(!visited.contains(edge.destination)) {\n visited.add(edge.destination)\n stack.push(edge.destination)\n currentVertex = stack.peek()\n continue@loop\n }\n }\n } else {\n stack.pop()\n currentVertex = stack.peek()\n continue\n }\n\n stack.pop()\n currentVertex = stack.peek()\n }\n\n return stack\n }\n\n fun breadthFirstSearch() {\n\n }\n\n fun floydWarshallAlgorythm(): Pair, Array> {\n val nVertices = this.adjacencyMap.size\n\n val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }\n this.adjacencyMap\n .asSequence()\n .map { it.value }\n .withIndex()\n .forEach { (index, weightsOfVertex) ->\n weightsOfVertex.asSequence()\n .withIndex()\n .forEach { (weightIndex, weight) ->\n weights[index][weightIndex] = weight.weight!!\n }\n }\n\n val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }\n for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]\n val next = Array(nVertices) { IntArray(nVertices) }\n for (i in 0 until next.size) {\n for (j in 0 until next.size) {\n if (i != j) next[i][j] = j + 1\n }\n }\n for (k in 0 until nVertices) {\n for (i in 0 until nVertices) {\n for (j in 0 until nVertices) {\n if (dist[i][k] + dist[k][j] < dist[i][j]) {\n dist[i][j] = dist[i][k] + dist[k][j]\n next[i][j] = next[i][k]\n }\n }\n }\n }\n return dist to next\n }\n }\n\n fun > TreeMap>.toAdjacencyList(type: EdgeType): AdjacencyList {\n val list = AdjacencyList()\n\n this.keys.forEach { list.createVertex(it) }\n this.entries\n .asSequence()\n .withIndex()\n .forEach { (x, edge) ->\n val vertex = list.createVertex(edge.key)\n edge.value\n .asSequence()\n .withIndex()\n .forEach { (y, weight) ->\n if(weight != .0 && y != x)\n list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)\n }\n }\n return list\n }\n //End KT Extensions\n\n abstract fun solve(scanner: Scanner, printer: PrintWriter)\n }\n\n class FastScanner: Scanner {\n var inputStream: InputStream? = null\n override fun changeInputStream(inputStream: InputStream) {\n this.inputStream = inputStream\n this.bufferedReader = BufferedReader(InputStreamReader(inputStream))\n }\n\n private lateinit var bufferedReader: BufferedReader\n private var stringTokenizer: StringTokenizer? = null\n\n private fun nextToken(): String? {\n while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())\n stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)\n return stringTokenizer!!.nextToken()\n }\n\n override fun nextInt() = nextToken()!!.toInt()\n override fun nextLong() = nextToken()!!.toLong()\n override fun nextDouble() = nextToken()!!.toDouble()\n override fun nextChar() = bufferedReader.read().toChar()\n override fun nextString() = nextToken()!!\n override fun nextLine() = bufferedReader.readLine()!!\n override fun nextBigInteger() = BigInteger(nextToken()!!)\n override fun nextBigDecimal() = BigDecimal(nextToken()!!)\n }\n\n class TaskBuilder {\n private var task: Task? = null\n private var inputStream: InputStream? = null\n private var outputStream: OutputStream? = null\n private var scanner: Scanner? = null\n\n fun useInputSource(inputStream: InputStream): TaskBuilder {\n this.inputStream = inputStream\n return this\n }\n\n fun useOutputSource(outputStream: OutputStream): TaskBuilder {\n this.outputStream = outputStream\n return this\n }\n\n fun useInputFile(inputFileName: String): TaskBuilder {\n this.inputStream = FileInputStream(File(inputFileName))\n return this\n }\n\n fun useOutputFile(outputFileName: String): TaskBuilder {\n this.outputStream = FileOutputStream(File(outputFileName))\n return this\n }\n\n fun useScanner(scanner: Scanner): TaskBuilder {\n this.scanner = scanner\n return this\n }\n\n\n fun solveTask(task: Task): TaskBuilder {\n this.task = task\n return this\n }\n\n fun run() {\n when {\n task == null -> throw NullPointerException(\"Task cannot be null!\")\n inputStream == null -> throw NullPointerException(\"Input cannot be null!\")\n outputStream == null -> throw NullPointerException(\"Output cannot be null!\")\n scanner == null -> throw NullPointerException(\"Scanner cannot be null!\")\n }\n scanner!!.changeInputStream(inputStream!!)\n val printer = PrintWriter(outputStream)\n TaskRunnable(task!!, scanner!!, printer).run()\n\n inputStream!!.close()\n printer.close()\n }\n\n class TaskRunnable(\n private val task: Task,\n private val scanner: Scanner,\n private val printer: PrintWriter\n ) {\n fun run() {\n task.solve(scanner, printer)\n }\n }\n }\n\n @JvmStatic\n fun main(args: Array) = TaskBuilder()\n .useInputSource(System.`in`)\n .useOutputSource(System.out)\n .useScanner(FastScanner())\n .solveTask(TaskA())\n .run()\n\n\n class TaskA: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val (firstValency, secondValency, thirdValency) = scanner.nextLine()\n .split(\" \")\n .map { it.toLong() }\n val averageValency = (firstValency + secondValency + thirdValency) / 2\n\n if ((firstValency + secondValency + thirdValency) % 2 != 0L ) { printer.println(\"Impossible\"); return }\n\n val countOfConnectionsFirst = averageValency - thirdValency\n val countOfConnectionsSecond = averageValency - firstValency\n val countOfConnectionsThird = averageValency - secondValency\n\n when {\n countOfConnectionsFirst < 0 -> { printer.println(\"Impossible\"); return }\n countOfConnectionsSecond < 0 -> { printer.println(\"Impossible\"); return }\n countOfConnectionsThird < 0 -> { printer.println(\"Impossible\"); return }\n else -> printer.println(\"$countOfConnectionsFirst $countOfConnectionsSecond $countOfConnectionsThird\")\n }\n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "209e013eef98cf71d5607a2c3a0a1931", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\n\n\nobject programkt {\n interface Scanner {\n fun changeInputStream(inputStream: InputStream)\n fun nextInt(): Int\n fun nextLong(): Long\n fun nextDouble(): Double\n fun nextChar(): Char\n fun nextString(): String\n fun nextLine(): String\n fun nextBigInteger(): BigInteger\n fun nextBigDecimal(): BigDecimal\n }\n\n abstract class Task {\n //KT Extensions\n fun > min(a: T, b: T) = if (a > b) b else a\n fun > max(a: T, b: T) = if (a < b) b else a\n fun abs(a: Int) = if (a > 0) a else -(a)\n fun abs(a: Long) = if (a > 0) a else -(a)\n fun abs(a: Float) = if (a > 0) a else -(a)\n fun abs(a: Double) = if (a > 0) a else -(a)\n operator fun Iterable.invoke(function: (it: T) -> Unit) { this.forEach(function) }\n private fun String.prefix(pi: Array): Array {\n pi[0] = 0\n (1 until this.length) {\n var j = pi[it - 1]\n while (j > 0 && this[it] != this[j]) {\n j = pi[j - 1]\n }\n if(this[it] == this[j]) {\n j++\n }\n pi[it] = j\n }\n return pi\n }\n private fun String.kmpFind(pattern: String): Int {\n val m = pattern.length\n val dfa = Array(256) { IntArray(m) }\n dfa[pattern[0].toInt()][0] = 1\n var x = 0\n var j = 1\n while (j < m) {\n for (c in 0 until 256) {\n dfa[c][j] = dfa[c][x] // Copy mismatch cases.\n }\n dfa[pattern[j].toInt()][j] = j + 1 // Set match case.\n x = dfa[pattern[j].toInt()][x] // Update restart state.\n j++\n }\n\n val n = this.length\n var i: Int = 0\n j = 0\n while (i < n && j < m) {\n j = dfa[this[i].toInt()][j]\n i++\n }\n if (j == m) return i - m // found\n return n // not found\n }\n fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}\n\n enum class EdgeType {\n DIRECTED,\n UNDIRECTED\n }\n data class Vertex>(\n val data: T\n ) {\n override fun toString(): String = \"V:$data\"\n }\n data class Edge>(\n var source: Vertex,\n var destination: Vertex,\n val weight: Double?\n )\n interface Graphable> {\n fun createVertex(data: T): Vertex\n fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double? = 0.0)\n fun weight(source: Vertex, destination: Vertex): Double?\n fun edges(source: Vertex): MutableList>?\n }\n class AdjacencyList>: Graphable {\n var adjacencyMap: MutableMap, MutableList>> = mutableMapOf()\n\n private fun addDirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))\n }\n\n private fun addUndirectedEdge(source: Vertex, destination: Vertex, weight: Double?) {\n addDirectedEdge(source, destination, weight)\n addDirectedEdge(destination, source, weight)\n }\n\n override fun createVertex(data: T): Vertex {\n val vertex = Vertex(data = data)\n adjacencyMap[vertex] ?: run {\n adjacencyMap[vertex] = mutableListOf()\n }\n return vertex\n }\n\n override fun add(type: EdgeType, source: Vertex, destination: Vertex, weight: Double?) = when(type) {\n EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)\n EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)\n }\n\n override fun weight(source: Vertex, destination: Vertex): Double? {\n adjacencyMap[source]?.forEach {\n if(it.destination == destination) return it.weight\n }\n return null\n }\n\n override fun edges(source: Vertex): MutableList>? = adjacencyMap[source]\n\n override fun toString(): String {\n var result = \"\"\n for ((vertex, edges) in adjacencyMap) {\n var edgeString = \"\"\n for ((index, edge) in edges.withIndex()) {\n edgeString += if (index != edges.count() - 1) \"${edge.destination}, \"\n else \"${edge.destination}\"\n }\n result += \"$vertex ---> [ $edgeString ] \\n\"\n }\n return result\n }\n\n fun depthFirstSearch(start: Vertex, end: Vertex): Stack> {\n val visited: HashSet> = hashSetOf()\n val stack: Stack> = Stack()\n stack.push(start)\n visited.add(start)\n\n var currentVertex = stack.peek()\n loop@while (currentVertex != null && currentVertex != end) {\n val neighbors = edges(currentVertex)\n if(neighbors != null && neighbors.count() > 0) {\n for(edge in neighbors) {\n if(!visited.contains(edge.destination)) {\n visited.add(edge.destination)\n stack.push(edge.destination)\n currentVertex = stack.peek()\n continue@loop\n }\n }\n } else {\n stack.pop()\n currentVertex = stack.peek()\n continue\n }\n\n stack.pop()\n currentVertex = stack.peek()\n }\n\n return stack\n }\n\n fun breadthFirstSearch() {\n\n }\n\n fun floydWarshallAlgorythm(): Pair, Array> {\n val nVertices = this.adjacencyMap.size\n\n val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }\n this.adjacencyMap\n .asSequence()\n .map { it.value }\n .withIndex()\n .forEach { (index, weightsOfVertex) ->\n weightsOfVertex.asSequence()\n .withIndex()\n .forEach { (weightIndex, weight) ->\n weights[index][weightIndex] = weight.weight!!\n }\n }\n\n val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }\n for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]\n val next = Array(nVertices) { IntArray(nVertices) }\n for (i in 0 until next.size) {\n for (j in 0 until next.size) {\n if (i != j) next[i][j] = j + 1\n }\n }\n for (k in 0 until nVertices) {\n for (i in 0 until nVertices) {\n for (j in 0 until nVertices) {\n if (dist[i][k] + dist[k][j] < dist[i][j]) {\n dist[i][j] = dist[i][k] + dist[k][j]\n next[i][j] = next[i][k]\n }\n }\n }\n }\n return dist to next\n }\n }\n\n fun > TreeMap>.toAdjacencyList(type: EdgeType): AdjacencyList {\n val list = AdjacencyList()\n\n this.keys.forEach { list.createVertex(it) }\n this.entries\n .asSequence()\n .withIndex()\n .forEach { (x, edge) ->\n val vertex = list.createVertex(edge.key)\n edge.value\n .asSequence()\n .withIndex()\n .forEach { (y, weight) ->\n if(weight != .0 && y != x)\n list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)\n }\n }\n return list\n }\n //End KT Extensions\n\n abstract fun solve(scanner: Scanner, printer: PrintWriter)\n }\n\n class FastScanner: Scanner {\n var inputStream: InputStream? = null\n override fun changeInputStream(inputStream: InputStream) {\n this.inputStream = inputStream\n this.bufferedReader = BufferedReader(InputStreamReader(inputStream))\n }\n\n private lateinit var bufferedReader: BufferedReader\n private var stringTokenizer: StringTokenizer? = null\n\n private fun nextToken(): String? {\n while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())\n stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)\n return stringTokenizer!!.nextToken()\n }\n\n override fun nextInt() = nextToken()!!.toInt()\n override fun nextLong() = nextToken()!!.toLong()\n override fun nextDouble() = nextToken()!!.toDouble()\n override fun nextChar() = bufferedReader.read().toChar()\n override fun nextString() = nextToken()!!\n override fun nextLine() = bufferedReader.readLine()!!\n override fun nextBigInteger() = BigInteger(nextToken()!!)\n override fun nextBigDecimal() = BigDecimal(nextToken()!!)\n }\n\n class TaskBuilder {\n private var task: Task? = null\n private var inputStream: InputStream? = null\n private var outputStream: OutputStream? = null\n private var scanner: Scanner? = null\n\n fun useInputSource(inputStream: InputStream): TaskBuilder {\n this.inputStream = inputStream\n return this\n }\n\n fun useOutputSource(outputStream: OutputStream): TaskBuilder {\n this.outputStream = outputStream\n return this\n }\n\n fun useInputFile(inputFileName: String): TaskBuilder {\n this.inputStream = FileInputStream(File(inputFileName))\n return this\n }\n\n fun useOutputFile(outputFileName: String): TaskBuilder {\n this.outputStream = FileOutputStream(File(outputFileName))\n return this\n }\n\n fun useScanner(scanner: Scanner): TaskBuilder {\n this.scanner = scanner\n return this\n }\n\n\n fun solveTask(task: Task): TaskBuilder {\n this.task = task\n return this\n }\n\n fun run() {\n when {\n task == null -> throw NullPointerException(\"Task cannot be null!\")\n inputStream == null -> throw NullPointerException(\"Input cannot be null!\")\n outputStream == null -> throw NullPointerException(\"Output cannot be null!\")\n scanner == null -> throw NullPointerException(\"Scanner cannot be null!\")\n }\n scanner!!.changeInputStream(inputStream!!)\n val printer = PrintWriter(outputStream)\n TaskRunnable(task!!, scanner!!, printer).run()\n\n inputStream!!.close()\n printer.close()\n }\n\n class TaskRunnable(\n private val task: Task,\n private val scanner: Scanner,\n private val printer: PrintWriter\n ) {\n fun run() {\n task.solve(scanner, printer)\n }\n }\n }\n\n @JvmStatic\n fun main(args: Array) = TaskBuilder()\n .useInputSource(System.`in`)\n .useOutputSource(System.out)\n .useScanner(FastScanner())\n .solveTask(TaskA())\n .run()\n\n\n class TaskA: Task() {\n override fun solve(scanner: Scanner, printer: PrintWriter) {\n val (firstValency, secondValency, thirdValency) = scanner.nextLine()\n .split(\" \")\n .map { it.toLong() }\n val averageValency = (firstValency + secondValency + thirdValency) / 2\n val countOfConnectionsFirst = averageValency - thirdValency\n val countOfConnectionsSecond = averageValency - firstValency\n val countOfConnectionsThird = averageValency - secondValency\n\n when {\n (firstValency + secondValency + thirdValency) / 2 % 1 != 0L -> { printer.println(\"Impossible\"); return }\n countOfConnectionsFirst < 0 -> { printer.println(\"Impossible\"); return }\n countOfConnectionsSecond < 0 -> { printer.println(\"Impossible\"); return }\n countOfConnectionsThird < 0 -> { printer.println(\"Impossible\"); return }\n else -> printer.println(\"$countOfConnectionsFirst $countOfConnectionsSecond $countOfConnectionsThird\")\n }\n }\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f220c896d0eb34598faa02f7da9adb1", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n\tval s = Scanner(System.`in`)\n\tval a = s.nextInt()\n\tval b = s.nextInt()\n\tval c = s.nextInt() * 2\n\tif (a >= c && b >= c) {\n\t\tprintln(\"First\")\n\t} else {\n\t\tprintln(\"Second\")\n\t}\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "edaeca02da683b427368709734b3e837", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.*\n\nval stdout = System.out;\nval stdin = FastScanner(System.`in`);\n\nfun solve() {\n val n = nextInt()\n val arr = nextIntArray(n)\n when {\n arr.last() == 15 -> print(\"DOWN\")\n arr.last() == 0 -> print(\"UP\")\n arr.size < 2 -> print(\"-1\")\n else -> if (arr[n - 1] > arr[n - 2]) print(\"UP\") else print(\"DOWN\")\n }\n}\n\ninline fun print(message: Any?) = stdout.print(message)\ninline fun print(message: Int) = stdout.print(message)\ninline fun print(message: Long) = stdout.print(message)\ninline fun print(message: Byte) = stdout.print(message)\ninline fun print(message: Short) = stdout.print(message)\ninline fun print(message: Char) = stdout.print(message)\ninline fun print(message: Boolean) = stdout.print(message)\ninline fun print(message: Float) = stdout.print(message)\ninline fun print(message: Double) = stdout.print(message)\ninline fun print(message: CharArray) = stdout.print(message)\ninline fun println(message: Any?) = stdout.println(message)\ninline fun println(message: Int) = stdout.println(message)\ninline fun println(message: Long) = stdout.println(message)\ninline fun println(message: Byte) = stdout.println(message)\ninline fun println(message: Short) = stdout.println(message)\ninline fun println(message: Char) = stdout.println(message)\ninline fun println(message: Boolean) = stdout.println(message)\ninline fun println(message: Float) = stdout.println(message)\ninline fun println(message: Double) = stdout.println(message)\ninline fun println(message: CharArray) = stdout.println(message)\ninline fun println() = stdout.println()\n\ninline fun nextInt() = stdin.nextInt()\ninline fun nextLong() = stdin.nextLong()\ninline fun nextChar() = stdin.nextChar()\ninline fun next() = stdin.next()\ninline fun nextLine() = stdin.nextLine()\ninline fun nextIntArray(n: Int) = IntArray(n, { nextInt() })\n\nclass FastScanner(ins: InputStream): Closeable {\n val BUFFER_SIZE = 65536;\n val br: BufferedReader\n var end = false\n\n var len: Int = 0\n val buffer = CharArray(BUFFER_SIZE)\n var it: Int = 0\n\n init {\n br = BufferedReader(InputStreamReader(ins), BUFFER_SIZE)\n }\n\n constructor(file: String): this(FileInputStream(file))\n\n inline fun isLineBreaker(c: Char) = c == '\\n'\n inline fun isDelimiter(c: Char) = c == ' ' || c == '\\n' || c == '\\r'\n\n inline fun ensureBuffer() {\n if (it == len) {\n it = 0\n len = br.read(buffer)\n if (len == -1) end = true\n }\n }\n\n inline fun moveNext() {\n while (!end) {\n ensureBuffer()\n if (!isDelimiter(buffer[it])) return\n while (it < len && isDelimiter(buffer[it])) it++;\n }\n }\n\n inline fun nextChar(): Char {\n moveNext()\n if (end) return (-1).toChar()\n return buffer[it++]\n }\n\n inline fun next(): String {\n moveNext()\n val sb = StringBuilder()\n while (!end) {\n val l = it\n while (++it < len && !isDelimiter(buffer[it]));\n sb.append(buffer, l, it - l)\n ensureBuffer()\n if (end || isDelimiter(buffer[it])) break;\n }\n return sb.toString()\n }\n\n inline fun nextInt(): Int {\n moveNext()\n var minus = true\n if (buffer[it] == '-') {\n it++\n minus = false\n }\n var result: Int = 0\n while (!end) {\n while (it < len && !isDelimiter(buffer[it])) {\n result *= 10\n result += (buffer[it] - '0').toInt()\n it++\n }\n ensureBuffer()\n if (end || isDelimiter(buffer[it])) break\n }\n return if (minus) result else -result\n }\n\n inline fun nextLong(): Long {\n moveNext()\n var minus = true\n if (buffer[it] == '-') {\n it++\n minus = false\n }\n var result: Long = 0\n while (!end) {\n while (it < len && !isDelimiter(buffer[it])) {\n result *= 10\n result += (buffer[it] - '0').toLong()\n it++\n }\n ensureBuffer()\n if (end || isDelimiter(buffer[it])) break\n }\n return if (minus) result else -result\n }\n\n inline fun nextLine(): String {\n moveNext()\n val sb = StringBuilder()\n while (!end) {\n val l = it\n while (++it < len && !isLineBreaker(buffer[it]));\n sb.append(buffer, l, it - l)\n ensureBuffer()\n if (end || isLineBreaker(buffer[it])) break;\n }\n return sb.toString()\n }\n\n override fun close() {\n br.close()\n }\n}\n\nfun main(args: Array) {\n solve()\n stdin.close()\n stdout.close();\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6c2fbd324442d7ad227dcb259d25296a", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n fun files(inputFilename: String, outputFilename: String) =\n ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))\n }\n\n var tok = StringTokenizer(\"\")\n\n fun close() { rd.close(); wr.close() }\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun readToken(): String {\n while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())\n return tok.nextToken()\n }\n fun readLine(): String {\n tok = StringTokenizer(\"\")\n return rd.readLine()\n }\n fun readInt(): Int = readToken().toInt()\n fun readLong(): Long = readToken().toLong()\n}\n\nfun main(args: Array) {\n Thread({ val io = ProblemIO.console(); solve(io); io.close() }).start()\n}\n\nfun solve(io: ProblemIO) {\n val n = io.readInt()\n val a = IntArray(n, { io.readInt() })\n val l = a.last()\n val res = when {\n l == 15 -> \"DOWN\"\n l == 0 -> \"UP\"\n else -> when {\n a.size == 1 -> \"-1\"\n l > a[a.lastIndex - 1] -> \"UP\"\n l < a[a.lastIndex - 1] -> \"DOWN\"\n else -> \"-1\"\n }\n }\n io.println(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bb045fbc0889a27040c6ba443696d1ae", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val n = r.readLine()!!.toInt()\n val v = r.readLine()!!.split(\" \").map { it.toInt() }\n if (n == 1) {\n when {\n v[0] == 0 -> println(\"UP\")\n v[0] == 15 -> println(\"DOWN\")\n else -> println(-1)\n }\n } else {\n val before = v[n - 2]\n val mid = v[n - 1]\n when {\n mid == 15 -> println(\"DOWN\")\n mid == 0 -> println(\"UP\")\n mid > before -> println(\"UP\")\n mid < before -> println(\"DOWN\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "86f9bad46beaaead275f25e9b9b44b14", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n val sizes = readInts()\n print(\n when {\n sizes.last() == 0 -> \"UP\"\n sizes.last() == 15 -> \"DOWN\"\n sizes.size == 1 -> \"-1\"\n sizes.last() > sizes[sizes.lastIndex - 1] -> \"UP\"\n else -> \"DOWN\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "912d78aacb86e603266dab7ad8aff0f8", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\n\nfun main() = bufferOut { readSolveWrite() }\n\nprivate const val MOD = 1000_000_007\n\nprivate val dp = IntArray(2001 * 2001 * 2) { -1 }\n\nfun compute(b: Int, r: Int, u: Int): Int {\n if (b < 0 || b > r || r == 0) return 0\n val index = (b * 2001 + r) * 2 + u\n dp[index].let { if (it >= 0) return it }\n var res = (compute(b + 1, r - 1, 0) + compute(b - 1, r - 1, 0)) % MOD\n if (u == 0) {\n if (b < r)\n res = modMax(res, (1 + compute(b + 1, r - 1, 1) + compute(b - 1, r - 1, 0)) % MOD)\n if (b > 0)\n res = modMax(res, (1 + compute(b + 1, r - 1, 0) + compute(b - 1, r - 1, 1)) % MOD)\n }\n dp[index] = res\n return res\n}\n\nfun modMax(a: Int, b: Int): Int =\n if ((a - b + MOD) % MOD < MOD / 2) a else b\n\nprivate fun PrintWriter.readSolveWrite() {\n val n = readLine()!!.toInt()\n println(compute(0, 2 * n, 0))\n}\n\nprivate fun bufferOut(block: PrintWriter.() -> Unit) = PrintWriter(System.out).use { block(it) }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d0ecf70522be4588f0450e488fb43751", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\nval INF_F = 1e-6\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val s = reader.next()\n for (i in 1 until s.length - 1) {\n if (s[i - 1] == '.' || s[i] == '.' || s[i + 1] == '.') {\n continue\n }\n\n if (s[i - 1] != s[i] && s[i - 1] != s[i + 1] && s[i] != s[i + 1]) {\n writer.println(\"yes\")\n return\n }\n }\n writer.println(\"no\")\n}\n\nfun gcd(a: Int, b: Int): Int {\n return if (b == 0) a else gcd(b, a % b)\n}\n\nclass InputReader(stream: InputStream) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4da2321982c1dcca9c497cdc1ee5c1f7", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val opa = readLine()!!\n var result = false\n for (i in 1..opa.length - 2){\n if (opa.get(i) != opa.get(i-1) \n && opa.get(i) != opa.get(i+1) \n && opa.get(i) != '.' \n && opa.get(i+1) != '.' \n && opa.get(i-1) != '.'\n && opa.get(i-1) != opa.get(i+1)){\n result = true\n }\n }\n if (result){\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "91a20c54261bc91716e6f5e0b9b6d3b7", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n val opa = readLine()\n if (opa == null){\n System.out.println(\"No\")\n return\n } else {\n var result = false\n for (i in 1..opa.length - 2){\n if (opa.get(i) != opa.get(i-1) \n && opa.get(i) != opa.get(i+1) \n && opa.get(i) != '.' \n && opa.get(i+1) != '.' \n && opa.get(i-1) != '.'){\n result = true\n }\n }\n if (result){\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "213711815292cc7bcf68b709749c13f3", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n val (numExams, requiredSum) = readLine()!!.split(\" \").map(String::toInt)\n if (requiredSum <= 2* numExams) return print(numExams)\n print(max(0, 3 * numExams - requiredSum))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "33198b85f1286d36c4c405959253ac31", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (numExams, requiredSum) = readLine()!!.split(\" \").map(String::toInt)\n if (requiredSum <= 2* numExams) return print(numExams)\n print(3 * numExams - requiredSum)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "43e332b273ea50b67fc20e28f6e86703", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val a = readLine()!!.split(\" \").map{ it.toInt() }.toMutableList()\n if (a[0] * 3 >= a[1]) {\n print(0)\n } else {\n print(a[0] * 3 - a[1])\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a3a0d55d55848adba6620e68231dee1b", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\nfun powMod(a: Long, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod(a * a % mod, n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n\n fun solve() {\n val S = ns()\n val Ss = (0 until 10).map { S.replace('X', '0'+it) }.distinct()\n val ans = Ss.map(::solve2).sum()\n out.println(ans)\n }\n\n fun solve2(S: String): Int {\n debug{\"solve2($S)\"}\n val N = S.length\n if (N < 3) {\n return solve_naive(S)\n }\n\n val head = S.take(max(0, N - 2)) // 0\u304b\u3082\u3057\u308c\u306a\u3044\n val fst = head.take(1)\n val snd = head.drop(1)\n val tail = S.drop(head.length)\n\n fun countTail(): Int {\n var cnt = 0\n for (num in 0 until 100) {\n if (num % 25 == 0 && accepts(tail, num) != null) cnt++\n }\n return cnt\n }\n\n fun countHead(): Int {\n if (fst.isEmpty()) return 1\n\n val c1 = when(fst[0]) {\n '_' -> 9\n '0' -> 0\n else -> 1\n }\n val underscores = snd.count { it == '_' }\n val c2 = powMod(10, underscores.toLong(), MOD).toInt()\n return c1 * c2\n }\n\n debug{\"countTail: ${countTail()} countHead${countHead()}\"}\n return countTail() * countHead()\n }\n\n fun solve_naive(S: String): Int {\n val N = S.length\n val max = powMod(10, N.toLong(), MOD).toInt()\n var cnt = 0\n for (num in 0 until max) {\n if (num % 25 != 0) continue\n val res = accepts(S, num) ?: continue\n if (res.length == 1 || res[0] != '0') cnt++\n }\n return cnt\n }\n\n fun accepts(S: String, num: Int): String? {\n val numStr = (\"00$num\").takeLast(S.length)\n val ok = numStr.indices.all { S[it] == '_' || S[it] == numStr[it] }\n return if (ok) numStr else null\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return IntArray(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n /**\n * \u30b3\u30fc\u30ca\u30fc\u30b1\u30fc\u30b9\u3067\u30a8\u30e9\u30fc\u51fa\u305f\u308a\u3059\u308b\u306e\u3067\u3001debug(dp[1])\u306e\u3088\u3046\u306b\u6dfb\u3048\u5b57\u4ed8\u304d\u306e\u5834\u5408\u306fdebug{}\u3092\u3064\u304b\u3046\u3053\u3068\n */\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { toString(a) }\n }\n\n private inline fun toString(a: BooleanArray) = run{a.map { if (it) 1 else 0 }.joinToString(\"\")}\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n private inline fun assert(b: Boolean, f: () -> String) = run{if (!b) throw AssertionError(f())}\n\n companion object {\n // TestRunner\u304b\u3089\u547c\u3073\u305f\u3044\u306e\u3067\u5358\u7d14\u306amain\u3058\u3083\u3060\u3081\n fun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n }\n }\n}\n\n/**\n * judge\u304b\u3089\u547c\u3070\u308c\u308b\n */\nfun main() = Solver.main()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9a8d52a5b3339660b353c8121e28797d", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\nfun powMod(a: Long, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod(a * a % mod, n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n\n fun solve() {\n val S = ns()\n val Ss = (0 until 10).map { S.replace('X', '0'+it) }.distinct()\n val ans = Ss.map(::solve2).sum()\n out.println(ans)\n }\n\n fun solve2(S: String): Int {\n debug{\"solve2($S)\"}\n val N = S.length\n if (N == 1) {\n return when(S[0]) {\n '0', '_' -> 1\n else -> 0\n }\n }\n\n val head = S.take(max(0, N - 2)) // 0\u304b\u3082\u3057\u308c\u306a\u3044\n val fst = head.take(1)\n val snd = head.drop(1)\n val tail = S.drop(head.length)\n\n fun countTail(): Int {\n var cnt = 0\n for (num in 0 until 100) {\n if (num % 25 != 0) continue\n val numStr = (\"0$num\").takeLast(2)\n val ok = numStr.indices.all { tail[it] == '_' || tail[it] == numStr[it] }\n if (ok) cnt++\n }\n return cnt\n }\n\n fun countHead(): Int {\n if (fst.isEmpty()) return 1\n\n val c1 = when(fst[0]) {\n '_' -> 9\n '0' -> 0\n else -> 1\n }\n val underscores = snd.count { it == '_' }\n val c2 = powMod(10, underscores.toLong(), MOD).toInt()\n return c1 * c2\n }\n\n debug{\"countTail: ${countTail()} countHead${countHead()}\"}\n return countTail() * countHead()\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return IntArray(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n /**\n * \u30b3\u30fc\u30ca\u30fc\u30b1\u30fc\u30b9\u3067\u30a8\u30e9\u30fc\u51fa\u305f\u308a\u3059\u308b\u306e\u3067\u3001debug(dp[1])\u306e\u3088\u3046\u306b\u6dfb\u3048\u5b57\u4ed8\u304d\u306e\u5834\u5408\u306fdebug{}\u3092\u3064\u304b\u3046\u3053\u3068\n */\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { toString(a) }\n }\n\n private inline fun toString(a: BooleanArray) = run{a.map { if (it) 1 else 0 }.joinToString(\"\")}\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n private inline fun assert(b: Boolean, f: () -> String) = run{if (!b) throw AssertionError(f())}\n\n companion object {\n // TestRunner\u304b\u3089\u547c\u3073\u305f\u3044\u306e\u3067\u5358\u7d14\u306amain\u3058\u3083\u3060\u3081\n fun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n }\n }\n}\n\n/**\n * judge\u304b\u3089\u547c\u3070\u308c\u308b\n */\nfun main() = Solver.main()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b65f82ad9455df1c4ef6ed9cee809927", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nval reader = BufferedReader(InputStreamReader(System.`in`))\nval writer = PrintWriter(System.out)\n\nval maxn = 50\n\n\nfun solve() {\n var (a, b, m) = reader.readLine()!!.split(\" \").map { it.toLong() }\n for (q in maxn downTo 1) {\n var coefficients = LongArray(q) { 1L }\n var r = LongArray(q) { 1L }\n r[0] = a\n for (i in 0 until q - 1) {\n coefficients[i] = (1L shl (q - i - 2))\n }\n var cur = 0L\n for (i in 0 until q) {\n cur += coefficients[i] * r[i]\n if (coefficients[i] * r[i] < 0) {\n cur = -1\n break\n }\n }\n if (cur < 0 || cur > b) {\n continue\n }\n for (i in 1 until q) {\n var rem = b - cur\n var addingValue = rem / coefficients[i]\n addingValue = Math.min(addingValue, m - 1 )\n r[i] += addingValue\n cur += addingValue * coefficients[i]\n }\n if (cur == b) {\n writer.print(\"$q \")\n var sum = 0L\n for (i in 0 until q) {\n var previousSum = sum\n sum += r[i]\n writer.print(\"$sum \")\n sum += previousSum\n }\n writer.print(\"\\n\")\n return\n } else {\n continue\n }\n }\n writer.print(\"-1\\n\")\n}\n\nfun main() {\n val q = reader.readLine()!!.toInt()\n for (i in 1..q) {\n solve()\n }\n writer.close()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a740903645c11bdc4a2bcfec742f2d02", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.io.*\n\nval reader = BufferedReader(InputStreamReader(System.`in`))\nval writer = PrintWriter(System.out)\n\nconst val maxN = 55\n\n\nfun solve() {\n var (a, b, m) = reader.readLine()!!.split(\" \").map { it.toLong() }\n for (q in maxN downTo 1) {\n var coefficients = LongArray(q) { 1L }\n var r = LongArray(q) { 1L }\n r[0] = a\n for (i in 0 until q - 1) {\n coefficients[i] = (1L shl (q - i - 2))\n }\n var cur = 0L\n for (i in 0 until q) {\n cur += coefficients[i] * r[i]\n if (coefficients[i] * r[i] < 0) {\n cur = -1\n break\n }\n }\n if (cur < 0 || cur > b) {\n continue\n }\n for (i in 1 until q) {\n var rem = b - cur\n var addingValue = rem / coefficients[i]\n addingValue = Math.min(addingValue, m - 1 )\n r[i] += addingValue\n cur += addingValue * coefficients[i]\n }\n if (cur == b) {\n writer.print(\"$q \")\n var sum = 0L\n for (i in 0 until q) {\n var previousSum = sum\n sum += r[i]\n writer.print(\"$sum \")\n sum += previousSum\n }\n writer.print(\"\\n\")\n return\n } else {\n continue\n }\n }\n writer.print(\"-1\\n\")\n}\n\nfun main() {\n val q = reader.readLine()!!.toInt()\n for (i in 1..q) {\n solve()\n }\n writer.close()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "643f9507298841bcbdd106cdc75f99fd", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.max\nimport java.lang.Long.min\nimport kotlin.math.max\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val q = readInt()\n\n repeat(q) {\n val (a, b, m) = readInts()\n fun f(x: Int) = 1L shl x\n\n var cur = a\n var sm = a\n var t = 0\n while (sm + 1 <= b) {\n cur = sm + 1\n sm += cur\n t++\n }\n\n val ans = mutableListOf(a)\n sm = a\n for (i in 1..t) {\n var temp = sm + 1\n val ff = f(max(0, t - i-1))\n val c = min((b - cur)/ ff, m-1)\n\n cur += c*ff\n temp += c\n ans.add(temp)\n sm += temp\n }\n if (cur != b)\n print(\"-1\\n\")\n else {\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6c6f9c48a4c30cd273d9b20796230f7e", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.max\nimport java.lang.Long.min\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val q = readInt()\n\n repeat(q) {\n val (a, b, m) = readInts()\n fun f(x: Int) = 1L shl x\n\n var cur = a\n var sm = a\n var t = 0\n while (sm + 1 < b) {\n cur = sm + 1\n sm += cur\n t++\n }\n\n val ans = mutableListOf(a)\n sm = a\n for (i in 1 until t) {\n var temp = sm + 1\n val ff = f(t - i)\n val c = min((b - cur)/ ff, m-1)\n\n cur += c*ff\n temp += c\n ans.add(temp)\n sm += temp\n }\n if (b - cur > m-1)\n print(\"-1\\n\")\n else {\n ans.add(b)\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "034b931d87510dbbf374cfef90b21cb5", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.max\nimport java.lang.Long.min\nimport kotlin.math.max\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val q = readInt()\n\n repeat(q) {\n val (a, b, m) = readInts()\n fun f(x: Int) = 1L shl x\n\n var cur = a\n var sm = a\n var t = 0\n while (sm + 1 <= b) {\n cur = sm + 1\n sm += cur\n t++\n }\n\n val ans = mutableListOf(a)\n sm = a\n for (i in 1..t) {\n var temp = sm + 1\n val ff = f(max(0, t - i-1))\n val c = min((b - cur)/ ff, m-1)\n\n cur += c*ff\n temp += c\n ans.add(temp)\n sm += temp\n }\n if (b - cur > m-1)\n print(\"-1\\n\")\n else {\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "393266414cd7709dd8adbbe94984d247", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.max\nimport java.lang.Long.min\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val q = readInt()\n\n repeat(q) {\n val (a, b, m) = readInts()\n var (l, r) = Pair(a, a)\n val segs = mutableListOf>()\n while (r < b) {\n if (l > a)\n segs.add(Pair(l, r))\n l = a\n r = a\n for (x in segs) {\n l += x.first\n r += x.second\n }\n l += 1\n r += m\n }\n if (l > b)\n print(\"-1\\n\")\n else {\n fun f(x: Int) = 1L shl x-1\n\n val ans = mutableListOf(a)\n var cur = l\n var sm = a\n for ((i, x) in segs.withIndex()) {\n var temp = sm + 1\n for (i in 0 until min(m-1, 1e9.toLong()).toInt()) {\n if (cur + f(segs.size-i) <= b) {\n temp++\n cur += f(segs.size-i)\n }\n else\n break\n }\n ans.add(temp)\n sm += temp\n }\n ans.add(b)\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "afad150e495c66ab875793c6a659d523", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toLong() } // list of ints\n\nfun main() {\n val q = readInt()\n\n repeat(q) {\n val (a, b, m) = readInts()\n var (l, r) = Pair(a, a)\n val segs = mutableListOf>()\n while (r < b) {\n segs.add(Pair(l, r))\n l = 0\n r = 0;\n for (x in segs) {\n l += x.first\n r += x.second\n }\n l += 1\n r += m\n }\n if (l > b)\n print(\"-1\\n\")\n else {\n val ans = mutableListOf(b)\n segs.reverse()\n for (x in segs) {\n ans.add(x.second)\n }\n ans.reverse()\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e88a4de9a948245d7770f6af10835361", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n\t// 0 -businka\n\t// 1 - nit'\n\tval busy = readLine().toString().map{if (it =='o') 0 else 1}\n\tval length = busy.size\n\tval nitN = busy.sum()\n\tval busyN = length - nitN\n\t//println(\"$busyN $nitN\")\n\tif (busyN == 0){\n\t\tprintln(\"YES\")\n\t\treturn\n\t}\n\tval zlp = nitN.rem(busyN)\n\tif (zlp.rem(2) == 0) println(\"YES\") else println(\"NO\")\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3541d42f451e239388925fadfebac0b3", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val chain = readLine()!!.toCharArray()\n checkChain(chain)\n}\n\nfun checkChain(chain: CharArray) {\n val char1 = '-'\n val char0 = 'o'\n\n val char1Count = chain.filter { it == char1 }.count()\n val char0Count = chain.filter { it == char0 }.count()\n\n if (char0Count == 0 || char1Count == 0) return print(\"YES\")\n\n if (char0Count > char1Count) {\n return if (char0Count % char1Count == 0) print(\"YES\") else print(\"NO\")\n } else if (char0Count < char1Count) {\n return if (char1Count % char0Count == 0) print(\"YES\") else print(\"NO\")\n } else if (char0Count == char1Count) {\n return print(\"YES\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7d44ea8411505e6752e0ba7763f44e4c", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val necklace = readLine()!!\n val numPearls = necklace.count { it == 'o' }\n print(if ((necklace.length - numPearls) % numPearls == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c6ad9ae59c57ffbda6984f8c3a5ef913", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (links, pearls) = readLine()!!.partition { it == '-' }\n println(if (links.length % pearls.length == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "736f2a464d24040a096c03b9a2e159f0", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import com.sun.org.apache.xpath.internal.operations.Bool\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.max\nimport kotlin.math.min\nimport java.io.IOException\nimport jdk.nashorn.internal.runtime.ScriptingFunctions.readLine\nimport java.util.StringTokenizer\nimport java.io.InputStreamReader\nimport java.io.BufferedReader\nimport java.io.InputStream\nimport kotlin.math.abs\n\nfun main(args: Array) {\n Thread { solve() }.start()\n}\n\nfun solve() {\n val scanner = Scanner(System.`in`)\n val str = scanner.next()\n var a = 0\n var b = 0\n for (c in str) {\n if (c == '-')\n b++\n else\n a++\n }\n if (a == 0 || b % a == 0)\n print(\"YES\")\n else\n print(\"NO\")\n\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\n//class Pair(val a: Int, val b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return a - other.a\n//", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b11eb14c38aea0bc2776f86bf864aab8", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val necklace = readLine()!!\n val numPearls = necklace.count { it == 'o' }\n if (numPearls == 0) return print(\"YES\")\n print(if ((necklace.length - numPearls) % numPearls == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0c7a2537effadb630f4e65ddbbb83e23", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val chain = readLine()!!.toCharArray()\n checkChain(chain)\n}\n\nfun checkChain(chain: CharArray) {\n val char1 = '-'\n val char0 = 'o'\n\n val char1Count = chain.filter { it == char1 }.count()\n val char0Count = chain.filter { it == char0 }.count()\n\n if (char0Count == 0 || char1Count == 0) return print(\"YES\")\n\n if (char0Count > char1Count) {\n return if (char0Count % char1Count == 0) print(\"YES\") else print(\"NO\")\n } else if (char0Count < char1Count) {\n return if (char1Count % char0Count == 0) print(\"YES\") else print(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3b4cf27a8a4c72a3499b5d86423bf956", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.SortedMap\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val r0 = readInt()\n val g0 = readInt()\n\n var D = HashMap()\n D.add(r0, g0, ModInt(1))\n\n for(h in 1..200000) {\n val Di = HashMap()\n for((state, v) in D) {\n var (r, g) = state\n if(r < h) r = 0\n if(g < h) g = 0\n if(r != 0) Di.add(r-h, g, v)\n if(g != 0) Di.add(r, g-h, v)\n }\n if(Di.isEmpty()) break\n D = Di\n }\n\n val ans = D.values.sum()\n\n println(ans.int)\n}\n\nfun MutableMap.add(r: Int, g: Int, v: ModInt) {\n val state = State(r, g)\n this[state] = (this[state] ?: ModInt(0)) + v\n}\n\ndata class State(val r: Int, val g: Int) {\n val hash = r.bitConcat(g).hash().toInt()\n override fun hashCode(): Int = hash\n}\n\nfun splitmix64(seed: Long): Long {\n var x = seed - 7046029254386353131\n x = (x xor (x ushr 30)) * -4658895280553007687\n x = (x xor (x ushr 27)) * -7723592293110705685\n return (x xor (x ushr 31))\n}\n@JvmField val nonce64 = random.nextLong()\nfun Long.hash() = splitmix64(nonce64 xor this)\n\nfun Int.bitConcat(other: Int) = toLong().shl(32) or other.toLong().and(0xffff_ffff)\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\nconst val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt(this umod MODINT_BASE)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n operator fun plus(other: ModInt) = // MODINT_BASE < 2^30\n (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)\n\n operator fun minus(other: ModInt) =\n (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent umod MODINT_TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent umod MODINT_TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun sum() = indices.sumByModInt(::get)\n fun product() = indices.productByModInt(::get)\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "19e7f01e1680480a92f13433dda56bb0", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val R = ni()\n val G = ni()\n var H = 0\n while((H + 1) * (H + 2) / 2 <= R + G) H++\n val N = min(R, G)\n var cur = IntArray(1_000_000)\n var next = IntArray(1_000_000)\n cur[0] = 1\n var sum = 0L\n for (i in H - 1 downTo 0) {\n val size = min(N, H * (H + 1) / 2 - i * (i + 1) / 2)\n val nsize = min(N, H * (H + 1) / 2 - (i + 1) * (i + 2) / 2)\n for (j in 0 .. size) {\n next[j] = 0\n if (j <= nsize) next[j] += cur[j]\n val nj = j - (i + 1)\n if ((0 .. nsize).contains(nj)) {\n next[j] += cur[nj]\n }\n if (next[j] > MOD) next[j] -= MOD\n }\n// debug(next.take(10).toLongArray())\n val tmp = cur\n cur = next\n next = tmp\n sum += size\n }\n debug{\"sum:$sum\"}\n var ans = 0L\n val remain = R + G - H * (H + 1) / 2\n for (r in 0 .. remain) {\n val j = N - r\n if (cur.indices.contains(j)) ans += cur[j]\n }\n out.println(ans % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b309c48136c364f2465a40cb97a560d", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.SortedMap\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val r0 = readInt()\n val g0 = readInt()\n\n var D = ModIntArray(r0 + 1)\n D[r0] = ModInt(1)\n\n for(h in 1..200000) {\n val Di = ModIntArray(r0 + 1)\n val s = g0 - h * (h-1) / 2 + r0\n var ok = false\n for(r in D.indices) {\n if(D[r].int == 0) continue\n val g = s - r\n if(r >= h) {\n Di[r-h] += D[r]\n ok = true\n }\n if(g >= h) {\n Di[r] += D[r]\n ok = true\n }\n }\n if(!ok) break\n D = Di\n }\n\n val ans = D.sum()\n\n println(ans.int)\n}\n\nfun MutableMap.add(state: Int, v: ModInt) {\n this[state] = (this[state] ?: ModInt(0)) + v\n}\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\nconst val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt(this umod MODINT_BASE)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n operator fun plus(other: ModInt) = // MODINT_BASE < 2^30\n (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)\n\n operator fun minus(other: ModInt) =\n (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent umod MODINT_TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent umod MODINT_TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun ModIntArray.sum() = indices.sumByModInt(::get)\nfun ModIntArray.product() = indices.productByModInt(::get)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ee5caab9ad49f575522d44da07039044", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.SortedMap\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val r0 = readInt()\n val g0 = readInt()\n\n var D = ModIntArray(r0 + 1)\n D[r0] = ModInt(1)\n\n for(h in 1..200000) {\n val Di = ModIntArray(D.size)\n val s = g0 - h * (h-1) / 2 + r0\n var ok = false\n for(r in D.indices) {\n val v = D[r]\n if(v.int == 0) continue\n val g = s - r\n if(r >= h) {\n Di[r-h] += v\n ok = true\n }\n if(g >= h) {\n Di[r] += v\n ok = true\n }\n }\n if(!ok) break\n D = Di\n }\n\n val ans = D.sum().int\n\n println(ans)\n}\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\nconst val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt(this umod MODINT_BASE)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n operator fun plus(other: ModInt) = // MODINT_BASE < 2^30\n (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)\n\n operator fun minus(other: ModInt) =\n (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent umod MODINT_TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent umod MODINT_TOTIENT)\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun ModIntArray.sum() = indices.sumByModInt(::get)\nfun ModIntArray.product() = indices.productByModInt(::get)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b829a16547858225a31c45feb9bccaae", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.min\n\n//30/11/2019\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val t = nextInt()\n for (i in 0 until t) {\n val n = nextInt()\n val k = nextInt()\n val d = nextInt()\n val series = (0 until n).map { nextInt() }.toIntArray()\n println(solve(series, k, d))\n }\n}\n\nfun solve(n: IntArray, k: Int, d: Int): Long {\n val diffSet = DiffSet(1000000)\n for (i in 0 until d) {\n diffSet.inc(n[i])\n }\n var minDiffSize = diffSet.diffSize\n for (j in 1 .. (n.size - d)) {\n diffSet.dec(n[j - 1])\n diffSet.inc(n[d + j - 1])\n minDiffSize = min(minDiffSize, diffSet.diffSize)\n }\n return minDiffSize\n}\n\nclass DiffSet(val size: Int) {\n private val myValues: IntArray = IntArray(size)\n var diffSize = 0L\n\n fun inc(v: Int) {\n if (myValues[v]++ == 0) {\n diffSize++\n }\n }\n\n fun dec(v: Int) {\n if (--myValues[v] == 0) {\n diffSize--\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1ebf7c1d08d6f1bcfa871d9569e1d3f8", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.Closeable\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main() {\n FastReader().use { rdr ->\n val t = rdr.nextInt()\n val output = IntArray(t)\n for (tc in 0 until t) {\n val n = rdr.nextInt()\n val k = rdr.nextInt()\n val d = rdr.nextInt()\n val a = IntArray(n) { rdr.nextInt() }\n var min = Int.MAX_VALUE\n val c = hashMapOf()\n for (j in 0 until d) {\n c.increment(a[j])\n }\n for (i in 0..(n - d)) {\n if (i != 0) {\n c.decrement(a[i - 1])\n c.increment(a[i + (d - 1)])\n }\n if (c.size < min) {\n min = c.size\n }\n }\n output[tc] = min\n }\n println(output.joinToString(\"\\n\"))\n }\n}\n\nprivate fun MutableMap.increment(key: T) {\n this[key] = this.getOrDefault(key, 0) + 1\n}\n\nprivate fun MutableMap.decrement(key: T) {\n val v = this.getOrDefault(key, 0)\n if (v == 1)\n remove(key)\n else\n this[key] = v - 1\n}\n\nclass FastReader() : Closeable {\n private val rdr = BufferedReader(InputStreamReader(System.`in`))\n private var tkn: StringTokenizer? = null\n\n fun nextLine(): String {\n return rdr.readLine()\n }\n\n fun nextInt(): Int {\n if (tkn == null || !tkn!!.hasMoreElements())\n tkn = StringTokenizer(nextLine())\n return tkn!!.nextToken().toInt()\n }\n\n override fun close() {\n rdr.close()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "65be03bab4d481306b050fe136a34574", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val tests = readLine()!!.toInt()\n for (test in 0 until tests) {\n val (n, k, d) = readLine()!!.split(\" \").map { it.toInt() }\n if (k == 1 || d == 1) {\n readLine()\n println(\"1\")\n } else {\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val current = mutableMapOf()\n for (i in 0 until d) {\n current[a[i]] = (current[a[i]] ?: 0) + 1\n }\n var m = current.keys.size\n var count = m\n for (i in d until n) {\n current[a[i - d]] = (current[a[i - d]] ?: 0) - 1\n if(current[a[i-d]]!! == 0) {\n count--\n }\n current[a[i]] = (current[a[i]] ?: 0) + 1\n if(current[a[i]]!! == 1) {\n count++\n }\n m = min(m, count)\n }\n println(m)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9d70df6da27a64bf06930d0e1b0b3f9d", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val t = readLine()!!.toInt()\n for (q in 1..t) {\n val (n, k, d) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var count = d\n for (i in 0..a.size - d) {\n val set = mutableSetOf()\n for (j in 0 until d) {\n set.add(a[i + j])\n }\n count = min(set.size, count)\n }\n println(count)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5b08920756da505792e93b88284d5946", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numQueries = readInt()\n val sols = IntArray(numQueries)\n for (query in 0 until numQueries) {\n val (totalDays, _, numConsecutiveDays) = readInts()\n val dayToShow = readInts()\n val showToNumDays = mutableMapOf().withDefault { 0 }\n for (day in 0 until numConsecutiveDays) {\n val show = dayToShow[day]\n showToNumDays[show] = showToNumDays.getValue(show) + 1\n }\n sols[query] = showToNumDays.size\n for (day in 1..totalDays - numConsecutiveDays) {\n val showToRemove = dayToShow[day - 1]\n val showToAdd = dayToShow[day + numConsecutiveDays - 1]\n showToNumDays[showToRemove] = showToNumDays.getValue(showToRemove) - 1\n if (showToNumDays[showToRemove] == 0) showToNumDays.remove(showToRemove)\n showToNumDays[showToAdd] = showToNumDays.getValue(showToAdd) + 1\n if (showToNumDays.size < sols[query]) sols[query] = showToNumDays.size\n }\n }\n print(sols.joinToString(System.lineSeparator()))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4f1c83d56ecd488bbdd41e8b0c69bb96", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readInt()\n repeat(t) {\n val (n, k, d) = readInts()\n val a = readInts()\n val cc = mutableListOf()\n for (i in 0..a.size - d) {\n val r = a.subList(i, i + d).toSet()\n cc.add(r.size)\n }\n println(cc.min())\n }\n}\n\nprivate fun readInt() = readLine()!!.toInt()\n\nprivate fun readInts() = readLine()!!.split(\" \").map { it.toInt() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b01e40f0f9a55430616ddf8c6d711085", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()\nfun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()\nfun readStringList() = readLine()!!.split(' ').toMutableList()\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\n\nfun main(args: Array) {\n\n val t = readInt()\n (1..t).forEach {\n val (n, k, d) = readIntList()\n val elems = Array(k, { 0 })\n val a = readIntList()\n\n var min = 1_000_000\n\n for(i in 0..n - d){\n var set = hashSetOf()\n var j = i\n\n while (j < i + d)\n set.add(a[j++])\n\n min = kotlin.math.min(min , set.size)\n }\n\n\n println(min)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94368152932e7ba5d6e47f2238218ad1", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.SortedMap\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln // immediate println for interactive\n\nfun main() {\n output {\n val T = readInt()\n\n repeat(T) {\n val n = readInt()\n val k = readInt()\n val d = readInt()\n val A = readIntArray(n)\n\n val bag = HashBag()\n for(i in 0 until d) {\n bag.add(A[i])\n }\n\n var ans = bag.numDistinct\n for(i in d until n) {\n bag.add(A[i])\n bag.remove(A[i-d])\n ans = min(ans, bag.numDistinct)\n }\n\n println(ans)\n }\n }\n}\n\nval Bag<*>.numDistinct get() = countMap.size\n\ninterface Bag : Collection {\n val countMap: Map\n\n fun getCount(element: T): Int = countMap[element] ?: 0\n val elements: Set get() = countMap.keys\n val entries: Set> get() = countMap.entries\n\n override fun iterator(): Iterator = sequence {\n for((e, cnt) in countMap) {\n repeat(cnt) { yield(e) }\n }\n }.iterator()\n\n override fun contains(element: T): Boolean = countMap.containsKey(element)\n}\n\nprivate fun Bag<*>._size() = countMap.values.sum()\nprivate fun Bag<*>._equals(other: Any?) = when {\n this === other -> true\n other is Bag<*> -> countMap == other.countMap\n else -> false\n}\nprivate fun Bag<*>._hashCode() = countMap.hashCode()\n\nclass BagImpl(override val countMap: Map): Bag, AbstractCollection() {\n override val size = _size()\n override fun equals(other: Any?) = _equals(other)\n override fun hashCode() = _hashCode()\n override fun contains(element: T) = super.contains(element)\n override fun iterator() = super.iterator()\n}\nfun Bag(countMap: Map): Bag = BagImpl(countMap)\n\ninterface MutableBag : Bag, MutableCollection {\n val _countMap: MutableMap\n var _size: Int\n\n override fun add(element: T): Boolean { add(element, 1); return true }\n fun add(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n _countMap[element] = oldCount + occurrences\n _size += occurrences\n return oldCount\n }\n\n override fun remove(element: T): Boolean = remove(element, 1) > 0\n fun remove(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n val m = minOf(occurrences, oldCount)\n when(oldCount) {\n 0 -> return 0\n m -> _countMap.remove(element)\n else -> _countMap[element] = oldCount - m\n }\n _size -= m\n return oldCount\n }\n\n fun setCount(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n if(occurrences == 0) _countMap.remove(element)\n else _countMap[element] = occurrences\n _size += occurrences - oldCount\n return oldCount\n }\n\n override fun iterator(): MutableIterator = object: MutableIterator {\n private val mapIterator = _countMap.iterator()\n private var rem = 0\n private lateinit var lastEntry: MutableMap.MutableEntry\n private var removed = true\n override fun hasNext() = rem > 0 || mapIterator.hasNext()\n override fun next(): T {\n if(rem == 0) {\n lastEntry = mapIterator.next()\n rem = lastEntry.value\n }\n rem--\n removed = false\n return lastEntry.key\n }\n override fun remove() {\n if(removed) error(\"\")\n lastEntry.setValue(lastEntry.value - 1)\n if(lastEntry.value == 0) mapIterator.remove()\n _size--\n removed = true\n }\n }\n}\n\nabstract class AbstractMutableBag: MutableBag, AbstractMutableCollection() {\n final override val countMap: Map get() = _countMap\n final override val size get() = _size\n override fun equals(other: Any?) = _equals(other)\n override fun hashCode() = _hashCode()\n override fun contains(element: T) = super.contains(element)\n override fun iterator() = super.iterator()\n override fun add(element: T): Boolean = super.add(element)\n override fun addAll(elements: Collection): Boolean =\n if(elements is Bag) {\n for((e, n) in elements.countMap) add(e, n)\n true\n } else super.addAll(elements)\n override fun remove(element: T): Boolean = super.remove(element)\n override fun removeAll(elements: Collection): Boolean =\n if(elements is Bag) {\n var modified = false\n for((e, n) in elements.countMap) if(remove(e, n) > 0) modified = true\n modified\n } else super.removeAll(elements)\n}\n\nclass HashBag(override val _countMap: HashMap): AbstractMutableBag() {\n constructor(): this(HashMap())\n\n override var _size = _size()\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9b488f70b5848be4257a0cdd83d8f588", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\n val t = readLine()!!.toInt()\n\n repeat(t) {\n val (n, k, d) = readLine()!!.split(\" \") .map{it.toInt()}\n val aa = readLine()!!.split(\" \").map{it.toInt()}\n\n var minCnt = Math.min(k, d)\n for (i in 0..n-d) {\n val cnt = aa.slice(i until i+d).toSet().size\n if (cnt < minCnt) minCnt = cnt\n }\n\n println(minCnt)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "201f4ddf533dfdae2dc36cbddf1151a2", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val map : MutableMap = mutableMapOf()\n\n val t = readLine()!!.toInt()\n repeat(t) {\n val (_, _, d) = readLine()!!\n .split(' ')\n .map { it.toInt() }\n\n val schedule = readLine()!!\n .split(' ')\n .map { it.toInt() }\n .toMutableList()\n\n map.clear()\n for (index in schedule.indices) {\n val serial = schedule[index]\n val day = index + 1\n\n map[serial] = day\n\n var count = 0\n for ((_, value) in map)\n if (day - value < d)\n count ++\n\n schedule[index] = if (day >= d)\n count\n else Int.MAX_VALUE\n }\n println(schedule.min())\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eee15ee133b0336a177e978f8768f616", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array ) {\n val t = readLine()!!.toInt()\n (1..t).forEach {\n val (n, k, d) = readLine()!!.split(\" \").map { it.toInt() }\n val x = readLine()!!.split(\" \").map { it.toInt() - 1 }\n var c = IntArray(k)\n var r = k\n var s = 0\n (0..n-1).forEach {\n if ( c[ x[it] ] == 0 ) s++\n c[ x[it] ] ++\n if ( it >= d ) {\n c[ x[ it-d ] ] --\n if ( c[ x[ it-d ] ] == 0 ) s--\n }\n if ( it >= d-1 ) {\n if ( s < r ) r = s\n }\n }\n println( r )\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "219015d54e523f3f85d9348df80d7293", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n\n var count = readLine()!!.toInt()\n\n for(c in 0 until count) {\n var (n, k, d) = readLine()!!.split(\" \").map { it.toInt() }\n var numbers = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\n var set = numbers.take(k).toMutableSet()\n var numNumber = set.size\n for(i in k until n) {\n set.remove(numbers[i - k])\n set.add(numbers[i])\n numNumber = Math.min(numNumber, set.size)\n }\n\n println(numNumber)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9c4c8265c5ce4b2d7cf377e2e7b7bdab", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.sqrt\n\ntypealias IndexPair = Pair\ntypealias IntIndexPair = IndexPair\ntypealias IntIntPair = Pair\n\ntypealias IntMatrix = Array\ntypealias LongMatrix = Array\n\ntypealias ListArray = Array>\n\ntypealias Graph = IntMatrix\n\ntypealias Edge = Pair\ntypealias EdgeArray = Array\ntypealias WeightedGraph = Array\n\ntypealias TotalEdge = Triple\ntypealias TotalEdgeArray = Array\n\nfun init() { }\n\nconst val MODULO = 1000 * 1000 * 1000 + 7\n\nfun solve() {\n val n = readLong() - 1\n\n var nearestRoot = sqrt(n * 2.0).toLong()\n while (nearestRoot * (nearestRoot + 1) > 2 * n) --nearestRoot\n val sum = nearestRoot * (nearestRoot + 1) / 2\n\n val answer = n - sum\n out.println(answer + 1)\n}\n\nfun stress() {\n val rnd = Random(1234)\n\n for (it in 0 until 100) {\n val expected = brute()\n val actual = fast()\n\n if (expected != actual) {\n System.err.println(\"Gotcha!\")\n System.err.println(\"$expected $actual\")\n\n break\n }\n }\n}\n\n\nfun fast() {\n\n}\n\nfun brute() {\n\n}\n\nfun Long.mod() : Long {\n var result = this % MODULO\n if (result < 0) result += MODULO\n return result\n}\n\ninfix fun Long.add(other : Long) = (this + other).mod()\ninfix fun Long.sub(other : Long) = this add -other.mod()\ninfix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()\n\nfun Long.even() = (this and 1L) == 0L\nfun Long.odd() = !even()\n\nfun Int.even() = (this and 1) == 0\nfun Int.odd() = !even()\n\ninfix fun Long.binpow(power : Long) : Long {\n if (power == 0L) return 1L\n\n val half = binpow(power shl 1)\n\n var result = half mult half\n if (power.odd()) {\n result = result mult this\n }\n\n return result\n}\n\nval stepsXY = arrayOf(\n arrayOf(0, -1),\n arrayOf(0, 1),\n arrayOf(-1, 0),\n arrayOf(1, 0)\n)\n\n\n\nclass IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {\n\n private val graph : Graph\n\n private fun buildGraphForEdges(\n edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }\n ) : Graph {\n val builder = GraphBuilder()\n edges\n .forEachIndexed { index, edge ->\n if (edgeFilter(index, edge)) {\n val (first, second, _ ) = edge\n\n builder.addDirectedEdge(first, index)\n builder.addDirectedEdge(second, index)\n }\n }\n\n return builder.build(n)\n }\n\n init {\n graph = buildGraphForEdges()\n }\n\n var root : Int = -1\n lateinit var inTree : BooleanArray\n lateinit var tree : Graph\n\n fun kruskalTree(root : Int) : Long {\n this.root = root\n\n inTree = BooleanArray(edges.size) { false }\n\n val dsu = DSU(n)\n\n edges\n .mapIndexed { index, (_, _, w) -> index to w }\n .sortedBy { it.second }\n .forEach {\n val edge = edges[it.first]\n inTree[it.first] = dsu.union(edge.first, edge.second)\n }\n\n tree = buildGraphForEdges { index, _ -> inTree[index] }\n\n return edges\n .mapIndexed { index, (_, _, w) -> if (inTree[index]) w.toLong() else 0L }\n .sum()\n }\n\n private fun to(from : Int, index : Int) : Int {\n val edge = edges[index]\n return if (from == edge.first) edge.second else edge.first\n }\n\n fun buildLca() {\n calculateTimes()\n calculateParents()\n calculatePathInfo()\n }\n\n lateinit var timesIn : IntArray\n lateinit var timesOut : IntArray\n private var time = -1\n\n private fun calculateTimes() {\n timesIn = IntArray(n) { -1 }\n timesOut = IntArray(n) { -1 }\n this.time = 0\n\n timeDfs(root)\n }\n\n private fun timeDfs(from : Int, parent : Int = -1) {\n timesIn[from] = time++\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n timeDfs(to, from)\n }\n\n timesOut[from] = time++\n }\n\n lateinit var parents : Array\n private val maxBit = 19\n\n private fun calculateParents() {\n parents = Array(maxBit) { IntArray(n) { -1 } }\n\n parentDfs(root, root)\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n parents[bit + 1][v] = parents[bit][parent]\n }\n }\n }\n\n private fun parentDfs(from : Int, parent : Int = -1) {\n parents[0][from] = parent\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n parentDfs(to, from)\n }\n }\n\n lateinit var maxEdges : Array\n\n private fun calculatePathInfo() {\n maxEdges = Array(maxBit) { IntArray(n) { -1 } }\n\n for (v in 0 until n){\n for (index in tree[v]) {\n val to = to(v, index)\n if (to == parents[0][v]) continue\n\n maxEdges[0][to] = edges[index].third\n }\n }\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n maxEdges[bit + 1][v] = max(\n maxEdges[bit][v],\n maxEdges[bit][parent]\n )\n }\n }\n }\n\n fun getOnPath(a : Int, b : Int) : Int {\n var answer = Int.MIN_VALUE\n\n answer = max(answer, getOnLcaPath(a, b))\n answer = max(answer, getOnLcaPath(b, a))\n\n return answer\n }\n\n private fun getOnLcaPath(start : Int, other : Int) : Int {\n var answer = Int.MIN_VALUE\n\n if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {\n return answer\n }\n\n var v = start\n for (bit in maxBit - 1 downTo 0) {\n val parent = parents[bit][v]\n if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {\n answer = max(answer, maxEdges[bit][v])\n v = parent\n }\n }\n\n answer = max(answer, maxEdges[0][v])\n\n return answer\n }\n}\n\nfun yesNo(yes : Boolean) {\n out.println(if (yes) \"YES\" else \"NO\")\n}\n\nfun run() {\n init()\n solve()\n out.close()\n}\n\nfun main(args: Array) {\n run()\n}\n\nval ONLINE_JUDGE = !File(\"input.txt\").exists()\n\nval input = BufferedReader(\n if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader(\"input.txt\")\n)\nval out =\n if (ONLINE_JUDGE) PrintWriter(System.out)\n else PrintWriter(\"output.txt\")\n\nfun readStrings(separator: String = \" \", emptyWords: Boolean = false) : Array {\n val line = input.readLine()\n\n val list = ArrayList()\n var builder = StringBuilder()\n\n for (i in 0..line.length) {\n if (i == line.length || separator.contains(line[i])) {\n if (emptyWords || builder.isNotEmpty()) {\n list.add(builder.toString())\n builder = StringBuilder()\n }\n } else {\n builder.append(line[i])\n }\n }\n\n return list.toTypedArray()\n}\n\nfun readString(separator: String = \" \") =\n readStrings(separator).first()\n\nfun readInts(separator: String = \" \") =\n readStrings(separator).map(String::toInt).toIntArray()\n\nfun readDecreasedInts(separator : String = \" \") =\n readInts(separator).map { it - 1 }.toIntArray()\n\nfun readSortedInts(separator: String = \" \") : IntArray {\n val a = readInts(separator)\n\n val aInteger = Array(a.size) { a[it] }\n Arrays.sort(aInteger)\n\n return aInteger.toIntArray()\n}\n\nfun readInt(separator: String = \" \") =\n readInts(separator).first()\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun readLong(separator: String = \" \") =\n readLongs(separator).first()\n\nfun readDoubles(separator: String = \" \") =\n readStrings(separator).map(String::toDouble).toDoubleArray()\n\nfun readDouble(separator: String = \" \") =\n readDoubles(separator).first()\n\nfun readBigIntegers(separator: String = \" \") =\n readStrings(separator).map { BigInteger(it) }.toTypedArray()\n\nfun readBigInteger(separator: String = \" \") =\n readBigIntegers(separator).first()\n\nfun readTree(n : Int, indexing : Int = 1) =\n readGraph(n, n - 1, true, indexing)\n\nfun readGraph(n: Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : Graph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to)\n else builder.addDirectedEdge(from, to)\n }\n\n return builder.build(n)\n}\n\nfun readWeightedGraph(n : Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : WeightedGraph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to, weight) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to, weight)\n else builder.addDirectedEdge(from, to, weight)\n }\n\n return builder.buildWeighted(n)\n}\n\nfun readTotalEdges(m : Int, indexing : Int = 1) =\n TotalEdgeArray(m) {\n var (from, to, w) = readInts()\n\n from -= indexing\n to -= indexing\n\n Triple(from, to, w)\n }\n\nclass GraphBuilder {\n\n private val froms = ArrayList()\n private val tos = ArrayList()\n private val weights = ArrayList()\n\n fun addEdge(from : Int, to : Int, weight : Int = 1) {\n addDirectedEdge(from, to, weight)\n addDirectedEdge(to, from, weight)\n }\n\n fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {\n froms.add(from)\n tos.add(to)\n weights.add(weight)\n }\n\n private fun calculateFromSizes(n : Int) : IntArray {\n val sizes = IntArray(n) { 0 }\n froms.forEach { ++sizes[it] }\n return sizes\n }\n\n fun build(n : Int) : Graph {\n val sizes = calculateFromSizes(n)\n\n val graph = Graph(n) { IntArray(sizes[it]) { 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n\n graph[from][sizes[from]++] = to\n }\n\n return graph\n }\n\n fun buildWeighted(n : Int) : WeightedGraph {\n val sizes = calculateFromSizes(n)\n\n val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n val weight = weights[i]\n\n graph[from][sizes[from]++] = to to weight\n }\n\n return graph\n }\n}\n\nfun gcd(a : Int, b : Int) : Int =\n if (a == 0) b else gcd(b % a, a)\n\nfun gcd(a : Long, b : Long) : Long =\n if (a == 0L) b else gcd(b % a, a)\n\nfun getDivisors(x : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 1\n while (d * d <= x) {\n if (x % d == 0) {\n if (d != 1) divisors.add(d)\n if (x != d) divisors.add(x / d)\n }\n\n ++d\n }\n\n return divisors\n}\n\nfun getPrimeDivisors(xx : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 2\n var x = xx\n while (d * d <= x) {\n if (x % d == 0) {\n divisors.add(d)\n while (x % d == 0) {\n x /= d\n }\n }\n\n ++d\n }\n\n if (x > 1) divisors.add(x)\n\n return divisors\n}\n\nfun checkIndex(index : Int, size : Int) =\n 0 <= index && index < size\n\nfun checkCell(x : Int, n : Int, y : Int, m : Int) =\n checkIndex(x, n) && checkIndex(y, m)\n\nfun toChar(index : Int, start : Char) =\n (index + start.toInt()).toChar()\n\nclass DSU {\n\n var sizes : IntArray\n var ranks : IntArray\n var parents : IntArray\n\n constructor(n : Int)\n : this(\n IntArray(n) { 1 }\n )\n\n constructor(sizes : IntArray) {\n val size = sizes.size\n this.sizes = sizes\n this.ranks = IntArray(size) { 1 }\n this.parents = IntArray(size) { it }\n }\n\n operator fun get(v : Int) : Int {\n val parent = parents[v]\n if (parent == v) return v\n parents[v] = get(parent)\n return parents[v]\n }\n\n fun union(aUniting : Int, bUniting : Int) : Boolean {\n var a = get(aUniting)\n var b = get(bUniting)\n\n if (a == b) return false\n\n if (ranks[a] < ranks[b]) {\n val tmp = a\n a = b\n b = tmp\n }\n\n parents[b] = a\n sizes[a] += sizes[b]\n if (ranks[a] == ranks[b]) ++ranks[a]\n\n return true\n }\n\n fun size(v : Int) : Int = sizes[get(v)]\n}\n\nclass FenwickTree(n : Int) {\n\n val size = n + 1\n val tree = LongArray(size) { 0L }\n\n fun update(index : Int, delta : Int) {\n var x = index + 1\n while (x < size) {\n tree[x] = tree[x] + delta\n x += x and -x\n }\n }\n\n operator fun get(start : Int, end : Int) =\n get(end) - get(start - 1)\n\n operator fun get(index : Int) : Long {\n var result : Long = 0\n\n var x = index + 1\n while (x > 0) {\n result += tree[x]\n x -= x and -x\n }\n\n return result\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "93631cb73698d19bb70d48c1d30833e0", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLong() - 1\n\n val bs = (1..2e7.toLong()).binarySearchBy {\n regime(it).compareTo(n)\n }\n\n val l = bs.value - if(bs.exactFound) 0 else 1\n val ans = n - regime(l) + 1\n\n println(ans)\n}\n\nfun regime(l: Long) = l * (l-1) / 2\n\nfun LongRange.binarySearchBy(goldilocks: (Long) -> Int): BinarySearchResult {\n var low = start\n var high = endInclusive\n\n while (low <= high) {\n val mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2\n val cmp = goldilocks(mid)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return BinarySearchResult(mid, true) // key found\n }\n return BinarySearchResult(low, false) // key not found\n}\ndata class BinarySearchResult(val value: T, val exactFound: Boolean)\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\nfun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cb870ee87c58aa52c19980a1c7a78cc0", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val n = readLong()\n\n if (n == 1L) {\n println(1)\n return\n }\n var counter = 1L\n\n var i = 1L\n var ans = 0L\n while (i <= n) {\n// println(i)\n if (i + counter >= n) {\n ans = 1 + (n - i)\n// break\n }\n\n i += counter\n counter++\n }\n println(ans)\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // li\nprivate fun readLongs() = readStrings().map { it.toLong() } // li", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dc04847930bf42bc3cb12a4a7950c34f", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun readLong() = readLine()!!.toLong()\n\n val n = readLong() - 1\n val x = ((sqrt((1 + 8 * n).toDouble()) - 1) / 2).toLong()\n print(1 + n - (x * (x + 1) / 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c3d624ca5634a0898972885fcabd16f3", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val n = readLong()\n\n if (n == 1L) {\n println(1)\n return\n }\n var counter = 1\n\n var i = 1\n var ans = 0L\n while (i <= n) {\n if (i + counter >= n) {\n ans = 1 + (n - i)\n break\n }\n\n i += counter\n counter++\n }\n println(ans)\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // li\nprivate fun readLongs() = readStrings().map { it.toLong() } // li", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7d812b64a3bbf1c7a5242b6cd2d221f9", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.sqrt\n\nfun main() {\n fun readLong() = readLine()!!.toLong()\n\n val n = readLong() - 1\n val x = ((sqrt((1 + 8 * n).toFloat()) - 1) / 2).toInt()\n print(1 + n - (x * (x + 1) / 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4b790883506a8c73e69c128e16c1834c", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.*\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\nimport kotlin.math.sqrt\n\ntypealias IndexPair = Pair\ntypealias IntIndexPair = IndexPair\ntypealias IntIntPair = Pair\n\ntypealias IntMatrix = Array\ntypealias LongMatrix = Array\n\ntypealias ListArray = Array>\n\ntypealias Graph = IntMatrix\n\ntypealias Edge = Pair\ntypealias EdgeArray = Array\ntypealias WeightedGraph = Array\n\ntypealias TotalEdge = Triple\ntypealias TotalEdgeArray = Array\n\nfun init() { }\n\nconst val MODULO = 1000 * 1000 * 1000 + 7\n\nfun solve() {\n val n = readLong() - 1\n\n val nearestRoot = sqrt(n * 2.0).toLong()\n val sum = nearestRoot * (nearestRoot + 1) / 2\n\n val answer = n - sum\n out.println(answer + 1)\n}\n\nfun stress() {\n val rnd = Random(1234)\n\n for (it in 0 until 100) {\n val expected = brute()\n val actual = fast()\n\n if (expected != actual) {\n System.err.println(\"Gotcha!\")\n System.err.println(\"$expected $actual\")\n\n break\n }\n }\n}\n\n\nfun fast() {\n\n}\n\nfun brute() {\n\n}\n\nfun Long.mod() : Long {\n var result = this % MODULO\n if (result < 0) result += MODULO\n return result\n}\n\ninfix fun Long.add(other : Long) = (this + other).mod()\ninfix fun Long.sub(other : Long) = this add -other.mod()\ninfix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()\n\nfun Long.even() = (this and 1L) == 0L\nfun Long.odd() = !even()\n\nfun Int.even() = (this and 1) == 0\nfun Int.odd() = !even()\n\ninfix fun Long.binpow(power : Long) : Long {\n if (power == 0L) return 1L\n\n val half = binpow(power shl 1)\n\n var result = half mult half\n if (power.odd()) {\n result = result mult this\n }\n\n return result\n}\n\nval stepsXY = arrayOf(\n arrayOf(0, -1),\n arrayOf(0, 1),\n arrayOf(-1, 0),\n arrayOf(1, 0)\n)\n\n\n\nclass IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {\n\n private val graph : Graph\n\n private fun buildGraphForEdges(\n edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }\n ) : Graph {\n val builder = GraphBuilder()\n edges\n .forEachIndexed { index, edge ->\n if (edgeFilter(index, edge)) {\n val (first, second, _ ) = edge\n\n builder.addDirectedEdge(first, index)\n builder.addDirectedEdge(second, index)\n }\n }\n\n return builder.build(n)\n }\n\n init {\n graph = buildGraphForEdges()\n }\n\n var root : Int = -1\n lateinit var inTree : BooleanArray\n lateinit var tree : Graph\n\n fun kruskalTree(root : Int) : Long {\n this.root = root\n\n inTree = BooleanArray(edges.size) { false }\n\n val dsu = DSU(n)\n\n edges\n .mapIndexed { index, (_, _, w) -> index to w }\n .sortedBy { it.second }\n .forEach {\n val edge = edges[it.first]\n inTree[it.first] = dsu.union(edge.first, edge.second)\n }\n\n tree = buildGraphForEdges { index, _ -> inTree[index] }\n\n return edges\n .mapIndexed { index, (_, _, w) -> if (inTree[index]) w.toLong() else 0L }\n .sum()\n }\n\n private fun to(from : Int, index : Int) : Int {\n val edge = edges[index]\n return if (from == edge.first) edge.second else edge.first\n }\n\n fun buildLca() {\n calculateTimes()\n calculateParents()\n calculatePathInfo()\n }\n\n lateinit var timesIn : IntArray\n lateinit var timesOut : IntArray\n private var time = -1\n\n private fun calculateTimes() {\n timesIn = IntArray(n) { -1 }\n timesOut = IntArray(n) { -1 }\n this.time = 0\n\n timeDfs(root)\n }\n\n private fun timeDfs(from : Int, parent : Int = -1) {\n timesIn[from] = time++\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n timeDfs(to, from)\n }\n\n timesOut[from] = time++\n }\n\n lateinit var parents : Array\n private val maxBit = 19\n\n private fun calculateParents() {\n parents = Array(maxBit) { IntArray(n) { -1 } }\n\n parentDfs(root, root)\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n parents[bit + 1][v] = parents[bit][parent]\n }\n }\n }\n\n private fun parentDfs(from : Int, parent : Int = -1) {\n parents[0][from] = parent\n\n for (index in tree[from]) {\n val to = to(from, index)\n if (to == parent) continue\n\n parentDfs(to, from)\n }\n }\n\n lateinit var maxEdges : Array\n\n private fun calculatePathInfo() {\n maxEdges = Array(maxBit) { IntArray(n) { -1 } }\n\n for (v in 0 until n){\n for (index in tree[v]) {\n val to = to(v, index)\n if (to == parents[0][v]) continue\n\n maxEdges[0][to] = edges[index].third\n }\n }\n\n for (bit in 0 until maxBit - 1) {\n for (v in 0 until n) {\n val parent = parents[bit][v]\n maxEdges[bit + 1][v] = max(\n maxEdges[bit][v],\n maxEdges[bit][parent]\n )\n }\n }\n }\n\n fun getOnPath(a : Int, b : Int) : Int {\n var answer = Int.MIN_VALUE\n\n answer = max(answer, getOnLcaPath(a, b))\n answer = max(answer, getOnLcaPath(b, a))\n\n return answer\n }\n\n private fun getOnLcaPath(start : Int, other : Int) : Int {\n var answer = Int.MIN_VALUE\n\n if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {\n return answer\n }\n\n var v = start\n for (bit in maxBit - 1 downTo 0) {\n val parent = parents[bit][v]\n if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {\n answer = max(answer, maxEdges[bit][v])\n v = parent\n }\n }\n\n answer = max(answer, maxEdges[0][v])\n\n return answer\n }\n}\n\nfun yesNo(yes : Boolean) {\n out.println(if (yes) \"YES\" else \"NO\")\n}\n\nfun run() {\n init()\n solve()\n out.close()\n}\n\nfun main(args: Array) {\n run()\n}\n\nval ONLINE_JUDGE = !File(\"input.txt\").exists()\n\nval input = BufferedReader(\n if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader(\"input.txt\")\n)\nval out =\n if (ONLINE_JUDGE) PrintWriter(System.out)\n else PrintWriter(\"output.txt\")\n\nfun readStrings(separator: String = \" \", emptyWords: Boolean = false) : Array {\n val line = input.readLine()\n\n val list = ArrayList()\n var builder = StringBuilder()\n\n for (i in 0..line.length) {\n if (i == line.length || separator.contains(line[i])) {\n if (emptyWords || builder.isNotEmpty()) {\n list.add(builder.toString())\n builder = StringBuilder()\n }\n } else {\n builder.append(line[i])\n }\n }\n\n return list.toTypedArray()\n}\n\nfun readString(separator: String = \" \") =\n readStrings(separator).first()\n\nfun readInts(separator: String = \" \") =\n readStrings(separator).map(String::toInt).toIntArray()\n\nfun readDecreasedInts(separator : String = \" \") =\n readInts(separator).map { it - 1 }.toIntArray()\n\nfun readSortedInts(separator: String = \" \") : IntArray {\n val a = readInts(separator)\n\n val aInteger = Array(a.size) { a[it] }\n Arrays.sort(aInteger)\n\n return aInteger.toIntArray()\n}\n\nfun readInt(separator: String = \" \") =\n readInts(separator).first()\n\nfun readLongs(separator: String = \" \") =\n readStrings(separator).map(String::toLong).toLongArray()\n\nfun readLong(separator: String = \" \") =\n readLongs(separator).first()\n\nfun readDoubles(separator: String = \" \") =\n readStrings(separator).map(String::toDouble).toDoubleArray()\n\nfun readDouble(separator: String = \" \") =\n readDoubles(separator).first()\n\nfun readBigIntegers(separator: String = \" \") =\n readStrings(separator).map { BigInteger(it) }.toTypedArray()\n\nfun readBigInteger(separator: String = \" \") =\n readBigIntegers(separator).first()\n\nfun readTree(n : Int, indexing : Int = 1) =\n readGraph(n, n - 1, true, indexing)\n\nfun readGraph(n: Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : Graph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to)\n else builder.addDirectedEdge(from, to)\n }\n\n return builder.build(n)\n}\n\nfun readWeightedGraph(n : Int, m : Int,\n undirected : Boolean = true,\n indexing : Int = 1) : WeightedGraph {\n val builder = GraphBuilder()\n\n for (i in 1..m) {\n var (from, to, weight) = readInts()\n\n from -= indexing\n to -= indexing\n\n if (undirected) builder.addEdge(from, to, weight)\n else builder.addDirectedEdge(from, to, weight)\n }\n\n return builder.buildWeighted(n)\n}\n\nfun readTotalEdges(m : Int, indexing : Int = 1) =\n TotalEdgeArray(m) {\n var (from, to, w) = readInts()\n\n from -= indexing\n to -= indexing\n\n Triple(from, to, w)\n }\n\nclass GraphBuilder {\n\n private val froms = ArrayList()\n private val tos = ArrayList()\n private val weights = ArrayList()\n\n fun addEdge(from : Int, to : Int, weight : Int = 1) {\n addDirectedEdge(from, to, weight)\n addDirectedEdge(to, from, weight)\n }\n\n fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {\n froms.add(from)\n tos.add(to)\n weights.add(weight)\n }\n\n private fun calculateFromSizes(n : Int) : IntArray {\n val sizes = IntArray(n) { 0 }\n froms.forEach { ++sizes[it] }\n return sizes\n }\n\n fun build(n : Int) : Graph {\n val sizes = calculateFromSizes(n)\n\n val graph = Graph(n) { IntArray(sizes[it]) { 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n\n graph[from][sizes[from]++] = to\n }\n\n return graph\n }\n\n fun buildWeighted(n : Int) : WeightedGraph {\n val sizes = calculateFromSizes(n)\n\n val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }\n\n for (i in 0 until n) {\n sizes[i] = 0\n }\n\n for (i in 0 until froms.size) {\n val from = froms[i]\n val to = tos[i]\n val weight = weights[i]\n\n graph[from][sizes[from]++] = to to weight\n }\n\n return graph\n }\n}\n\nfun gcd(a : Int, b : Int) : Int =\n if (a == 0) b else gcd(b % a, a)\n\nfun gcd(a : Long, b : Long) : Long =\n if (a == 0L) b else gcd(b % a, a)\n\nfun getDivisors(x : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 1\n while (d * d <= x) {\n if (x % d == 0) {\n if (d != 1) divisors.add(d)\n if (x != d) divisors.add(x / d)\n }\n\n ++d\n }\n\n return divisors\n}\n\nfun getPrimeDivisors(xx : Int) : MutableList {\n val divisors = ArrayList()\n\n var d = 2\n var x = xx\n while (d * d <= x) {\n if (x % d == 0) {\n divisors.add(d)\n while (x % d == 0) {\n x /= d\n }\n }\n\n ++d\n }\n\n if (x > 1) divisors.add(x)\n\n return divisors\n}\n\nfun checkIndex(index : Int, size : Int) =\n 0 <= index && index < size\n\nfun checkCell(x : Int, n : Int, y : Int, m : Int) =\n checkIndex(x, n) && checkIndex(y, m)\n\nfun toChar(index : Int, start : Char) =\n (index + start.toInt()).toChar()\n\nclass DSU {\n\n var sizes : IntArray\n var ranks : IntArray\n var parents : IntArray\n\n constructor(n : Int)\n : this(\n IntArray(n) { 1 }\n )\n\n constructor(sizes : IntArray) {\n val size = sizes.size\n this.sizes = sizes\n this.ranks = IntArray(size) { 1 }\n this.parents = IntArray(size) { it }\n }\n\n operator fun get(v : Int) : Int {\n val parent = parents[v]\n if (parent == v) return v\n parents[v] = get(parent)\n return parents[v]\n }\n\n fun union(aUniting : Int, bUniting : Int) : Boolean {\n var a = get(aUniting)\n var b = get(bUniting)\n\n if (a == b) return false\n\n if (ranks[a] < ranks[b]) {\n val tmp = a\n a = b\n b = tmp\n }\n\n parents[b] = a\n sizes[a] += sizes[b]\n if (ranks[a] == ranks[b]) ++ranks[a]\n\n return true\n }\n\n fun size(v : Int) : Int = sizes[get(v)]\n}\n\nclass FenwickTree(n : Int) {\n\n val size = n + 1\n val tree = LongArray(size) { 0L }\n\n fun update(index : Int, delta : Int) {\n var x = index + 1\n while (x < size) {\n tree[x] = tree[x] + delta\n x += x and -x\n }\n }\n\n operator fun get(start : Int, end : Int) =\n get(end) - get(start - 1)\n\n operator fun get(index : Int) : Long {\n var result : Long = 0\n\n var x = index + 1\n while (x > 0) {\n result += tree[x]\n x -= x and -x\n }\n\n return result\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce785d65b2d71f882b04fc4adde7589a", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val n = readLong()\n\n if (n == 1L) {\n println(1)\n return\n }\n var counter = 1\n\n var i = 1\n var ans = 0L\n while (i <= n) {\n if (i + counter >= n) {\n ans = 1 + (n - i)\n }\n\n i += counter\n counter++\n }\n println(ans)\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // li\nprivate fun readLongs() = readStrings().map { it.toLong() } // li", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "49248f49f55618d62dc766b237d2d679", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nconst val IMPOSSIBLE = -100000000000000000L\n\nfun main() {\n val k = readLine()!!.toInt()\n val fs = readLine()!!.split(\" \").map { it.toLong() }\n readLine()\n val n = readLine()!!.toInt()\n var dpPrev = LongArray(n + 1) { IMPOSSIBLE }\n dpPrev[0] = 0L\n val segTrees = Array(3) { SegmentTree(0, n / 10) }\n for (e in 5 downTo 0) {\n for (t in 0..2) {\n segTrees[t].value.fill(IMPOSSIBLE)\n }\n for (j in 0..n / 10) {\n segTrees[j % 3][j] = dpPrev[j] - (((10 * j) / 3).toLong() * fs[e])\n }\n val dp = LongArray(n + 1) { IMPOSSIBLE }\n for (j in 0..n) {\n for (t in 0..2) {\n val correction = if ((j % 3) >= t) 0L else -1L\n dp[j] = max(dp[j], segTrees[t][(j - (9 * (k - 1)) + 9) / 10, j / 10] + (fs[e] * ((j / 3).toLong() + correction)))\n for (j2 in j - (9 * k) until j - (9 * (k - 1))) {\n if (j2 >= 0 && j2 % 10 == 0) {\n if ((j - j2) % 3 == 0) {\n dp[j] = max(dp[j], segTrees[t][j2 / 10] + (fs[e] * ((j / 3).toLong() + correction)))\n } else {\n val cancel = ((j - (9 * (k - 1)) - j2) / 3).toLong()\n dp[j] = max(dp[j], segTrees[t][j2 / 10] + (fs[e] * ((j / 3).toLong() + correction - cancel)))\n }\n }\n }\n }\n if (dp[j] < 0L) {\n dp[j] = IMPOSSIBLE\n }\n }\n dpPrev = dp\n }\n println(dpPrev[n])\n}\n\nclass SegmentTree(val treeFrom: Int, val treeTo: Int) {\n val value: LongArray\n val length: Int\n\n init {\n var e = 0\n while (1 shl e < treeTo - treeFrom + 1) {\n e++\n }\n value = LongArray(1 shl (e + 1))\n length = 1 shl e\n }\n\n operator fun set(index: Int, delta: Long) {\n var node = index - treeFrom + length\n value[node] = delta\n node = node shr 1\n while (node > 0) {\n value[node] = max(value[node shl 1], value[(node shl 1) + 1])\n node = node shr 1\n }\n }\n\n operator fun get(index: Int) = value[index - treeFrom + length]\n\n operator fun get(fromIndex: Int, toIndex: Int): Long {\n if (toIndex < fromIndex) {\n return IMPOSSIBLE\n }\n\n var from = max(treeFrom, fromIndex) + length - treeFrom\n var to = min(treeTo, toIndex) + length - treeFrom + 1\n var res = IMPOSSIBLE\n while (from + (from and -from) <= to) {\n res = max(res, value[from / (from and -from)])\n from += from and -from\n }\n while (to - (to and -to) >= from) {\n res = max(res, value[(to - (to and -to)) / (to and -to)])\n to -= to and -to\n }\n return res\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8dc0e445abdbd74338e9f08a7a22b183", "src_uid": "92bcbac3f167a44c235e99afc4de20d2", "difficulty": 2900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(){\n val s=Scanner(System.`in`)\n var r=s.next()\n var n=r.length\n var x:Int = -1\n var answer:String=\"\"\n for( i in 0..n-1){\n if(r[i]=='p'){\n answer += r[i]\n x=i\n break\n }\n else\n answer += r[i]\n }\n x++\n answer += \"://\"\n for (i in x..n-1){\n if(r[i]=='r' && r[i+1]=='u' && i!=x){\n answer+='.'\n answer+=\"ru\"\n x=i+1\n break\n }\n else\n answer+=r[i]\n }\n\n if(x!=n-1){\n x++\n answer+='/'\n for(i in x..n-1){\n answer+=r[i]\n }\n }\n print(answer)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2ea815a6c3e0d6698c5ebd9b4876d741", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(){\n val s=Scanner(System.`in`)\n var r=s.next()\n var n=r.length\n var x:Int = -1\n var answer:String=\"\"\n for( i in 0..n-1){\n if(r[i]=='p'){\n answer += r[i]\n x=i\n break\n }\n else\n answer += r[i]\n }\n x++\n answer += \"://\"\n for (i in x..n-1){\n if(r[i]=='r' && r[i+1]=='u'){\n answer+='.'\n answer+=\"ru\"\n x=i+1\n break\n }\n else\n answer+=r[i]\n }\n\n if(x!=n-1){\n x++\n answer+='/'\n for(i in x..n-1){\n answer+=r[i]\n }\n }\n print(answer)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d84f42296358d027dd50a189a6224e54", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import javax.print.attribute.IntegerSyntax\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun isDiverse(s: String): Boolean {\n val sortedSet = s.toSortedSet()\n return sortedSet.size == s.length &&\n sortedSet.last().toInt() - sortedSet.first().toInt() + 1 == sortedSet.size\n}\n\nfun main(args: Array) {\n val s = readLn()\n\n val all = mutableSetOf()\n\n for (i in 0 until s.length + 1) {\n for(ch in 'a'..'z') {\n val other = s.substring(0, i) + ch + s.substring(i)\n all.add(other)\n }\n }\n\n println(all.size)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "45e9da4c87247e31097d0cbec8466607", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val l = readLine()!!.length\n print(26 * (l + 1) - l)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "490873b5a0cf7841aeee1169c18dfd24", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n var n = readLine()!!\n\n println((n.length+1)*25+1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bfc956ca7c78f84873ea3017b90bb206", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\n\nfun main() {\n val pows = LongArray(40)\n pows[0] = 1L\n for (e in 1..39) {\n pows[e] = 7L * pows[e - 1]\n }\n val jin = FastScanner()\n val n = jin.nextInt().toLong()\n val m = jin.nextInt().toLong()\n var e = 1\n var pow = 7L\n while (pow < n) {\n e++\n pow *= 7L\n }\n var f = 1\n pow = 7L\n while (pow < m) {\n f++\n pow *= 7L\n }\n val used = mutableSetOf()\n var answer = 0\n var hour = 0L\n var minute = 0L\n fun recur(d: Int) {\n if (d == e + f) {\n if (hour < n && minute < m) {\n answer++\n }\n } else {\n for (digit in 0..6) {\n if (digit !in used) {\n used.add(digit)\n if (d < e) {\n hour += digit.toLong() * pows[d]\n } else {\n minute += digit.toLong() * pows[d - e]\n }\n recur(d + 1)\n if (d < e) {\n hour -= digit.toLong() * pows[d]\n } else {\n minute -= digit.toLong() * pows[d - e]\n }\n used.remove(digit)\n }\n }\n }\n }\n recur(0)\n println(answer)\n}\n\nclass FastScanner {\n private val BS = 1 shl 16\n private val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n private var `in`: BufferedInputStream? = null\n\n constructor() {\n `in` = BufferedInputStream(System.`in`, BS)\n }\n\n private val char: Char\n private get() {\n while (bId == size) {\n size = try {\n `in`!!.read(buf)\n } catch (e: Exception) {\n return NC\n }\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c >= '0' && c <= '9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "104298b00253487fed4efef875287a9a", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Kotlin 1.5", "source_code": "import java.io.BufferedReader\r\nimport java.io.BufferedWriter\r\n\r\nclass PerfectPower(val number: Long, val power: Long)\r\nclass ProblemE {\r\n private fun BufferedReader.readInt(): Int = this.readLine().toInt()\r\n private fun BufferedReader.readIntArray(delimiter: String = \" \") =\r\n this.readLine().split(delimiter).map { it.toInt() }.toIntArray()\r\n\r\n private fun BufferedWriter.writeLine(s: String) {\r\n this.write(s)\r\n this.newLine()\r\n }\r\n\r\n private fun IntArray.swap(i: Int, j: Int) {\r\n val tmp = this[i]\r\n this[i] = this[j]\r\n this[j] = tmp\r\n }\r\n\r\n private fun solveTest(input: BufferedReader, output: BufferedWriter) {\r\n val perfectPowers = mutableMapOf>()\r\n for (i in 2..(1e6).toLong()) {\r\n var k = i\r\n for (p in 2..22L) {\r\n k *= i\r\n if (k > 1e6) break\r\n val s = perfectPowers.getOrDefault(k, mutableListOf())\r\n s.add(PerfectPower(i, p))\r\n perfectPowers[k] = s\r\n }\r\n }\r\n\r\n val (n, m) = input.readLine().split(\" \").map { it.toLong() }\r\n var numDistinct = 1L\r\n for(i in 2..n) {\r\n if(perfectPowers.contains(i)) {\r\n var maxCommon = 0L\r\n for(r in perfectPowers[i]!!) {\r\n maxCommon = maxOf(m / r.power, maxCommon)\r\n }\r\n numDistinct += m - maxCommon\r\n } else {\r\n numDistinct += m\r\n }\r\n }\r\n output.writeLine(numDistinct.toString())\r\n }\r\n\r\n fun solve(input: BufferedReader, output: BufferedWriter) {\r\n solveTest(input, output)\r\n input.close()\r\n output.close()\r\n }\r\n\r\n}\r\n\r\nfun main() {\r\n val solution = ProblemE()\r\n solution.solve(System.`in`.bufferedReader(), System.out.bufferedWriter())\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c599f406a34b160f8386c51f759ea630", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.07.31 at 20:35:58 HKT\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\nimport java.util.TreeMap\r\nimport java.util.TreeSet\r\nimport kotlin.random.Random\r\nimport kotlin.random.nextInt\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. conveniecen conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\n//9.ordered pair\r\nfun order(a:Int, b:Int):Pair{\r\n return Pair(minOf(a,b), maxOf(a,b))\r\n}\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){ Reader.OUT.println(aa)}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\n\r\nfun debug(){}\r\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n val n = getint\r\n val m = getint\r\n var base = (n-1) * m.toLong() + 1\r\n\r\n val arr = BooleanArray((m+1) * 20)\r\n var taken = 0\r\n val ret = IntArray(21)\r\n for(level in 1..20){\r\n for(i in level..level * m step level){\r\n if(arr[i] == false){\r\n arr[i] = true\r\n taken ++\r\n }\r\n }\r\n ret[level] = taken\r\n }\r\n for(p in 2..n){\r\n\r\n var now =1\r\n var maxp = 0\r\n while(now * p.toLong() <= n){\r\n now *= p\r\n maxp ++\r\n }\r\n val distinct = maxp.toLong() * m\r\n val actual = ret[maxp]\r\n base -= distinct\r\n base += actual\r\n }\r\n put(base)\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n/*\r\n1 1\r\n2 4\r\n3 9\r\n4 16\r\n\r\n1000000 1000000\r\n */\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cfbe9b03d7605de603298868dc68d26a", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.07.31 at 20:35:58 HKT\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\nimport java.util.TreeMap\r\nimport java.util.TreeSet\r\nimport kotlin.random.Random\r\nimport kotlin.random.nextInt\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. conveniecen conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\n//9.ordered pair\r\nfun order(a:Int, b:Int):Pair{\r\n return Pair(minOf(a,b), maxOf(a,b))\r\n}\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){ Reader.OUT.println(aa)}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\n\r\nfun debug(){}\r\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n val n = getint\r\n val m = getint\r\n var base = (n-1) * m.toLong() + 1\r\n\r\n val arr = BooleanArray((m+1) * 20)\r\n var taken = 0\r\n val ret = IntArray(21)\r\n for(level in 1..20){\r\n for(i in level..level * m step level){\r\n if(arr[i] == false){\r\n arr[i] = true\r\n taken ++\r\n }\r\n }\r\n ret[level] = taken\r\n }\r\n val checked = BooleanArray(n+1)\r\n for(p in 2..n){\r\n\r\n if(checked[p]){\r\n continue\r\n }\r\n var now =1\r\n var maxp = 0\r\n while(now * p.toLong() <= n){\r\n now *= p\r\n checked[p] = true\r\n maxp ++\r\n }\r\n val distinct = maxp.toLong() * m\r\n val actual = ret[maxp]\r\n base -= distinct\r\n base += actual\r\n }\r\n put(base)\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n/*\r\n1 1\r\n2 4\r\n3 9\r\n4 16\r\n\r\n1000000 1000000\r\n */\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "469e537fc7da100ec0bc6fe38ddac355", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.07.31 at 20:35:58 HKT\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\nimport java.util.TreeMap\r\nimport java.util.TreeSet\r\nimport kotlin.random.Random\r\nimport kotlin.random.nextInt\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. conveniecen conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\n//9.ordered pair\r\nfun order(a:Int, b:Int):Pair{\r\n return Pair(minOf(a,b), maxOf(a,b))\r\n}\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){ Reader.OUT.println(aa)}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\n\r\nfun debug(){}\r\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n val n = getint\r\n val m = getint\r\n var base = (n-1) * m.toLong() + 1\r\n\r\n val arr = BooleanArray((m+1) * 20)\r\n var taken = 0\r\n val ret = IntArray(21)\r\n for(level in 1..20){\r\n for(i in level..level * m step level){\r\n if(arr[i] == false){\r\n arr[i] = true\r\n taken ++\r\n }\r\n }\r\n ret[level] = taken\r\n }\r\n val checked = BooleanArray(n+1)\r\n for(p in 2..n){\r\n\r\n if(checked[p]){\r\n continue\r\n }\r\n var now =1\r\n var maxp = 0\r\n while(now * p.toLong() <= n){\r\n now *= p\r\n checked[now] = true\r\n maxp ++\r\n }\r\n val distinct = maxp.toLong() * m\r\n val actual = ret[maxp]\r\n base -= distinct\r\n base += actual\r\n }\r\n put(base)\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n/*\r\n1 1\r\n2 4\r\n3 9\r\n4 16\r\n\r\n1000000 1000000\r\n */\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "819b5b43d66e6f507c21ca9a2aca1d3a", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin 1.5", "source_code": "import java.io.BufferedReader\r\nimport java.io.BufferedWriter\r\n\r\nclass ProblemE {\r\n private fun BufferedReader.readInt(): Int = this.readLine().toInt()\r\n private fun BufferedReader.readIntArray(delimiter: String = \" \") =\r\n this.readLine().split(delimiter).map { it.toInt() }.toIntArray()\r\n\r\n private fun BufferedWriter.writeLine(s: String) {\r\n this.write(s)\r\n this.newLine()\r\n }\r\n\r\n private fun solveTest(input: BufferedReader, output: BufferedWriter) {\r\n val (n, m) = input.readIntArray()\r\n\r\n /***\r\n * x^(i*j) where 1 <=i <= log_x(k), 1 <= j <= m\r\n * 1 <= i <= 20, 1 <= j <= 1e6\r\n *\r\n */\r\n val numDistinctPowers = IntArray(22)\r\n var numUnique = 0\r\n val visited = BooleanArray(22*(m +1))\r\n for(i in 1 until numDistinctPowers.size) {\r\n for(j in 1..m) {\r\n if(!visited[i*j]) {\r\n visited[i*j] = true\r\n numUnique+=1\r\n }\r\n }\r\n numDistinctPowers[i] = numUnique\r\n }\r\n val isAPower = BooleanArray(n +1)\r\n var numDistinct = 1L\r\n for(x in 2..n) {\r\n if(!isAPower[x]) {\r\n var powerCount = 0\r\n var j = x.toLong()\r\n while(j <= n) {\r\n isAPower[j.toInt()] = true\r\n powerCount += 1\r\n j *= x\r\n }\r\n numDistinct+= numDistinctPowers[powerCount]\r\n }\r\n }\r\n output.writeLine(numDistinct.toString())\r\n }\r\n\r\n fun solve(input: BufferedReader, output: BufferedWriter) {\r\n solveTest(input, output)\r\n input.close()\r\n output.close()\r\n }\r\n\r\n}\r\n\r\nfun main() {\r\n val solution = ProblemE()\r\n solution.solve(System.`in`.bufferedReader(), System.out.bufferedWriter())\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2e6f8df0030b063461cadcd64989b746", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.07.31 at 20:35:58 HKT\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\nimport java.util.TreeMap\r\nimport java.util.TreeSet\r\nimport kotlin.random.Random\r\nimport kotlin.random.nextInt\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. conveniecen conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\n//9.ordered pair\r\nfun order(a:Int, b:Int):Pair{\r\n return Pair(minOf(a,b), maxOf(a,b))\r\n}\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){ Reader.OUT.println(aa)}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\n\r\nfun debug(){}\r\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n val n = getint\r\n val m = getint\r\n var base = (n-1) * m.toLong() + 1\r\n\r\n val arr = BooleanArray((m+1) * 20)\r\n var taken = 0\r\n val ret = IntArray(21)\r\n for(level in 1..20){\r\n for(i in level..level * m step level){\r\n if(arr[i] == false){\r\n arr[i] = true\r\n taken ++\r\n }\r\n }\r\n ret[level] = taken\r\n }\r\n for(p in 2..n){\r\n\r\n var now =1\r\n var maxp = 0\r\n while(now * p <= n){\r\n now *= p\r\n maxp ++\r\n }\r\n val distinct = maxp.toLong() * m\r\n val actual = ret[maxp]\r\n base -= distinct\r\n base += actual\r\n }\r\n put(base)\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n/*\r\n1 1\r\n2 4\r\n3 9\r\n4 16\r\n */\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "378402e2f5899c19b2db3ef38dfec9f9", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import jdk.nashorn.internal.runtime.JSType.toLong\nimport sun.security.jgss.GSSToken.readInt\nimport java.util.*\nimport kotlin.math.sqrt\n\nfun main(args : Array){\n val o=Scanner(System.`in`)\n var n=0\n var a= o.nextInt()\n var k=true\n if(a%2==1){\n\n if( fun1(a)==true){\n print(\"1\")\n }else{\n\n if(fun1(a-2)==true){\n print(\"2\")\n }else{\n print(\"3\")\n }\n }\n }else{\n if(n==2){\n print(\"1\")\n }else{\n print(\"2\")\n }\n }\n\n}\n\nfun fun1(a:Int): Boolean {\n var k= sqrt(a.toDouble())\n for(i in 2..k.toInt()){\n if(a%i==0){\n // print(\"$i\")\n return false;\n }\n }\n return true;\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f1d85d6e174050c8ba9a647a74a204bd", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport java.util.Collections.min\nimport kotlin.math.min\n\nfun main() {\n val r = FastReader()\n val n = r.nextInt()\n print(solve(n))\n\n}\n\nfun isp(m:Int): Int {\n var i : Int= 2\n while(i * i <= m){\n if(m % i == 0){\n return (m / i)\n }\n i ++\n }\n return 1\n}\n\nfun solve(n:Int):Int{\n var k = isp(n)\n if(k < 3) return k\n var m = n-1\n while(isp(m) != 1){\n m --\n }\n //println(m)\n return 1 +solve( n - m)\n\n}\n@Suppress(\"MemberVisibilityCanBePrivate\")\ninternal class FastReader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreElements())\n t = StringTokenizer(br.readLine())\n tokenizer = t\n return t.nextToken()\n }\n\n fun nextInt():Int= next().toInt()\n\n fun nextLong(): Long = next().toLong()\n\n fun nextDouble(): Double = next().toDouble()\n\n fun nextLine(): String = br.readLine()\n\n fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }\n\n fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }\n\n fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }\n\n fun nextIntArr2(n: Int, m: Int): Array = Array(n) { IntArray(m) { nextInt() } }\n\n fun nextLongArr2(n: Int, m: Int): Array = Array(n) { LongArray(m) { nextLong() } }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e4d7a3893c4fab6f085028e34f4a66cc", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import jdk.nashorn.internal.runtime.JSType.toLong\nimport sun.security.jgss.GSSToken.readInt\nimport java.util.*\nimport kotlin.math.sqrt\n\nfun main(args : Array){\n val o=Scanner(System.`in`)\n var n=0\n var a= o.nextInt()\n var k=true\n if(a%2==1){\n\n if( fun1(a)==true){\n print(\"1\")\n }else{\n\n if(fun1(a-2)==true){\n print(\"2\")\n }else{\n print(\"3\")\n }\n }\n }else{\n if(a==2){\n print(\"1\")\n }else{\n print(\"2\")\n }\n }\n\n}\n\nfun fun1(a:Int): Boolean {\n var k= sqrt(a.toDouble())\n for(i in 2..k.toInt()){\n if(a%i==0){\n // print(\"$i\")\n return false;\n }\n }\n return true;\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4d559921b9ea393f9ef3b7c9c5850ae7", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport java.util.Collections.min\nimport kotlin.math.min\n\nfun main() {\n val r = FastReader()\n val n = r.nextInt()\n print(solve(n))\n\n}\n\nfun isp(m:Int): Int {\n var i : Int= 2\n while(i * i <= m){\n if(m % i == 0){\n return 0\n }\n i ++\n }\n return 1\n}\n\nfun solve(n:Int):Int{\n var k = isp(n)\n if(k == 1) return k\n if(n%2 == 0) return 2\n if(isp(n-2) == 1) return 2\n return 3\n}\n@Suppress(\"MemberVisibilityCanBePrivate\")\ninternal class FastReader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n var t = tokenizer\n while (t == null || !t.hasMoreElements())\n t = StringTokenizer(br.readLine())\n tokenizer = t\n return t.nextToken()\n }\n\n fun nextInt():Int= next().toInt()\n\n fun nextLong(): Long = next().toLong()\n\n fun nextDouble(): Double = next().toDouble()\n\n fun nextLine(): String = br.readLine()\n\n fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }\n\n fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }\n\n fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }\n\n fun nextIntArr2(n: Int, m: Int): Array = Array(n) { IntArray(m) { nextInt() } }\n\n fun nextLongArr2(n: Int, m: Int): Array = Array(n) { LongArray(m) { nextLong() } }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "73e84b7599a8af211f8419067c0b4165", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.InputStream\nimport java.util.*\n\nprivate class FScanner internal constructor(inputStream: InputStream = System.`in`) {\n internal val br = BufferedReader(InputStreamReader(inputStream))\n internal var st = StringTokenizer(\"\")\n\n internal fun hasNext(): Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n }\n\n internal operator fun next() =\n if (hasNext()) st.nextToken()!!\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextInt() = next().toInt()\n\n internal fun nextLong() = next().toLong()\n\n internal fun nextLine() =\n if (hasNext()) st.nextToken(\"\\n\")\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })\n\n internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })\n}\n\n\nfun main(args: Array) {\n val sc = FScanner()\n val n = sc.nextInt()\n val s = sc.nextLine()\n val b = sc.nextIntArray(n)\n\n val rev = PriorityQueue>(compareBy { it.second })\n var sum = b.sum()\n\n val remChar = IntArray(26)\n (0 until n / 2).forEach {\n val inv = n - it - 1\n if (s[it] == s[inv]) {\n// println(\"${s[it]} - ${b[it]} - ${b[n - it - 1]}\")\n if (b[it] < b[inv]) {\n remChar[s[it].toByte() - 'a'.toByte()]++\n// rev += Triple(s[inv], b[inv], s[it])\n sum -= b[it]\n } else {\n remChar[s[inv].toByte() - 'a'.toByte()]++\n// rev += Triple(s[it], b[it], s[inv])\n sum -= b[inv]\n }\n } else {\n rev += Triple(s[it], b[it], s[inv])\n rev += Triple(s[inv], b[inv], s[it])\n }\n }\n\n val remStat = PriorityQueue>(compareBy> { -it.second })\n remChar\n .forEachIndexed { index, i ->\n if (i > 0) {\n remStat += Pair((index + 'a'.toByte()).toChar(), i)\n }\n }\n\n// println(remStat.joinToString(\" \"))\n// println(sum)\n\n if (remStat.isNotEmpty()) {\n var x = remStat.poll()\n var oldx = x.first\n var xleft = x.second\n while (remStat.isNotEmpty()) {\n val y = remStat.poll()\n if (y.second <= xleft) {\n xleft -= y.second\n } else {\n xleft = y.second - xleft\n x = y\n }\n }\n// println(\"Need remove ${x.first} $xleft\")\n// println(rev.joinToString(\" \"))\n\n //find different x\n while (xleft > 0 && x.first == oldx) {\n val re = rev.poll()\n if (re.first != x.first && re.third != x.first) {\n// println(\"Remove $re\")\n xleft--\n sum -= re.second\n }\n }\n }\n \n println(sum)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0cf3069d5facb5d5cf0845ae48ce8103", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.InputStream\nimport java.util.*\n\nprivate class FScanner internal constructor(inputStream: InputStream = System.`in`) {\n internal val br = BufferedReader(InputStreamReader(inputStream))\n internal var st = StringTokenizer(\"\")\n\n internal fun hasNext(): Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n }\n\n internal operator fun next() =\n if (hasNext()) st.nextToken()!!\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextInt() = next().toInt()\n\n internal fun nextLong() = next().toLong()\n\n internal fun nextLine() =\n if (hasNext()) st.nextToken(\"\\n\")\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })\n\n internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })\n}\n\n\nfun main(args: Array) {\n val sc = FScanner()\n val n = sc.nextInt()\n val s = sc.nextLine()\n val b = sc.nextIntArray(n)\n\n val rev = PriorityQueue>(compareBy { it.second })\n var sum = b.sum()\n\n val remChar = IntArray(26)\n (0 until n / 2).forEach {\n val inv = n - it - 1\n if (s[it] == s[inv]) {\n// println(\"${s[it]} - ${b[it]} - ${b[n - it - 1]}\")\n if (b[it] < b[inv]) {\n remChar[s[it].toByte() - 'a'.toByte()]++\n rev += Triple(s[inv], b[inv], s[it])\n sum -= b[it]\n } else {\n remChar[s[inv].toByte() - 'a'.toByte()]++\n rev += Triple(s[it], b[it], s[inv])\n sum -= b[inv]\n }\n } else {\n rev += Triple(s[it], b[it], s[inv])\n rev += Triple(s[inv], b[inv], s[it])\n }\n }\n\n val remStat = PriorityQueue>(compareBy> { -it.second })\n remChar\n .forEachIndexed { index, i ->\n if (i > 0) {\n remStat += Pair((index + 'a'.toByte()).toChar(), i)\n }\n }\n\n// println(remStat.joinToString(\" \"))\n// println(sum)\n\n if (remStat.isNotEmpty()) {\n var x = remStat.poll()\n var oldx = x.first\n var xleft = x.second\n while (remStat.isNotEmpty()) {\n val y = remStat.poll()\n if (y.second <= xleft) {\n xleft -= y.second\n } else {\n xleft = y.second - xleft\n x = y\n }\n }\n// println(\"Need remove ${x.first} $xleft\")\n// println(rev.joinToString(\" \"))\n\n //find different x\n while (xleft > 0 && x.first == oldx) {\n val re = rev.poll()\n if (re.first != x.first && re.third != x.first) {\n// println(\"Remove $re\")\n xleft--\n sum -= re.second\n }\n }\n }\n\n println(sum)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c870efda284c754acfa86d041d9f82b0", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.InputStream\nimport java.util.*\n\nprivate class FScanner internal constructor(inputStream: InputStream = System.`in`) {\n internal val br = BufferedReader(InputStreamReader(inputStream))\n internal var st = StringTokenizer(\"\")\n\n internal fun hasNext(): Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n }\n\n internal operator fun next() =\n if (hasNext()) st.nextToken()!!\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextInt() = next().toInt()\n\n internal fun nextLong() = next().toLong()\n\n internal fun nextLine() =\n if (hasNext()) st.nextToken(\"\\n\")\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })\n\n internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })\n}\n\n\nfun main(args: Array) {\n val sc = FScanner()\n val n = sc.nextInt()\n val s = sc.nextLine()\n val b = sc.nextIntArray(n)\n\n val rev = PriorityQueue>(compareBy { it.second })\n var sum = b.sum()\n\n val remChar = IntArray(26)\n (0 until n / 2).forEach {\n val inv = n - it - 1\n if (s[it] == s[inv]) {\n// println(\"${s[it]} - ${b[it]} - ${b[n - it - 1]}\")\n if (b[it] < b[inv]) {\n remChar[s[it].toByte() - 'a'.toByte()]++\n rev += Triple(s[inv], b[inv], s[it])\n sum -= b[it]\n } else {\n remChar[s[inv].toByte() - 'a'.toByte()]++\n rev += Triple(s[it], b[it], s[inv])\n sum -= b[inv]\n }\n } else {\n rev += Triple(s[it], b[it], s[inv])\n rev += Triple(s[inv], b[inv], s[it])\n }\n }\n\n val remStat = PriorityQueue>(compareBy> { -it.second })\n remChar\n .forEachIndexed { index, i ->\n if (i > 0) {\n remStat += Pair((index + 'a'.toByte()).toChar(), i)\n }\n }\n\n// println(remStat.joinToString(\" \"))\n// println(sum)\n\n if (remStat.isNotEmpty()) {\n var x = remStat.poll()\n var xleft = x.second\n while (remStat.isNotEmpty()) {\n val y = remStat.poll()\n if (y.second <= xleft) {\n xleft -= y.second\n } else {\n xleft = y.second - xleft\n x = y\n }\n }\n// println(\"Need remove ${x.first} $xleft\")\n// println(rev.joinToString(\" \"))\n //find different x\n while (xleft > 0) {\n val re = rev.poll()\n if (re.first != x.first && re.third != x.first) {\n// println(\"Remove $re\")\n xleft--\n sum -= re.second\n }\n }\n }\n\n\n\n println(sum)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ded3ca0112a604069776295a9023696a", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.InputStream\nimport java.util.*\n\nprivate class FScanner internal constructor(inputStream: InputStream = System.`in`) {\n internal val br = BufferedReader(InputStreamReader(inputStream))\n internal var st = StringTokenizer(\"\")\n\n internal fun hasNext(): Boolean {\n while (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine() ?: return false)\n return true\n }\n\n internal operator fun next() =\n if (hasNext()) st.nextToken()!!\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextInt() = next().toInt()\n\n internal fun nextLong() = next().toLong()\n\n internal fun nextLine() =\n if (hasNext()) st.nextToken(\"\\n\")\n else throw RuntimeException(\"No tokens\")\n\n internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })\n\n internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })\n}\n\n\nfun main(args: Array) {\n val sc = FScanner()\n val n = sc.nextInt()\n val s = sc.nextLine()\n val b = sc.nextIntArray(n)\n\n val remove = mutableSetOf()\n val rev = PriorityQueue>(compareBy { it.second })\n var sum = b.sum()\n\n val remChar = IntArray(26)\n (0 until n / 2).forEach {\n val inv = n - it - 1\n if (s[it] == s[inv]) {\n// println(\"${s[it]} - ${b[it]} - ${b[n - it - 1]}\")\n if (b[it] < b[inv]) {\n remove.add(it)\n remChar[s[it].toByte() - 'a'.toByte()]++\n rev += Pair(s[inv], b[inv])\n sum -= b[it]\n } else {\n remove.add(inv)\n remChar[s[inv].toByte() - 'a'.toByte()]++\n rev += Pair(s[it], b[it])\n sum -= b[inv]\n }\n } else {\n rev += Pair(s[it], b[it])\n rev += Pair(s[inv], b[inv])\n }\n }\n\n val remStat = PriorityQueue>(compareBy> { -it.second })\n remChar\n .forEachIndexed { index, i ->\n if (i > 0) {\n remStat += Pair((index + 'a'.toByte()).toChar(), i)\n }\n }\n\n// println(remStat.joinToString(\" \"))\n\n if (remStat.isNotEmpty()) {\n var x = remStat.poll()\n var xleft = x.second\n while (remStat.isNotEmpty()) {\n val y = remStat.poll()\n if (y.second <= xleft) {\n xleft -= y.second\n } else {\n xleft = y.second - xleft\n x = y\n }\n }\n //find different x\n while (xleft > 0) {\n val re = rev.poll()\n if (re.first != x.first) {\n xleft--\n sum -= re.second\n }\n }\n }\n\n\n\n println(sum)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "395f6bccf500060ca4250189d448cec6", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nclass House(var human: Int) {\n val neighbours = mutableListOf()\n var sizeOfSubtree = 0\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n val vertices = List(n) { House(it + 1) }\n repeat(n - 1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n vertices[u].neighbours.add(vertices[v])\n vertices[v].neighbours.add(vertices[u])\n }\n\n fun DFS(vertex: House, old: House): Int {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n vertex.sizeOfSubtree = 1\n 1\n } else {\n var vym = 1\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS(it, vertex)\n }\n }\n vertex.sizeOfSubtree = vym\n vym\n }\n }\n\n DFS(vertices[0], vertices[0])\n\n fun DFS2(vertex: House, old: House): House? {\n if (vertex.sizeOfSubtree > (n / 2)) {\n vertex.neighbours.forEach {\n if (it != old) {\n val v = DFS2(it, vertex)\n if (v != null) {\n return v\n }\n }\n }\n return vertex\n }\n return null\n }\n\n fun DFS3(house: House, split: House): List {\n val houses = mutableListOf()\n\n fun DFS3IN(vertex: House, old: House) {\n houses.add(vertex)\n vertex.neighbours.forEach {\n if (it != old) {\n DFS3IN(it, vertex)\n }\n }\n }\n DFS3IN(house, split)\n return houses\n }\n\n val split = DFS2(vertices[0], vertices[0])!!\n DFS(split, split)\n val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }\n val queue = ArrayDeque() as Queue\n queue.addAll(sort[0].map { it.human })\n queue.add(split.human)\n split.human = queue.poll()\n for (i in 1 until sort.size) {\n queue.addAll(sort[i].map { it.human })\n sort[i].forEach {\n it.human = queue.poll()\n }\n }\n sort[0].forEach {\n it.human = queue.poll()\n }\n\n fun DFS4(vertex: House, old: House): Int {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n 1\n } else {\n var vym = 0\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS4(it, vertex)\n }\n }\n vym + vertex.sizeOfSubtree\n }\n }\n println((DFS4(split, split) - split.sizeOfSubtree) * 2)\n println(vertices.map { it.human }.joinToString(\" \"))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5e17cb46077f46c80354d3fea17ea711", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nclass House(var human: Int) {\n val neighbours = mutableListOf()\n var sizeOfSubtree = 0\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n val vertices = List(n) { House(it + 1) }\n repeat(n - 1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n vertices[u].neighbours.add(vertices[v])\n vertices[v].neighbours.add(vertices[u])\n }\n\n fun DFS(vertex: House, old: House): Int {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n vertex.sizeOfSubtree = 1\n 1\n } else {\n var vym = 1\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS(it, vertex)\n }\n }\n vertex.sizeOfSubtree = vym\n vym\n }\n }\n\n DFS(vertices[0], vertices[0])\n\n fun DFS2(vertex: House, old: House): House? {\n if (vertex.sizeOfSubtree > (n / 2)) {\n vertex.neighbours.forEach {\n if (it != old) {\n val v = DFS2(it, vertex)\n if (v != null) {\n return v\n }\n }\n }\n return vertex\n }\n return null\n }\n\n fun DFS3(house: House, split: House): List {\n val houses = mutableListOf()\n\n fun DFS3IN(vertex: House, old: House) {\n houses.add(vertex)\n vertex.neighbours.forEach {\n if (it != old) {\n DFS3IN(it, vertex)\n }\n }\n }\n DFS3IN(house, split)\n return houses\n }\n\n val split = DFS2(vertices[0], vertices[0])!!\n val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }\n val queue = ArrayDeque() as Queue\n queue.add(split.human)\n queue.addAll(sort[0].map { it.human })\n for (i in 1 until sort.size) {\n queue.addAll(sort[i].map { it.human })\n sort[i].forEach {\n it.human = queue.poll()\n }\n }\n split.human = queue.poll()\n sort[0].forEach {\n it.human = queue.poll()\n }\n\n fun DFS4(vertex: House, old: House): Int {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n 1\n } else {\n var vym = 0\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS4(it, vertex)\n }\n }\n vym + vertex.sizeOfSubtree\n }\n }\n\n DFS(split, split)\n println((DFS4(split, split) - split.sizeOfSubtree) * 2)\n println(vertices.map { it.human }.joinToString(\" \"))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2fbc26cef9a9560466c093dc67e32467", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nclass House(var human: Int) {\n val neighbours = mutableListOf()\n var sizeOfSubtree = 0\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n val vertices = List(n) { House(it + 1) }\n repeat(n - 1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n vertices[u].neighbours.add(vertices[v])\n vertices[v].neighbours.add(vertices[u])\n }\n\n fun DFS(vertex: House, old: House): Int {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n vertex.sizeOfSubtree = 1\n 1\n } else {\n var vym = 1\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS(it, vertex)\n }\n }\n vertex.sizeOfSubtree = vym\n vym\n }\n }\n\n DFS(vertices[0], vertices[0])\n\n fun DFS2(vertex: House, old: House): House? {\n if (vertex.sizeOfSubtree > (n / 2)) {\n vertex.neighbours.forEach {\n if (it != old) {\n val v = DFS2(it, vertex)\n if (v != null) {\n return v\n }\n }\n }\n return vertex\n }\n return null\n }\n\n fun DFS3(house: House, split: House): List {\n val houses = mutableListOf()\n\n fun DFS3IN(vertex: House, old: House) {\n houses.add(vertex)\n vertex.neighbours.forEach {\n if (it != old) {\n DFS3IN(it, vertex)\n }\n }\n }\n DFS3IN(house, split)\n return houses\n }\n\n val split = DFS2(vertices[0], vertices[0])!!\n DFS(split, split)\n val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }\n val queue = ArrayDeque() as Queue\n queue.addAll(sort[0].map { it.human })\n queue.add(split.human)\n split.human = queue.poll()\n for (i in 1 until sort.size) {\n queue.addAll(sort[i].map { it.human })\n sort[i].forEach {\n it.human = queue.poll()\n }\n }\n sort[0].forEach {\n it.human = queue.poll()\n }\n\n fun DFS4(vertex: House, old: House): Long {\n return if (vertex.neighbours.size == 1 && vertex != old) {\n 1L\n } else {\n var vym = 0L\n vertex.neighbours.forEach {\n if (it != old) {\n vym += DFS4(it, vertex)\n }\n }\n vym + vertex.sizeOfSubtree.toLong()\n }\n }\n println((DFS4(split, split) - split.sizeOfSubtree.toLong()) * 2L)\n println(vertices.map { it.human }.joinToString(\" \"))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6ce08f41ca3870231ae02f8c1c9c770d", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "fun main() {\n var str = readLine()!!\n if (str[1] == '1' || str[1] == '8') {\n if (str[0] == 'a' || str[0] == 'h') {\n println(3)\n return\n } else {\n println(5)\n return\n }\n } else {\n if (str[0] == 'a' || str[0] == 'h'){\n println(5)\n }else{\n println(8)\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5e391e9835f828d8b9dac107924eabef", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val input = readLine()!!.toCharArray()\n if ((input[0] == 'b' || input[0] == 'c' || input[0] == 'd' || input[0] == 'e' || input[0] == 'f' || input[0] == 'g') && (input[1] == '2' || input[1] == '3' || input[1] == '4' || input[1] == '5' || input[1] == '6' || input[1] == '7')) print(\"8\") else if (((input[0] == 'b' || input[0] == 'c' || input[0] == 'd' || input[0] == 'e' || input[0] == 'f' || input[0] == 'g') && (input[1] == '1' || input[1] == '8')) || ((input[0] == 'a' || input[0] == 'h') && (input[1] == '2' || input[1] == '3' || input[1] == '4' || input[1] == '5' || input[1] == '6' || input[1] == '7'))) print(\"5\") else print(\"3\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94261b8ed5c91841a9c9a56f0c61ad6c", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"a.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val s = next()\n fun mirror(a: Int) = if (a > 3) 7 - a else a\n val a = mirror(s[0] - 'a')\n val b = mirror(s[1] - '1')\n if (a > 0 && b > 0)\n fout.print(8)\n else if (a == 0 && b == 0)\n fout.print(3)\n else\n fout.print(5)\n\n\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4fb21ce0c50b3439dd99f2721d61e4d5", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val pos = readLine()!!\n if (pos in setOf(\"a1\", \"h1\", \"a8\", \"h8\")) return print(3)\n if (pos[0] == 'a' || pos[0] == 'h' || pos[1] == '1' || pos[1] == '8') return print(5)\n print(8)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d9553c5f0b7391131e74db74599b034b", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val pos = readLine()!!\n if (pos in setOf(\"a1\", \"h1\", \"a8\", \"h8\")) return print(4)\n if (pos[0] == 'a' || pos[0] == 'h' || pos[1] == '1' || pos[1] == '8') return print(5)\n print(8)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6f16e6f8385216967ef7a96c306e9672", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.File\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val onlineJudge = System.getProperty(\"ONLINE_JUDGE\") == \"true\"\n val input = if (onlineJudge) System.`in`.bufferedReader() else File(\"input.txt\").bufferedReader()\n val output = if (onlineJudge) PrintWriter(System.out.writer(), true) else PrintWriter(File(\"output.txt\"))\n\n solve(input, output)\n}\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n //todo implement the task solution\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "71e98fc03f9763949da2c806aa167042", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val s1 = r.readLine()!!.split(\" \").map { it.toInt() }.sum()\n val s2 = r.readLine()!!.split(\" \").map { it.toInt() }.sum()\n val v = r.readLine()!!.toInt()\n val ans = s1/5 + s2/10 +if (s1%5!=0) 1 else 0 +if (s2%10!=0) 1 else 0\n println(if (ans<=v) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f004a39905f3d861cf1e187283cdada5", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// https://codeforces.com/problemset/problem/448/A\n\n\nfun main(args: Array) {\n val medals = readInts()\n val cups = readInts()\n var totalShelves = readInt()\n\n val totalMedals = medals.sum()\n val totalCups = cups.sum()\n\n var totalCupsShelves = (totalCups / 10)\n if(totalCupsShelves % 10 != 0){\n totalCupsShelves += 1\n }\n var totalMedalsShelves = (totalMedals / 5) + (totalMedals % 5)\n if(totalMedalsShelves % 5 != 0){\n totalMedalsShelves += 1\n }\n\n if(totalCupsShelves + totalMedalsShelves > totalShelves){\n print(\"NO\")\n }else{\n print(\"YES\")\n }\n\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings(del: String = \" \") = readLn().split(del) // list of strings\nprivate fun readInts(del: String = \" \") = readStrings(del).map { it.toInt() } // list of ints", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "988dbdf62fa2b08afa23d5c14e3c965e", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// https://codeforces.com/problemset/problem/448/A\n\n\nfun main(args: Array) {\n val medals = readInts()\n val cups = readInts()\n var totalShelves = readInt()\n\n val totalMedals = medals.sum()\n val totalCups = cups.sum()\n\n var totalCupsShelves = (totalCups / 10)\n if(totalCupsShelves % 10 != 0){\n totalCupsShelves += 1\n }\n var totalMedalsShelves = (totalMedals / 5)\n if(totalMedalsShelves % 5 != 0){\n totalMedalsShelves += 1\n }\n\n if(totalCupsShelves + totalMedalsShelves > totalShelves){\n print(\"NO\")\n }else{\n print(\"YES\")\n }\n\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings(del: String = \" \") = readLn().split(del) // list of strings\nprivate fun readInts(del: String = \" \") = readStrings(del).map { it.toInt() } // list of ints", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7ebfb4dcf95043577d0866241fa845d8", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun min(a:Double,b:Double) = if (ab) a else b\nfun min(a:Long,b:Long) = if (ab) a else b\n\nfun readLn():String = readLine()!!.toString()\nfun readLong() = readLn().toLong()\nfun readLongs() = readLn().split(\" \").map{it.toLong()}\nvar nul=0.toLong();\nvar one=1.toLong();\nvar two=2.toLong();\nvar three=3.toLong();\nvar four=4.toLong();\nvar five=5.toLong();\nfun powmod(a:Long,b:Long,mod:Long):Long {\n\n if (b==1.toLong()) return a;\n var k=powmod(a,b/2,mod);\n if (b%2==0.toLong())\n { return (k*k)%mod }\n else { k=k*k; k=k%mod; k=k*a; k=k%mod; return k; }\n}\nfun prime (p:Long):Long {\n if (p==one) return 0.toLong();\n var i=two;\n while (i*i<=p) {if (p%i==nul) return i; i++; }\n return one;\n}\nfun inv (a:Long,mod:Long):Long {\nreturn powmod(a,mod-2,mod);\n}\n\nfun solve() {\n val cin = Scanner(System.`in`)\n\n /*\n var map=hashMapOf();\n map[q] <=> map.getOrDefault(q,0)\n \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0430\u0440 - k=v.sortedWith(compareBy({it.first},{it.second}));\n prLong(\"${k[i].second}\"); - \u0432\u044b\u0432\u043e\u0434 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0430\u0440\u044b\n var m=ArrayList (); <=> vector\n getline(cin,a) <=> readLine()!!.last()\n readLong() - \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e\n readLongs() - \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b\n readLine()!!.toCharArray() - \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0430\u0440\u043e\u0432 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438\n\n */\n /* --------- */\n // \u0412\u0421\u0415\u0413\u0414\u0410 \u041f\u0418\u0421\u0410\u0422\u042c \u0412 \u041b\u041e\u041d\u0413\u0410\u0425\n\n var (a1,a2,a3)=readLongs();\n var (b1,b2,b3)=readLongs();\n a1+=a2+a3;\n b1+=b2+b3;\n var n=readLong();\n var min1=(a1+four)/five+(b1+9.toLong())/10.toLong();\n if (min1>n) print(\"NO\"); else print(\"YES\"); \n /* --------- */\n\n}\n\nfun main() {\n val cin = Scanner(System.`in`)\n\n var T=one;\n //T=readLine()!!.toLong();\n for (i55555 in 1..T) solve()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "580ccbdca5ea9fd71dd00124d78392d4", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args:Array) {\n val a = readLine()!!.trim().split(\" \").asSequence().sumBy { s -> s.toInt() }\n val b = readLine()!!.trim().split(\" \").asSequence().sumBy { s -> s.toInt() }\n val n = readLine()!!.toInt();\n if ((a + 4) / 5 + (b + 9) / 10 <= n) print(\"YES\") else print(\"NO\")\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2f9d973e36576d97f22caf09ecc60a46", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n val a = readLine()!!.split(' ').map { it.toInt() }.sum()\n val b = readLine()!!.split(' ').map { it.toInt() }.sum()\n val n = readLine()!!.toInt()\n\n println(if (d(a,5) + d(b, 10) <= n) \"YES\" else \"NO\")\n}\n\nfun d(a : Int, n : Int) = if (a%n == 0) a/n else a/n + 1", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1f526d8f5e28cb0f5d788a22fd519614", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {\n companion object {\n fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n }\n\n var tok = StringTokenizer(\"\")\n\n fun close() { rd.close(); wr.close() }\n fun print(v: T) = wr.print(v)\n fun println(v: T) = wr.println(v)\n fun readToken(): String {\n while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())\n return tok.nextToken()\n }\n fun readInt() = readToken().toInt()\n fun readLong() = readToken().toLong()\n fun readLine() : String {\n tok = StringTokenizer(\"\")\n return rd.readLine()\n }\n}\n\nfun main(args: Array) {\n Thread({ val io = ProblemIO.console(); solve(io) ; io.close() }).start()\n}\n\nfun solve(io: ProblemIO) {\n val a = (1 .. 3).map({ io.readInt() }).sum()\n val b = (1 .. 3).map({ io.readInt() }).sum()\n val n = io.readInt()\n val res = (n >= ((a + 4) / 5) + ((b + 9) / 10))\n io.println(if (res) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "44b076a4814ea1864ff58690d22713a3", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "// https://codeforces.com/problemset/problem/448/A\n\n\nfun main(args: Array) {\n val medals = readInts()\n val cups = readInts()\n var totalShelves = readInt()\n\n val totalMedals = medals.sum()\n val totalCups = cups.sum()\n\n var totalCupsShelves = (totalCups / 10)\n if(totalCups % 10 != 0){\n totalCupsShelves += 1\n }\n var totalMedalsShelves = (totalMedals / 5)\n if(totalMedals % 5 != 0){\n totalMedalsShelves += 1\n }\n\n\n if(totalCupsShelves + totalMedalsShelves > totalShelves){\n print(\"NO\")\n }else{\n print(\"YES\")\n }\n\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings(del: String = \" \") = readLn().split(del) // list of strings\nprivate fun readInts(del: String = \" \") = readStrings(del).map { it.toInt() } // list of ints", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bde757fe8d9437cc6b7b15d74fd92a52", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n// \u041f\u0440\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u044b\n\nfun main(args: Array) {\n\n val kubok = readLine()!!.trim().split(\" \")\n val medal = readLine()!!.trim().split(\" \")\n val n = readLine()!!.trim().toInt()\n\n val countA = kubok.asSequence().sumBy { s -> s.toInt() }\n val countB = medal.asSequence().sumBy { s -> s.toInt() }\n\n // println(countA)\n // println(countB)\n\n val needRowToA = if (countA % 5 == 0) countA/5 else countA/5+1\n val needRowToB = if (countB % 10 == 0) countB/10 else countB/10+1\n\n // println(needRowToA)\n // println(needRowToB)\n\n if (n - needRowToB - needRowToA >= 0){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n /*\n \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u043b\u043a\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a\u0443\u0431\u043a\u0438 \u0438 \u043c\u0435\u0434\u0430\u043b\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e;\n \u043d\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u043a\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u044f\u0442\u0438 \u043a\u0443\u0431\u043a\u043e\u0432;\n \u043d\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u043a\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u0441\u044f\u0442\u0438 \u043c\u0435\u0434\u0430\u043b\u0435\u0439.\n */\n\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a67ac6a1a0006816575d0a8e222caade", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val s1 = r.readLine()!!.split(\" \").map { it.toInt() }.sum()\n val s2 = r.readLine()!!.split(\" \").map { it.toInt() }.sum()\n val v = r.readLine()!!.toInt()\n val ans = s1 / 5 + s2 / 10 + (if (s2 % 10 != 0) 1 else 0) + (if (s1 % 5 != 0) 1 else 0)\n println(if (ans <= v) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd1fc06b18a03a2bc9d9487abe3886a6", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var a = 0\n var b = 0\n readLine()!!.split(' ').map(String::toInt).forEach {\n a += it\n }\n readLine()!!.split(' ').map(String::toInt).forEach {\n b += it\n }\n val n = readLine()!!.toInt()\n if ((a+4)/5+(b+9)/10 <= n)\n print(\"YES\\n\")\n else\n print(\"NO\\n\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f7901fe6ffe023cc7c68ac5875e62da5", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(){\n val a = readInts()\n val s1 = a.sum()\n val b = readInts()\n val s2 = b.sum()\n val n = readInt()\n val p = s1 / 5 + if (s1 % 5 > 0) 1 else 0\n val q = s2 / 10 + if (s2 % 10 > 0) 1 else 0\n println(if (p + q > n) \"NO\" else \"YES\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f5abababf83c948e0b6cd36cbb86178f", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var q1 = 0\n var q2 = 0\n q1 = sc.nextInt() + sc.nextInt() + sc.nextInt()\n q2 = sc.nextInt() + sc.nextInt() + sc.nextInt()\n var s = sc.nextInt()\n var w: Int\n var e: Int\n w = q1 / 5;\n if (q1 % 5 != 0)\n w++;\n e = q2 / 10;\n if (q2 % 10 != 0)\n e++;\n if (s >= (e + w)) print(\"YES\")\n else print(\"NO\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d5f10645d33e8c409f8f3994bd9c3e44", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val line = readLine()!!\n val six = line.indexOf(' ')\n val n = line.substring(0, six).toLong()\n val k = line.substring(six + 1).toLong()\n var len = 0\n while (1L shl len <= n) {\n len++\n }\n fun amt(d: Long): Long {\n var res = 0L\n if (d % 2L == 0L) {\n res += amt(d + 1L)\n }\n var l = 0\n while (1L shl l <= d) {\n l++\n }\n var l2 = l\n while (l2 < len) {\n res += 1L shl (l2 - l)\n l2++\n }\n val q = n / (1L shl (len - l))\n if (q > d) {\n res += 1L shl (len - l)\n } else if (q == d) {\n res += (n % (1L shl (len - l))) + 1L\n }\n //println(\"amt($d) = $res\")\n return res\n }\n var lower = 0L\n var upper = n / 2L\n while (upper > lower) {\n val mid = (lower + upper + 1L) / 2L\n if (amt(2L * mid) >= k) {\n lower = mid\n } else {\n upper = mid - 1L\n }\n }\n var answer = upper * 2L\n if (amt(answer + 1L) >= k) {\n answer++\n }\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b28597df5032d1ae5ed493160d47545f", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\nval INF_F = 1e-6\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val k = reader.nextInt()\n val x = reader.nextInt()\n val a = reader.nextArrayInt(n).reversed().toMutableList()\n for (i in 0 until k) {\n a[i] = x\n }\n writer.println(a.sum())\n}\n\nfun gcd(a: Int, b: Int): Int {\n return if (b == 0) a else gcd(b, a % b)\n}\n\nclass InputReader(stream: InputStream) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ee533f197762f11262d9323727311138", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nval sc = java.util.Scanner(System.`in`)\n\ndata class Interval(val L: Int, val R: Int) : Comparable {\n\toverride fun compareTo(other: Interval): Int {\n\t\treturn compareValuesBy(this, other, Interval::L, Interval::R)\n\t}\n}\n\nfun main(args: Array) {\n\tval n = sc.nextInt()\n\tval k = sc.nextInt()\n\tval x = sc.nextInt()\n\tval a = Array(n) { sc.nextInt() }\n\ta.reverse()\n\tfor (i in 0 until k) a[i] = x\n\tprintln(a.sum())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b44f53b3794d60635a008ac48f26711e", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numChores, numReplazazbleChores, timeFastChores) = readInts()\n val chores = readInts().reversed()\n var sol = 0\n val end = min(numChores, numReplazazbleChores)\n for (chore in chores.subList(0, end)) sol += min(chore, timeFastChores)\n print(sol + chores.subList(end, numChores).sum())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "af4640cb099de8f4c83ca7145155f328", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n\nfun main(args: Array) {\n val spin = \"v<^>\"\n\n val line = readLine()!!\n val s = line.split(\" \")[0]\n val e = line.split(\" \")[1]\n\n val n = readLine()!!.toInt()\n\n when {\n n % 2 == 0 -> println(\"undefined\")\n n % 2 == 1 -> {\n if(spin[(spin.indexOf(s) + n) % 4] == e[0]) println(\"cw\")\n else println(\"ccw\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a0c51068aada2f5db0930c6a386ef4e9", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val positions = \"v<^>\"\n val fromTo = readLine()!!\n val duration = readLine()!!.toInt() % 4\n var sol = if (fromTo[2] == positions[(positions.indexOf(fromTo[0]) + duration) % 4]) 1 else 0\n if (fromTo[2] == positions[(positions.indexOf(fromTo[0]) + 4 - duration) % 4]) sol = sol or 2\n print(\n when (sol) {\n 1 -> \"cw\"\n 2 -> \"ccw\"\n else -> \"undefined\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d51c4bbf0b081725eae86db9d1832272", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n val s = \"<^>v\"\n val a = nextString()!![0].let { s.indexOf(it) }\n val b = nextString()!![0].let { s.indexOf(it) }\n val n = nextInt()\n if (b == (a + n) % 4 && b == Math.floorMod(a - n, 4)) {\n println(\"undefined\")\n } else if (b == Math.floorMod(a - n, 4)) {\n println(\"ccw\")\n } else {\n println(\"cw\")\n }\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "252ac25013aae1c1e5aa0e4391c81a88", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.test.assertTrue\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\n\nprivate fun solve() {\n var recipe = readLn()\n var (nb, ns, nc) = readInts()\n var (pb, ps, pc) = readInts()\n var r = readLong()\n\n var needB = false\n var needS = false\n var needC = false\n var cost = 0;\n for (c in recipe) {\n if (c == 'B') {\n needB = true\n cost += pb\n } else if (c == 'S') {\n needS = true\n cost += ps\n } else {\n needC = true\n cost += pc\n }\n }\n\n if (needB) {\n r += nb * pb\n }\n if (needS) {\n r += ns * ps\n }\n if (needC) {\n r += nc * pc\n }\n\n val ans = r / cost\n println(ans)\n}\n\nfun main() {\n var t = 1;\n // t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b5b6dfc2f522a6f63106c646c8a2b318", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\n\nvar nb = 0\nvar ns = 0\nvar nc = 0\nvar pb = 0\nvar ps = 0\nvar pc = 0\nvar r = 0L\nvar cb = 0\nvar cs = 0\nvar cc = 0\n\nprivate fun f(x: Long):\n Long {\n return Math.max(0, (x * cb - nb) * pb) + Math.max(0, (x * cs - ns) * ps) +\n Math.max(0, (x * cc - nc) * pc)\n}\n\nprivate fun solve() {\n var recipe = readLn()\n val (nb_, ns_, nc_) = readInts()\n nb = nb_\n ns = ns_\n nc = nc_\n val (pb_, ps_, pc_) = readInts()\n pb = pb_\n ps = ps_\n pc = pc_\n r = readLong()\n\n for (c in recipe) {\n when (c) {\n 'B' -> {\n cb++\n }\n 'S' -> {\n cs++\n }\n else -> {\n cc++\n }\n }\n }\n\n var x = 0L\n var jump: Long = 100000000000000L // 1e14\n while (jump >= 1) {\n while (f(x + jump) <= r) {\n x += jump\n }\n jump /= 2\n }\n\n println(x)\n}\n\nfun main() {\n var t = 1;\n // t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7ec9564fd05dcd8f7b799a3a02af62e7", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\n\nprivate fun solve() {\n var recipe = readLn()\n var (nb, ns, nc) = readInts()\n var (pb, ps, pc) = readInts()\n var r = readLong()\n\n var needB = false\n var needS = false\n var needC = false\n var cost = 0;\n for (c in recipe) {\n if (c == 'B') {\n needB = true\n cost += pb\n } else if (c == 'S') {\n needS = true\n cost += ps\n } else {\n needC = true\n cost += pc\n }\n }\n\n if (needB) {\n r += nb * pb\n }\n if (needS) {\n r += ns * ps\n }\n if (needC) {\n r += nc * pc\n }\n\n val ans = r / cost\n println(ans)\n}\n\nfun main() {\n var t = 1;\n // t = readInt();\n for (i in 1..t) {\n solve();\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b6d4c44b105e8ed0f47d0f13aeb99d7", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.min\n\nfun main(args: Array) {\n with(Scanner(System.`in`)) {\n val pt = mutableListOf()\n val X2 = nextInt()\n val mk = Array(X2 + 1, { true })\n val mf = Array(X2 + 1, { 0 })\n\n var counter = 0\n (2..X2).forEach {\n if (mk[it]) {\n pt.add(it)\n for (j in (it * 2)..X2 step it) {\n mk[j] = false\n mf[j] = it\n ++counter\n }\n }\n }\n\n pt.reverse()\n\n val lo = fun(x: Int) = x - mf[x] + 1\n\n var ans = X2\n (lo(X2)..X2).forEach {\n if (!mk[it]) {\n val c = lo(it)\n if (c > 3) {\n ans = min(ans, c)\n }\n }\n }\n println(ans)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "58da2a53c9b36f65d882ed9efb6f8b95", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.min\n\nfun main(args: Array) {\n with(Scanner(System.`in`)) {\n val pt = mutableListOf()\n val X2 = nextInt()\n val mk = Array(X2 + 1, { true })\n\n var counter = 0\n (2..X2).forEach {\n if (mk[it]) {\n pt.add(it)\n for (j in (it * 2)..X2 step it) {\n mk[j] = false\n ++counter\n }\n }\n }\n\n pt.reverse()\n\n val maxFactor = fun(x: Int): Int {\n return pt.first { x%it == 0 }\n }\n\n val lo = fun(x: Int) = x - maxFactor(x) + 1\n\n var ans = X2\n (lo(X2)..X2).forEach {\n val c = lo(it)\n if (c > 3) {\n ans = min(ans, c)\n }\n }\n println(ans)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5a952edd70008a9433c755704170ddc6", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val X2 = readLine() ?. toInt() ?: return\n\n val C = 1000000\n val mxp = IntArray(C+5) { -1 }\n for(i in 2 .. C) {\n if(mxp[i] == -1) {\n for(j in i .. C step i) {\n mxp[j] = i\n }\n }\n }\n\n val a = X2 - mxp[X2]\n val b = (X2 - mxp[X2] + 1 .. X2).filter({ mxp[it] != it }).map { it - mxp[it] }.min() ?: return\n println(Math.min(a, b) + 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0dfcbc767cdce7b4a5ddb9fd42d6c1ff", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (r, x, y, x2, y2) = readInts()\n val d = sqrt(((x - x2) * (x - x2) + (y - y2) * (y - y2)).toDouble())\n print(ceil(d / (r * 2)).toLong())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e94276626ff492725fc1fcf24f0d8dfe", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (r, x, y, x2, y2) = readInts()\n val d = sqrt((abs(x - x2) * abs(x - x2) + abs(y - y2) * abs(y - y2)).toDouble())\n print(ceil(d / (r * 2)).toLong())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fc44fc187763b9fa509facf762cf6f88", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.pow\nimport kotlin.math.sqrt\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val len = r.readLine()!!.toInt()\n val (radius, x, y, x1, y1) = r.readLine()!!.split(\" \").map { it.toDouble() }\n val dis = sqrt((x-x1).pow(2)+(y-y1).pow(2))\n val ans = (dis/(2*radius)).toInt() + if (dis-dis/(2*radius)*(2*radius)>=0.0) 1 else 0\n //println((dis/(2*radius)).toInt())\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e13d8832daf5e53be09b58be8955eb9d", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "// 8/5/2020 7:05 AM\n\n//package p507\n\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n val (r, x, y, x2, y2) = readInts()\n val distanceTo = sqrt(((x-x2)*(x-x2) + (y-y2)*(y-y2)).toDouble())\n if (x == x2 && y == y2) {\n println(0)\n return\n }\n\n if (distanceTo < r) {\n println(2)\n return\n }\n\n println( ceil((distanceTo) / (2*r)).toInt() )\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b91edad53cddc3ce25346a23454cf893", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\nimport kotlin.math.max\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (r, x, y, x2, y2) = readInts()\n print(max(abs(x2 - x) / (2 * r), abs(y2 - y) / (2 * r)))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "06aadc01406fe6826740002bee56a8c1", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.pow\nimport kotlin.math.sqrt\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val len = r.readLine()!!.toInt()\n val (radius, x, y, x1, y1) = r.readLine()!!.split(\" \").map { it.toDouble() }\n val dis = sqrt((x-x1).pow(2)+(y-y1).pow(2))\n val ans = (dis/(2*radius)).toInt() + if (dis%radius!=0.0) 1 else 0\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8685186e2660d4d61c78fc3350d38937", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "// 8/5/2020 7:05 AM\n/*\nhttps://codeforces.com/problemset/problem/507/B\n */\n//package p507\n\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n val (r, x, y, x2, y2) = readInts().map{ it.toLong() }\n val distanceTo = sqrt(((x-x2)*(x-x2) + (y-y2)*(y-y2)).toDouble())\n\n println( ceil((distanceTo) / (2*r)).toInt() )\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4c1a08fe042995424788f425aaa98696", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (r, x, y, x2, y2) = readLongs()\n val d = sqrt(((x - x2) * (x - x2) + (y - y2) * (y - y2)).toDouble())\n print(ceil(d / (r * 2)).toLong())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "72c959b59810c968f50080bdedb11cee", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "//package com.happypeople.codeforces.c1097\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n B().run()\n } catch (e: Throwable) {\n B.log(\"\" + e)\n }\n}\n\nclass B {\n fun run() {\n val sc = Scanner(systemIn())\n val n=sc.nextInt()\n val a=(1..n).map { sc.nextInt() }\n\n val res=binsearch(a, 0, 0)\n if(res)\n println(\"YES\")\n else\n println(\"NO\")\n }\n\n fun binsearch(a:List, next:Int, sum:Int):Boolean {\n if(next==a.size)\n return sum%360==0\n else\n return binsearch(a, next+1, sum+a[next]) ||\n binsearch(a, next+1, sum-a[next])\n }\n\n companion object {\n var inputStr: String? = null\n\n fun systemIn(): InputStream {\n if (inputStr != null)\n return ByteArrayInputStream(inputStr!!.toByteArray())\n else\n return System.`in`\n }\n\n var printLog = false\n fun log(str: String) {\n if (printLog)\n println(str)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "75ccfe61ad3ad17771ecb4bd30d62020", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nfun BufferedReader.readIntList() = readLine().split(' ').map(String::toInt)\nfun BufferedReader.readLongList() = readLine().split(' ').map(String::toLong)\n\nclass Solution(private val inf: BufferedReader, private val ouf: PrintWriter) : Runnable {\n constructor() : this(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))\n\n fun solve() {\n val n = inf.readLine().toInt()\n val a = IntArray(n) {\n inf.readLine().toInt()\n }\n var ans = false\n for (i in 0 until (1 shl n)) {\n var sum = 0\n for (j in a.indices) {\n if ((i and (1 shl j)) == 0) sum += a[j] else sum -= a[j]\n }\n if ((sum % 360 + 360) % 360 == 0) ans = true\n }\n ouf.println(if (ans) \"YES\" else \"NO\")\n }\n\n override fun run() {\n// for (testNum in 1..inf.readLine().toInt()) {\n solve()\n// }\n\n ouf.close()\n }\n}\n\nfun main(args: Array) {\n Thread(null, Solution(), \"name\", 1 shl 27).start()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "162f9bce1696d3b4be2f780ba612325f", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n //println((4 or 6)xor(4 or 5))\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val n = r.readLine()!!.toInt()\n var v = mutableListOf(0)\n repeat(r.readLine()!!.toInt()) {\n val n = r.readLine()!!.toInt()\n val newList = mutableListOf()\n v.forEach {\n newList += it+n\n newList += it-n\n }\n v = newList\n }\n val ans = v.any { it%360==0 }\n println(if (ans) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "105525bcacb826657b2158e68d558a6d", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n\n var possibilities = setOf(0)\n\n repeat(n) {\n val a = readInt()\n\n possibilities = sequence {\n for(p in possibilities) {\n yield((p + a) umod 360)\n yield((p - a) umod 360)\n }\n }.toSet()\n }\n\n if(0 in possibilities) println(\"YES\") else println(\"NO\")\n}\n\ninfix fun Int.umod(divisor: Int) =\n (this % divisor).let { if(it >= 0) it else it + divisor }\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ef16d7b1070d929d13dfe7a138831739", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main(arg: Array){\n\tvar N = readLine()!!.toInt()\n\tval NN = N\n\tval M = 2.0.pow(N.toDouble()).toInt()\n\tval L = mutableListOf()\n\tvar S = 0\n\twhile(N > 0){\n\t\tL.add(readLine()!!.toInt())\n\t\tN--\n\t}\n\tL.forEach(){\n\t\tS += it\n\t}\n\tfor(i in 0..M-1){\n\t\tval opts = i.toString(2).padStart(NN,'0')\n\t\t//println(opts)\n\t\tvar Sum = 0\n\t\tfor (i in 1..opts.length){\n\t\t\tif(opts[i-1] == '0'){\n\t\t\t\tSum -= L[i-1]\n\t\t\t}else{\n\t\t\t\tSum += L[i-1]\n\t\t\t}\n\t\t}\n\t\tif(Sum.rem(360) == 0){\n\t\t\t//println(\"OGON: $opts $Sum\")\n\t\t\tprintln(\"YES\")\n\t\t\treturn\n\t\t}\n\n\t}\n\tprintln(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "58765a503bce91e6c78e52028a5d4dac", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val (n, k) = r.readLine()!!.split(\" \").map { it.toInt() }\n val n = r.readLine()!!.toInt()\n println((n/2-1)/2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "77f99ed4c1fad54bc9652411fb7b2ea9", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val (n, k) = r.readLine()!!.split(\" \").map { it.toInt() }\n val n = r.readLine()!!.toInt()\n println(n/2/2)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "56c6e8f6c3e6f2e8bc6f0c0d7bc85027", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Kotlin 1.4", "source_code": "// $time$\nimport java.io.BufferedInputStream\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.system.measureTimeMillis\nimport java.util.TreeMap\nimport java.util.TreeSet\n\ninline fun TIME(f:()->Unit){\n val t = measureTimeMillis(){\n f()\n }\n println(\"$t ms\")\n}\n\nobject IO{\n private const val BS = 1 shl 16\n private const val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n\n var warningActive = true\n var fakein = StringBuilder()\n\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\n val OUT: PrintWriter = PrintWriter(System.out)\n\n private val char: Char\n get() {\n while (bId == size) {\n size = IN.read(buf) // no need for checked exceptions\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextLong(): Long {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0L\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextString():String{\n val ret = StringBuilder()\n while (true){\n c = char\n if(!isWhitespace(c)){ break}\n }\n ret.append(c)\n while (true){\n c = char\n if(isWhitespace(c)){ break}\n ret.append(c)\n }\n return ret.toString()\n }\n fun isWhitespace(c:Char):Boolean{\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\n }\n fun rerouteInput(){\n if(warningActive){\n put(\"You forgot to disable tests you digital dummy!\")\n println(\"You forgot to disable tests you digital dummy!\")\n warningActive = false\n }\n val S = fakein.toString()\n println(\"New Case \")\n println(S.take(80))\n println(\"...\")\n fakein.clear()\n IN = BufferedInputStream(S.byteInputStream(),BS)\n }\n fun takeFile(name:String){\n IN = BufferedInputStream(File(name).inputStream(),BS)\n }\n}\nfun put(aa:Any){ IO.OUT.println(aa)}\nfun done(){ IO.OUT.close() }\nfun share(aa:Any){\n if(aa is IntArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is LongArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is List<*>){IO.fakein.append(aa.toString())}\n else{IO.fakein.append(aa.toString())}\n IO.fakein.append(\"\\n\")\n}\n\nval getintfast:Int get() = IO.nextInt()\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\nval getlong:Long get() = IO.nextLong()\nval getstr:String get() = IO.nextString()\nfun getline(n:Int):IntArray{\n return IntArray(n){getint}\n}\nfun getlineL(n:Int):LongArray{\n return LongArray(n){getlong}\n}\nfun getbinary(n:Int, asTrue:Char):BooleanArray{\n val str = getstr\n return BooleanArray(n){str[it] == asTrue}\n}\n\nval List.ret:String\nget() = this.joinToString(\"\")\nvar dmark = -1\ninfix fun Any.dei(a:Any){\n //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators\n dmark++\n var str = \"<${dmark}> \"\n debug()\n if(this is String){ str += this\n }else if(this is Int){ str += this.toString()\n }else if(this is Long){ str += this.toString()\n }else{ str += this.toString()}\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\n }else if(a is Array<*>){\n println(\"$str : \")\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\n else if(c is LongArray){println(c.joinToString(\" \"))}\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\n }\n\n }\n println()\n }else{ println(\"$str : $a\")\n }\n}\nval just = \" \" // usage: just dei x , where x is the debug variable\nfun crash(){\n throw Exception(\"Bad programme\")} // because assertion does not work\nfun assert(a:Boolean){\n if(!a){\n throw Exception(\"Failed Assertion\")\n }}\nenum class solveMode {\n real, rand, tc\n}\nobject solve{\n var mode:solveMode = solveMode.real\n var tcNum:Int = 0\n var rand:()->Unit = {}\n var TC:MutableMapUnit> = mutableMapOf()\n var answersChecked = 0\n var tn:Long = 0\n fun cases(onecase:()->Unit){\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\n //safety checks\n if(pI != 998_244_353 && pI != 1_000_000_007){\n throw Exception(\"Modding a wrong prime!\")\n }\n if(withBruteForce){\n println(\"Brute force is active\")\n }\n\n if(t == 1 && mode != solveMode.real){\n tn = System.currentTimeMillis()\n }\n repeat(t){\n if(mode == solveMode.tc){\n TC[tcNum]?.let { it() }\n IO.rerouteInput()\n }else if(mode == solveMode.rand){\n rand()\n IO.rerouteInput()\n }\n onecase()\n }\n if(t == 1 && mode != solveMode.real){\n val dt = System.currentTimeMillis() - tn\n println(\"Time $dt ms \")\n }\n }\n inline fun singleCase(a:solve.()->Unit){\n val t = if(mode != solveMode.rand){1} else randCount\n repeat(t) { a() }\n }\n fun rand(a:()->Unit){\n this.rand = a\n }\n fun tc(id:Int = 0,a:()->Unit){\n TC[id] = a\n }\n fun usetc(a:Int = 0 ){\n this.tcNum = a\n this.mode = solveMode.tc\n }\n fun userand(){\n this.mode = solveMode.rand\n }\n}\ninline fun T.alsoBrute(cal:() -> T){\n if(!withBruteForce) return\n val also = cal()\n if(this != also){\n println(\"Checking failed: Got ${this} Brute ${also}\")\n crash()\n }\n}\n// 1. Modded\nconst val p = 1000000007L\nconst val pI = p.toInt()\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\n// 2. DP initial values\nconst val plarge = 1_000_000_727\nconst val nlarge = -plarge\nconst val phuge = 2_727_000_000_000_000_000L\nconst val nhuge = -phuge\n// 3. conveniecen conversions\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\n//3. hard to write stuff\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\nval mint:MutableList get() = mutableListOf()\nval mong:MutableList get() = mutableListOf()\n//4. more outputs\nfun List.conca():String = this.joinToString(\"\")\nval CharArray.conca :String get() = this.joinToString(\"\")\nval IntArray.conca :String get() = this.joinToString(\" \")\n@JvmName(\"concaInt\")\nfun List.conca():String = this.joinToString(\" \")\nval LongArray.conca:String get() = this.joinToString(\" \")\n@JvmName(\"concaLong\")\nfun List.conca():String = this.joinToString(\" \")\n//5. Pair of ints\nconst val longmask = (1L shl 32) - 1\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\nval Long.first get() = (this ushr 32).toInt()\nval Long.second get() = this.toInt()\n//6. strings\nval String.size get() = this.length\nconst val randCount = 100\n//7. bits\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\n\n\n\n\nfun debug(){}\nconst val withBruteForce = false\nconst val singleCase = true\nfun main(){\n val t= TreeSet()\n t.addAll(listOf(1200,1400,1600,1900,2100,2300,2400,2600,3000))\n solve.cases{\n val r = getint\n put(t.ceiling(r)!!)\n\n\n\n\n\n }\n done()\n}\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "62638cc3818a64eeccd1d897974ef4e2", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nval INPUT = System.`in`!!\nval OUTPUT = System.out!!\nval reader = INPUT.bufferedReader()\nfun readLine(): String? = reader.readLine()\nfun line() = reader.readLine()!!\nvar st: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (st.hasMoreTokens().not())\n st = StringTokenizer(reader.readLine() ?: return \"\", \" \")\n return st.nextToken()\n}\nfun int() = read().toInt()\nfun ints(n: Int) = List(n) { read().toInt() }\nfun intArray(n: Int) = IntArray(n) { read().toInt() }\nval writer = PrintWriter(OUTPUT, false)\nfun main() { writer.solve(); writer.flush() }\nfun PrintWriter.solve() {\n var tt = 1\n //tt = int()\n while (tt-- > 0) {\n val n = int()\n val arr = arrayOf(1200, 1400, 1600, 1900, 2100, 2300, 2400, 2600, 3000)\n for(i in arr) {\n if(i > n) {\n println(i)\n break\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "77aa6d1818b82e00518dacabb4823f46", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.min\n\nfun getMinRest (a: List): Int {\n val inf = 100000\n tailrec fun go (xs: Queue, rest: Int, contest: Int, gym: Int): Int =\n if (xs.isEmpty()) min(rest, min(contest, gym))\n else {\n val newRest = min(rest, min(contest, gym)) + 1\n when (xs.poll()) {\n '0' -> go(xs, newRest, inf, inf)\n '1' -> go(xs, newRest, min(rest, gym), inf)\n '2' -> go(xs, newRest, inf, min(rest, contest))\n else -> go(xs, newRest, min(rest, gym), min(rest, contest))\n }\n }\n return go(LinkedList(a),0, inf, inf)\n}\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val n = br.readLine().toInt()\n val a = br.readLine().split(\" \").map { it.single() }\n println(getMinRest(a))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9ee3a1bac64af7a757929b6caf3afb48", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun solve(): String {\n val a = readLine()!!.split(' ').map {it.toInt()}\n var ma = -1\n for (i in 0..3)\n for (j in 0..3)\n for (k in 0..3)\n if (i != j && j != k && k != i)\n ma = maxOf(ma, a[i] + a[j] + a[k] - 2 * maxOf(a[i], a[j], a[k]))\n return when {\n (ma > 0) -> \"TRIANGLE\"\n (ma == 0) -> \"SEGMENT\"\n else -> \"IMPOSSIBLE\"\n }\n}\n\nfun main(args: Array) {\n println(solve())\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "33819a6c0ed07f0aebca3112cad7813c", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ').map { it.toInt() }\n\nfun a6() {\n val list: List = readInts().sortedDescending()\n\n if (list[1] + list[2] > list[0] || list[2] + list[3] > list[0] || list[1] + list[3] > list[0] || list[2] + list[3] > list[1])\n print(\"TRIANGLE\")\n else if (list[1] + list[2] == list[0] || list[2] + list[3] == list[0] || list[1] + list[3] == list[0] || list[2] + list[3] == list[1])\n print(\"SEGMENT\")\n else\n print(\"IMPOSSIBLE\")\n}\n\nfun main() {\n a6()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b4692a441bb690206f4486a6e5aa69e0", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\nfun canMakeTriangle(x: Int, y: Int, z: Int) = (x + y > z && x + z > y && y + z > x)\nfun canMakeSegment(x: Int, y: Int, z: Int) = (x + y == z || x + z == y || y + z == x)\n\nfun main(args: Array) {\n val lines = readLine()!!.split(\" \").map { it.toInt() }\n\n lines.forEach {\n val tr = lines.minus(it)\n if (canMakeTriangle(tr[0], tr[1], tr[2])) {\n println(\"TRIANGLE\")\n return\n }\n }\n\n lines.forEach {\n val tr = lines.minus(it)\n if (canMakeSegment(tr[0], tr[1], tr[2])) {\n println(\"SEGMENT\")\n return\n }\n }\n\n println(\"IMPOSSIBLE\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1eb9074f0d995875346247ef356ffeca", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n\n var arr1 = IntArray(4)\n\n for (i in 0..3) {\n arr1[i] = reader.nextInt()\n }\n\n compare(arr1[0], arr1[1], arr1[2], arr1[3])\n\n}\n\n fun compare(a: Int, b: Int, c: Int, d: Int) : Unit {\n\n if ((a < b + c && b < a + c && c < a + b) || (a < b + d && b < a + d && d < a + b) || (a < d + c && d < a + c && c < a + d) || (d < b + c && b < d + c && c < d + b))\n println(\"TRIANGLE\")\n else if ((a == b + c || b == a + c || c == a + b) || (a == b + d || b == a + d || d == a + b) || (a == d + c || d == a + c || c == a + d) || (d == b + c || b == d + c || c == d + b))\n println(\"SEGMENT\")\n else\n println(\"IMPOSSIBLE\")\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "73529a5494ae89d1d2af9131faf218f6", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val In = BufferedReader(InputStreamReader(System.`in`))\n val sticks = In.readLine()!!.split(\" \").map {it.toInt()}\n sticks.sorted()\n if(sticks[0] + sticks[1] > sticks[2] && sticks[1] + sticks[2] > sticks[0] && sticks[0] + sticks[2] > sticks[1] ||\n sticks[1] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[1] && sticks[1] + sticks[3] > sticks[2] ||\n sticks[0] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[0] && sticks[0] + sticks[3] > sticks[2] ||\n sticks[1] + sticks[0] > sticks[3] && sticks[0] + sticks[3] > sticks[1] && sticks[1] + sticks[3] > sticks[0]) {\n println(\"TRIANGLE\")\n } else if(sticks[0] + sticks[1] == sticks[2] || sticks[0] + sticks[1] == sticks[3] ||\n sticks[1] + sticks[2] == sticks[3] || sticks[0] + sticks[2] == sticks[3]) {\n println(\"SEGMENT\")\n } else\n println(\"IMPOSSIBLE\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "44c66f39f955539b1fb01041d3521c4b", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "//package codeforces\n\nimport java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val In = BufferedReader(InputStreamReader(System.`in`))\n val sticks = In.readLine()!!.split(\" \").map {it.toInt()}\n sticks.sorted()\n if(sticks[0] + sticks[1] > sticks[2] && sticks[1] + sticks[2] > sticks[0] && sticks[0] + sticks[2] > sticks[1] ||\n sticks[1] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[1] && sticks[1] + sticks[3] > sticks[2] ||\n sticks[0] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[0] && sticks[0] + sticks[3] > sticks[2] ||\n sticks[1] + sticks[0] > sticks[3] && sticks[0] + sticks[3] > sticks[1] && sticks[1] + sticks[3] > sticks[0]) {\n println(\"TRIANGLE\")\n } else if(sticks[0] + sticks[1] == sticks[2] || sticks[0] + sticks[1] == sticks[3] ||\n sticks[1] + sticks[2] == sticks[3] || sticks[0] + sticks[2] == sticks[3]) {\n println(\"SEGMENT\")\n } else\n println(\"IMPOSSIBLE\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0a802ceb8b5cb3f175154e85416b78dd", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun readInts() = readLine()!!.split(' ').map { it.toInt() }\n\nfun a6() {\n val list: List = readInts().sortedDescending()\n\n if (list[1] + list[2] > list[0] || list[2] + list[3] > list[0] || list[1] + list[3] > list[0] || list[2] + list[3] > list[1])\n print(\"TRIANGLE\")\n else if (list[1] + list[2] + list[3] > list[0])\n print(\"SEGMENT\")\n else\n print(\"IMPOSSIBLE\")\n}\n\nfun main() {\n a6()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "801efb0e01b7744cfa56b248313482c6", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\")\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln // immediate println for interactive\n\nfun main() {\n output {\n val n = readInt()\n val s = readLn().toCharArray()\n\n val ans = sequence {\n val init = Ans(s.beauty(), 0, 0)\n yield(init)\n if(init.b == 0) return@sequence\n\n for(i in 0 until n-1) {\n for(j in i+1 until n) {\n s.swap(i, j)\n yield(Ans(s.beauty(), i, j))\n s.swap(i, j)\n }\n }\n }.maxBy { it.b }!!\n\n println(ans)\n }\n}\n\nfun CharArray.swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n\nfun CharArray.beauty(): Int {\n var min = 0\n var count = 0\n var acc = 0\n\n for(c in this) {\n when(c) {\n '(' -> acc++\n ')' -> acc--\n }\n when {\n acc == min -> count++\n acc < min -> {\n min = acc\n count = 1\n }\n }\n }\n\n return if(acc == 0) count else 0\n}\n\ndata class Ans(val b: Int, val l: Int, val r: Int) {\n override fun toString(): String = \"$b\\n${l+1} ${r+1}\"\n}\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9e9e60f74d8af47b0ed703f836cdc830", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\")\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport java.util.StringTokenizer\nimport java.util.TreeSet\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln // immediate println for interactive\n\nfun main() {\n output {\n val n = readInt()\n val s = readLn().toCharArray()\n\n val ans = sequence {\n val init = Ans(s.beauty(), 0, 0)\n yield(init)\n if(init.b == 0) return@sequence\n\n for(i in 0 until n-1) {\n for(j in i+1 until n) {\n if(s[i] == s[j]) continue\n s.swap(i, j)\n yield(Ans(s.beauty(), i, j))\n s.swap(i, j)\n }\n }\n }.maxBy { it.b }!!\n\n println(ans)\n }\n}\n\nfun CharArray.swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n\nfun CharArray.beauty(): Int {\n var min = 0\n var count = 0\n var acc = 0\n\n for(c in this) {\n when(c) {\n '(' -> acc++\n ')' -> acc--\n }\n when {\n acc == min -> count++\n acc < min -> {\n min = acc\n count = 1\n }\n }\n }\n\n return if(acc == 0) count else 0\n}\n\ndata class Ans(val b: Int, val l: Int, val r: Int) {\n override fun toString(): String = \"$b\\n${l+1} ${r+1}\"\n}\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3d40ac95aec25f3737083ebe53e99eca", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val n = readLine()!!.toInt()\n val ys = IntArray((2 * n) + 1)\n val line = readLine()!!\n for (i in 0 until 2 * n) {\n ys[i + 1] = ys[i] + if (line[i % n] == '(') 1 else -1\n }\n if (ys[n] != 0) {\n println(0)\n println(\"1 1\")\n return\n }\n val low = ys.min()!!\n val sums = Array(3) { IntArray((2 * n) + 1) }\n //println(\"ys = ${ys.contentToString()}\")\n //println(\"low = $low\")\n for (i in 1..2 * n) {\n for (j in 0..2) {\n sums[j][i] = sums[j][i - 1]\n }\n if (ys[i] - low <= 2) {\n sums[ys[i] - low][i]++\n }\n }\n /*for (j in 0..2) {\n println(\"sums[$j] = ${sums[j].contentToString()}\")\n }*/\n val last = IntArray(2)\n val nearest = Array(2) { IntArray(n + 1) }\n for (i in 2 * n downTo 1) {\n if (ys[i] - low <= 1) {\n last[ys[i] - low] = i\n }\n if (i <= n) {\n for (j in 0..1) {\n nearest[j][i] = last[j]\n }\n }\n }\n /*for (j in 0..1) {\n println(\"nearest[$j] = ${nearest[j].contentToString()}\")\n }*/\n var answer = sums[0][n]\n var al = 1\n var ar = 1\n for (i in 1..n) {\n if (line[i - 1] == '(') {\n var j = min(nearest[0][i], nearest[1][i])\n var pos = sums[0][n] + sums[2][j - 1] - sums[2][i - 1]\n if (pos > answer) {\n answer = pos\n al = i\n ar = j\n }\n if (nearest[1][i] < nearest[0][i]) {\n j = nearest[0][i]\n pos = sums[1][j - 1] - sums[1][i - 1]\n if (pos > answer) {\n answer = pos\n al = i\n ar = j\n }\n }\n }\n }\n println(answer)\n println(\"$al ${((ar - 1) % n) + 1}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7d39cf59aece6a2eca8937063e639a65", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.BufferedReader\r\n\r\nval bin = System.`in`.bufferedReader()\r\nfun BufferedReader.readInts() = this.readLine()!!.split(' ').map { it.toInt() }.toIntArray()\r\n\r\nfun main() {\r\n// explore()\r\n val (n, m) = bin.readInts()\r\n println(solve(n, m))\r\n}\r\n\r\nfun solve(n: Int, m: Int): Int {\r\n val s = IntArray(n+1)\r\n s[n] = 1\r\n\r\n var sum = 0\r\n for (x in n downTo 2) {\r\n s[x] = (s[x] + sum) % m\r\n val v = s[x]\r\n\r\n var l = 1\r\n while (l <= x) {\r\n val t = x/l\r\n val r = binarySearchRightmost(l..x) { x/it == t }!!\r\n val copies = r-l+1\r\n s[t] = ((s[t] + copies.toLong()*v) % m).toInt()\r\n l = r+1\r\n }\r\n\r\n sum = (sum + v) % m\r\n }\r\n\r\n return (s[1] + sum) % m\r\n}\r\n\r\n/**\r\n * TTTTFFFF pattern, finds rightmost true value\r\n */\r\nfun binarySearchRightmost(range: IntRange, check: (Int) -> Boolean): Int? {\r\n var l = range.first\r\n var r = range.last+1\r\n while (l < r) {\r\n val m = (l + r) / 2\r\n\r\n if (check(m)) {\r\n l = m+1\r\n } else {\r\n r = m\r\n }\r\n }\r\n return if (r-1 in range) r-1 else null\r\n}\r\n\r\nfun explore() {\r\n var total = 0L\r\n for (x in 2..200000) {\r\n// val res = sortedMapOf()\r\n for (i in 2..x) {\r\n if (x / i == 1) break\r\n// res[x / i] = (res[x / i] ?: 0) + 1\r\n total ++\r\n }\r\n if (x % 10000 == 0) println(x)\r\n// total += res.map { it.value }.sum()\r\n }\r\n\r\n println(\"Total: $total\")\r\n// println(\"$x size=${res.size}\")\r\n// println(\"$x = ${res.map { \"${it.key}:${it.value}\" }.joinToString(separator=\", \")}\")\r\n}\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f36cbd7032502f3708e012d7344e8057", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "Kotlin 1.4", "source_code": "import java.io.BufferedReader\r\nimport java.util.*\r\n\r\nval bin = System.`in`.bufferedReader()\r\nfun BufferedReader.readInts() = this.readLine()!!.split(' ').map { it.toInt() }.toIntArray()\r\n\r\nfun main() {\r\n// val t = measureTimeMillis {\r\n// solve(200000, 998244353)\r\n// }\r\n// println(\"Took $t ms\")\r\n\r\n// explore()\r\n val (n, m) = bin.readInts()\r\n println(solve(n, m))\r\n}\r\n\r\nfun solve(n: Int, m: Int): Int {\r\n val s = IntArray(n+1)\r\n s[n] = 1\r\n\r\n var sum = 0\r\n for (x in n downTo 2) {\r\n s[x] = (s[x] + sum) % m\r\n val v = s[x]\r\n\r\n var l = 1\r\n while (l*l <= x) {\r\n if (l != 1 && x/l != l) {\r\n s[x / l] = (s[x / l] + v) % m\r\n }\r\n val copies = x/l - x/(l+1)\r\n s[l] = ((s[l] + v.toLong() * copies) % m).toInt()\r\n l++\r\n }\r\n\r\n sum = (sum + v) % m\r\n }\r\n\r\n return (s[1] + sum) % m\r\n}\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a2547fc297794fbd088bf50a7fcf401f", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main() {\n val fs = CodeForces.FastReader()\n var n = fs.nextInt()\n var ans =0\n var a = ArrayList()\n for (i in 1..n) {\n for (j in 1..n) {\n for (k in 1..n) {\n var sum = i+j+k\n var max = max(max(i,j),k)\n var min = min(min(i,j),k)\n if(i xor j xor k == 0 && sum - max > max && sum - max - 2*min < max && !a.contains(i+j+k)){\n ans++\n a.add(i+j+k)\n }\n }\n }\n }\n println(ans)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n\n fun readLongArray(n: Int): LongArray {\n val a = LongArray(n)\n for (i in 0 until n) a[i] = nextLong()\n return a\n }\n\n fun readDoubleArray(n: Int): DoubleArray {\n val a = DoubleArray(n)\n for (i in 0 until n) a[i] = nextDouble()\n return a\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2ba8eee92a622afaf4a3040b6219fcae", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main() {\n val fs = CodeForces.FastReader()\n var n = fs.nextInt()\n var ans =0\n var a = ArrayList()\n for (i in 1..n) {\n for (j in 1..n) {\n var k = i xor j\n var sum = i+j+k\n var max = max(max(i,j),k)\n var min = min(min(i,j),k)\n if(k in 1..n && sum - max > max && sum - max - 2*min < max && !a.contains(i+j+k)){\n ans++\n a.add(i+j+k)\n break;\n }\n }\n }\n println(ans)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n\n fun readLongArray(n: Int): LongArray {\n val a = LongArray(n)\n for (i in 0 until n) a[i] = nextLong()\n return a\n }\n\n fun readDoubleArray(n: Int): DoubleArray {\n val a = DoubleArray(n)\n for (i in 0 until n) a[i] = nextDouble()\n return a\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "260ac3c55a6ac94bd19b253f73f69d0d", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val n = readLine()!!.toInt()\n var sol = 0\n for (a in 1..n)\n for (b in a..n) {\n val cCandidate = a xor b\n if (cCandidate in b..min(n, a + b - 1)) sol++\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "430f3146cb8bf02ec3a59a5735d2aca1", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main() {\n val fs = CodeForces.FastReader()\n var n = fs.nextInt()\n var ans =0\n for (i in 1..n) {\n for (j in i..n) {\n var k = i xor j\n if(k in 1..n){\n var sum = i+j+k\n var max = max(max(i,j),k)\n var min = min(min(i,j),k)\n if(sum - max > max && sum - max - 2*min < max ){\n ans++\n }\n }\n }\n }\n println(ans/3)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n\n fun readLongArray(n: Int): LongArray {\n val a = LongArray(n)\n for (i in 0 until n) a[i] = nextLong()\n return a\n }\n\n fun readDoubleArray(n: Int): DoubleArray {\n val a = DoubleArray(n)\n for (i in 0 until n) a[i] = nextDouble()\n return a\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "45783b92a9b198e87dee86754cc7171e", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main() {\n val fs = CodeForces.FastReader()\n var n = fs.nextInt()\n var ans =0\n var a = ArrayList()\n for (i in 1..n) {\n for (j in i..n) {\n var k = i xor j\n var sum = i+j+k\n var max = max(max(i,j),k)\n var min = min(min(i,j),k)\n if(k in 1..n && sum - max > max && sum - max - 2*min < max && !a.contains(i+j+k)){\n ans++\n a.add(i+j+k)\n break;\n }\n }\n }\n println(ans)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n\n fun readLongArray(n: Int): LongArray {\n val a = LongArray(n)\n for (i in 0 until n) a[i] = nextLong()\n return a\n }\n\n fun readDoubleArray(n: Int): DoubleArray {\n val a = DoubleArray(n)\n for (i in 0 until n) a[i] = nextDouble()\n return a\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bb6c69d13d20ea2ed95e9628b3f52268", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, ks) = readLine()!!.split(\" \")\n val k = ks.toInt()\n if (k == 0) return print(0)\n var sol = 0\n var numZeros = 0\n for (c in n.reversed()) {\n if (c == '0') numZeros++ else sol++\n if (numZeros == k) break\n }\n print(if (numZeros == k) sol else n.length - 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "03401a2e5174ffc6072dcae69287495b", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt(); val pos = nextInt()\n val l = nextInt(); val r = nextInt()\n\n val leftToRight = pos - l + 1 + (1 + r - l) * (if (r != n) 1 else 0)\n val rightToLeft = r - pos + 1 + (1 + r - l) * (if (l != 1) 1 else 0)\n\n if (l == 1 && r == n) {\n print(0)\n } else {\n print(minOf(leftToRight, rightToLeft))\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8bdd9a3f120277064f20d848efb0a5fa", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, pos, l, r) = readLine()!!.split(\" \").map(String::toInt)\n val toDelete = mutableListOf()\n if (l > 1)\n toDelete.add(pos - l)\n if (r < n)\n toDelete.add(r - pos)\n toDelete.sort()\n var sol = 0\n when (toDelete.size) {\n 1 -> sol += toDelete[0] + 1\n 2 -> sol += toDelete[0] + 1 + toDelete[0] + toDelete[1] + 1\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8af0fbb9ffa655e5b972da7cc412de6e", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main() {\n var (n, pos, l, r) = readLine()!!.split(\" \").map(String::toInt)\n val toDelete = mutableListOf>()\n if (l > 1)\n toDelete.add(pos - l to l)\n if (r < n)\n toDelete.add(r - pos to r)\n toDelete.sortBy { it.first }\n var sol = 0\n for(tab in toDelete) {\n sol += abs(pos -tab.second) + 1\n pos = tab.second\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1fc6fa3d0e1c15113479ec3fc9c1b033", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.min\n\n\nclass B {\n fun solve(input : InputStream, output : OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n val n = reader.nextInt()\n val pos = reader.nextInt()\n val l = reader.nextInt()\n val r = reader.nextInt()\n\n writer.println(solve(n, pos, l, r))\n\n writer.close()\n }\n\n fun range(a : Int, b : Int) : Int {\n return abs(a - b)\n }\n\n fun solve(n : Int, pos : Int, l : Int, r : Int) : Int {\n if (l == 1 && r == n) {\n return 0\n }\n if (l == 1) {\n return range(pos, r) + 1\n }\n if (r == n) {\n return range(pos, l) + 1\n }\n\n val leftFirst = range(pos, l) + 1 + range(l, r) + 1\n val rightFirst = range(pos, r) + 1 + range(l, r) + 1\n return min(leftFirst, rightFirst)\n }\n\n private class InputReader(stream: InputStream) {\n var reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n }\n}\n\nfun main(args : Array) {\n B().solve(System.`in`, System.out)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3360f75b7dc9332cbc0e415b5e580004", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.lang.Math.*\nimport java.util.*\n\n\nfun main() {\n init(System.`in`, System.out)\n val twos = LongArray(64) { i -> 1L shl i }\n val l = nextLong()\n val r = nextLong()\n var max = 0L\n for (i in 0 until 64) {\n if (twos[i] and l != twos[i] and r) {\n max = (1L shl i + 1) - 1\n }\n }\n pw.println(max)\n pw.close()\n}\n\nlateinit var br: BufferedReader\nlateinit var st: StringTokenizer\nlateinit var pw: PrintWriter\n\nfun init(`in`: InputStream, out: OutputStream) {\n br = BufferedReader(InputStreamReader(`in`))\n st = StringTokenizer(\"\")\n pw = PrintWriter(out)\n}\n\nfun init(`in`: File, out: File) {\n br = BufferedReader(FileReader(`in`))\n st = StringTokenizer(\"\")\n pw = PrintWriter(out)\n}\n\nfun next(): String {\n if (!st.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st.nextToken()\n}\n\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5349e63576d4029c7f483f45cc152313", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.concurrent.fixedRateTimer\nimport kotlin.math.max\n\nclass Solution : Runnable {\n override fun run() {\n solve()\n }\n\n fun start() {\n Thread(null, Solution(), \"whatever\", (1 shl 27).toLong()).start()\n }\n}\n\nfun main(args: Array) {\n Solution().start()\n}\n\n\nclass IO {\n companion object {\n\n private val reader: InputReader\n private val writer: OutputWriter\n\n init {\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n reader = InputReader(FileInputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/in.txt\"))\n writer = OutputWriter(FileOutputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/out.txt\"))\n } else {\n reader = InputReader(System.`in`)\n writer = OutputWriter(System.`out`)\n }\n }\n\n private fun readMultipleInts(count: Int): List {\n val map = mutableListOf()\n repeat(count) {\n map.add(reader.readInt())\n }\n return map\n }\n\n fun readInt() = reader.readInt()\n fun readLong() = reader.readLong()\n fun readTwoInts() = readMultipleInts(2)\n fun readThreeInts() = readMultipleInts(3)\n fun readFourInts() = readMultipleInts(4)\n fun readFiveInts() = readMultipleInts(5)\n fun readSixInts() = readMultipleInts(6)\n fun readString() = reader.readString()\n fun readTree(n: Int): MutableMap> {\n val graph = mutableMapOf>()\n repeat(n - 1) {\n val u = reader.readInt()\n val v = reader.readInt()\n if (!graph.containsKey(u)) graph[u] = mutableListOf()\n if (!graph.containsKey(v)) graph[v] = mutableListOf()\n graph[u]!!.add(v)\n graph[v]!!.add(u)\n }\n return graph\n }\n\n fun readIntArray(n: Int): IntArray {\n return IntArray(n) { readInt() }\n }\n\n fun readLongArray(n: Int): Array {\n return Array(n) { readLong() }\n }\n\n fun write(obj: Any) {\n writer.printLine(obj)\n }\n\n fun flushOutput() {\n writer.flush()\n }\n\n fun closeOutput() {\n writer.close()\n }\n }\n}\n\n\nclass MATH {\n companion object {\n\n val mod = 998244353\n var ispre = false\n\n val factMod = Array(300002) { 1 }\n\n fun pre() {\n for (i in 2 until 300001) {\n factMod[i] = ((factMod[i - 1] * i.toLong()) % MATH.mod).toInt()\n }\n }\n\n fun gcd(a: Int, b: Int): Int {\n if (b == 0)\n return a\n return gcd(b, a % b)\n }\n\n fun gcd(a: Long, b: Long): Long {\n if (b == 0L)\n return a\n return gcd(b, a % b)\n }\n\n fun inverseMod(a: Int): Int {\n return powMod(a, mod - 2)\n }\n\n fun powMod(a: Int, b: Int): Int {\n //calculate a to the power b mod m\n if (b == 0) return 1\n return if (b % 2 == 1) {\n prodMod(a, powMod(a, b - 1))\n } else {\n val p = powMod(a, b / 2)\n prodMod(p, p)\n }\n }\n\n fun ncr(n: Int, r: Int): Int {\n if (!ispre) pre(); ispre = true\n return ((factMod[n].toLong() * inverseMod(((factMod[r].toLong() * factMod[n - r]) % mod).toInt())) % mod).toInt()\n }\n\n fun prodMod(val1: Int, val2: Int): Int {\n return ((val1.toLong() * val2) % mod).toInt()\n }\n\n }\n}\n\nfun solve() {\n\n\n val l = IO.readLong()\n val r = IO.readLong()\n val binl = get64BitBinaryString(l)\n val binr = get64BitBinaryString(r)\n var res = java.lang.StringBuilder()\n var found = false\n for (i in 0 until 64){\n //start from the msb\n if (found){\n res.append('1')\n continue\n }\n if ((binl[i] == '0' && binr[i] == '0' ) || ( binl[i] == '1' && binr[i] == '1')) {\n //just skip\n res.append('0')\n }else{\n //just append all ones\n res.append('1')\n found = true\n }\n }\n val ansString = res.toString()\n var ans = 0L\n var mul = 1L\n for (i in 63 downTo 0){\n if (ansString[i] == '1'){\n ans+= mul\n }\n mul *= 2\n }\n IO.write(ans)\n IO.flushOutput()\n IO.closeOutput()\n}\n\nfun get64BitBinaryString(numm : Long) : String {\n val builder = StringBuilder()\n var num = numm\n while (num != 0L){\n if (num%2 == 0L){\n builder.append('0')\n }else{\n builder.append('1')\n }\n num/=2\n }\n while (builder.length != 64){\n builder.append('0')\n }\n return builder.toString().reversed()\n}\n\nclass Primes {\n\n val primes = mutableListOf()\n\n init {\n sieve()\n }\n\n fun sieve() {\n val composite = IntArray(100001) { 0 }\n for (i in 2 until 100001){\n if (composite[i] == 0){\n //means i is prime\n primes.add(i)\n var cur = 1\n while (i*cur <= 100000){\n composite[i*cur] = 1\n cur++\n }\n }\n }\n }\n\n fun factorize(num: Int): Map {\n //using these primes factorize\n val factors = mutableMapOf()\n var n =num\n primes.forEach {\n var power = 0\n while (n%it == 0){\n n /= it\n power++\n }\n if (power != 0){\n factors[it] = power\n }\n }\n if (n != 1){\n factors[n] = 1\n }\n return factors\n }\n\n}\n\n\nfun isBitSet(num : Int, i : Int) : Boolean{\n return (num.and(1.shl(i)) > 0)\n}\n\nfun power(i : Int, j : Int) : Int{\n if (j == 0) return 1\n return i*power(i, j - 1)\n}\n\ndata class Graph(val edges: MutableMap>)\n\n\nclass MinSegmentTree(\n input: Array\n) {\n private val tree: Array\n private val lazy: Array\n\n constructor(size: Int) : this(Array(size) { Int.MAX_VALUE })\n\n init {\n val size = nextPowerOfTwo(input.size)\n tree = Array(2 * size) { Int.MAX_VALUE }\n lazy = Array(2 * size) { Int.MAX_VALUE }\n for (i in 0 until input.size) {\n tree[i + size] = input[i]\n }\n for (i in (size - 1) downTo 1) {\n tree[i] = Math.min(tree[leftChild(i)], tree[rightChild(i)])\n }\n }\n\n private fun updateTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int, value: Int) {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) updateLazyNode(index, lowerBound, upperBound, value)\n else {\n updateTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index), value)\n updateTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index), value)\n tree[index] = Math.min(tree[leftChild(index)], tree[rightChild(index)])\n }\n }\n\n private fun queryTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int): Int {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return Int.MAX_VALUE\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) return tree[index]\n else {\n return Math.min(queryTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index)),\n queryTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index)))\n }\n }\n\n private fun updateLazyNode(index: Int, lowerBound: Int, upperBound: Int, delta: Int) {\n tree[index] += delta\n if (lowerBound != upperBound) {\n lazy[leftChild(index)] += delta\n lazy[rightChild(index)] += delta\n }\n lazy[index] = 0\n }\n\n fun getElements(N: Int): List {\n return tree.copyOfRange(tree.size / 2, tree.size / 2 + N).asList()\n }\n\n fun update(lowerRange: Int, upperRange: Int, value: Int) {\n updateTree(lowerRange, upperRange, 1, lazy.size / 2, 1, value)\n }\n\n fun query(lowerRange: Int, upperRange: Int): Int {\n return queryTree(lowerRange, upperRange, 1, lazy.size / 2, 1)\n }\n\n private fun noOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb > u || ub < l)\n\n private fun completeOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb >= l && ub <= u)\n\n\n private fun nextPowerOfTwo(num: Int): Int {\n var exponent = 2\n while (true) {\n if (exponent >= num) {\n return exponent\n }\n exponent *= 2\n }\n }\n\n private fun midIndex(l: Int, r: Int) = (l + r) / 2\n private fun parent(i: Int) = i / 2\n private fun leftChild(i: Int) = 2 * i\n private fun rightChild(i: Int) = 2 * i + 1\n\n}\n\nclass InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var sgn: Long = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var number: Long = 0\n do {\n number *= 10L\n number += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return number * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n}\n\nclass OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n\n fun flush() {\n writer.flush()\n }\n\n}\n\nclass DinitzMaxFlowSolver(val n: Int, val s: Int, val t: Int, val graph: MutableMap>, val edgeMap: MutableMap, Edge>) {\n\n private val level = IntArray(n + 1) { -1 } //storing levels of each vertex in level graph\n var maxFlow = 0L\n\n init {\n solve()\n }\n\n fun solve() {\n val next = IntArray(n + 1) { 0 }\n while (bfs()) {\n Arrays.fill(next, 0)\n var flow = 0L\n do {\n maxFlow += flow\n flow = dfs(s, next, Long.MAX_VALUE)\n } while (flow != 0L)\n }\n }\n\n private fun dfs(at: Int, next: IntArray, flow: Long): Long {\n if (at == t) return flow\n var size = 0\n if (graph.containsKey(at)) size = graph[at]!!.size\n while (next[at] < size) {\n val edge = graph[at]!!.get(next[at])\n if (edge.remainingCapacity() > 0 && level[edge.to] == level[at] + 1) {\n val bottleNeck = dfs(edge.to, next, Math.min(flow, edge.remainingCapacity()))\n if (bottleNeck > 0) {\n edgeMap[Pair(edge.from, edge.to)]!!.flow += bottleNeck\n edgeMap[Pair(edge.to, edge.from)]!!.flow -= bottleNeck\n return bottleNeck\n }\n }\n next[at]++\n }\n return 0\n }\n\n private fun bfs(): Boolean {\n Arrays.fill(level, -1)\n val curLevel = ArrayDeque()\n curLevel.add(s)\n level[s] = 0\n\n while (curLevel.isNotEmpty()) {\n val top = curLevel.poll()\n if (graph.containsKey(top)) {\n graph[top]!!.forEach {\n if (it.remainingCapacity() > 0 && level[it.to] == -1) {\n level[it.to] = level[top] + 1\n curLevel.offer(it.to)\n }\n }\n }\n }\n return level[t] != -1\n }\n\n\n}\n\nclass Edge(val from: Int, val to: Int, val capacity: Long) {\n var flow = 0L\n fun remainingCapacity(): Long {\n return capacity - flow\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bf5a60c3b40220065a0ee0d95ff47db6", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nobject Main {\n var `in`: IO? = null\n var out: PrintWriter? = null\n\n @Throws(Exception::class)\n fun init_io(filename: String) {\n if (filename == \"\") {\n `in` = IO(System.`in`)\n out = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)), true)\n } else {\n `in` = IO(FileInputStream(\"$filename.in\"))\n out = PrintWriter(BufferedWriter(FileWriter(\"$filename.out\")), true)\n }\n }\n\n const val mod: Long = 998244353\n\n /*\nfun main(args: Array) {\n Main.main(args);\n}\n*/\n operator fun get(l: Long, r: Long): Long {\n if (l == r) return 0\n var x: Long = 1\n while (x * 2 <= r) x *= 2\n return if (l < x) x * 2 - 1 else get(l - x, r - x)\n }\n\n @Throws(Exception::class)\n fun solve(tc: Int) {\n val l = `in`!!.nlong()\n val r = `in`!!.nlong()\n out!!.println(get(l, r))\n }\n\n @Throws(Exception::class)\n @JvmStatic\n fun main(_u_n_u_s_e_d_: Array) {\n init_io(\"\")\n val t = 1\n // t = in.nint();\n for (tc in 0 until t) {\n solve(tc)\n }\n }\n\n fun minv(v: Long): Long {\n return mpow(v, mod - 2)\n }\n\n fun mpow(base: Long, exp: Long): Long {\n var base = base\n var exp = exp\n var res: Long = 1\n while (exp > 0) {\n if (exp and 1 == 1L) {\n res = res * base % mod\n }\n base = base * base % mod\n exp = exp shr 1\n }\n return res\n }\n\n fun gcd(x: Long, y: Long): Long {\n return if (x == 0L) y else gcd(y % x, x)\n }\n\n fun rsort(arr: LongArray) {\n val r = Random()\n for (i in arr.indices) {\n val j = i + r.nextInt(arr.size - i)\n val t = arr[i]\n arr[i] = arr[j]\n arr[j] = t\n }\n Arrays.sort(arr)\n }\n\n fun rsort(arr: IntArray) {\n val r = Random()\n for (i in arr.indices) {\n val j = i + r.nextInt(arr.size - i)\n val t = arr[i]\n arr[i] = arr[j]\n arr[j] = t\n }\n Arrays.sort(arr)\n }\n\n /* static void qsort(long[] arr) {\n Long[] oarr = new Long[arr.length];\n for (int i = 0; i < arr.length; i++) {\n oarr[i] = arr[i];\n }\n\n ArrayList alist = new ArrayList(Arrays.asList(oarr));\n Collections.sort(alist);\n\n for (int i = 0; i < arr.length; i++) {\n arr[i] = (long)alist.get(i);\n }\n } */\n fun reverse(arr: LongArray) {\n for (i in 0 until arr.size / 2) {\n val temp = arr[i]\n arr[i] = arr[arr.size - 1 - i]\n arr[arr.size - 1 - i] = temp\n }\n }\n\n fun atos(arr: LongArray?): String {\n var s = Arrays.toString(arr)\n s = s.substring(1, s.length - 1)\n return s.replace(\",\", \"\")\n }\n\n class IO(x: InputStream?) {\n var `in`: BufferedReader\n var tokens: StringTokenizer\n\n @Throws(Exception::class)\n fun nint(): Int {\n return nstr().toInt()\n }\n\n @Throws(Exception::class)\n fun nlong(): Long {\n return nstr().toLong()\n }\n\n @Throws(Exception::class)\n fun ndouble(): Double {\n return nstr().toDouble()\n }\n\n @Throws(Exception::class)\n fun nstr(): String {\n if (!tokens.hasMoreTokens()) tokens = StringTokenizer(`in`.readLine())\n return tokens.nextToken()\n }\n\n @Throws(Exception::class)\n fun nla(n: Int): LongArray {\n val arr = LongArray(n)\n for (i in 0 until n) {\n arr[i] = nlong()\n }\n return arr\n }\n\n init {\n `in` = BufferedReader(InputStreamReader(x))\n tokens = StringTokenizer(`in`.readLine())\n }\n }\n\n internal class Pair?, B : Comparable?>(var f: A, var s: B) : Comparable> {\n override fun compareTo(other: Pair): Int {\n val v = f!!.compareTo(other.f)\n return if (v != 0) v else s!!.compareTo(other.s)\n }\n\n override fun toString(): String {\n return \"(\" + f.toString() + \", \" + s.toString() + \")\"\n }\n\n }\n}\n\nfun main(args: Array) {\n Main.main(args);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2014f43cb6a5a5a6858ac2eb9bb13abd", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(){\n val scanner = Scanner(System.`in`)\n val l = scanner.nextLong().toString(2)\n val r = scanner.nextLong().toString(2)\n\n val diff = r.length - l.length\n var max = StringBuilder(\"\")\n var flag = false\n//797162752288318119 908416915938410706\n if(diff > 0){\n for(i in 1..diff)\n max.append(\"1\")\n flag = true\n }\n\n for(i in l.indices){\n if(flag){\n for(j in i + 1..l.length)\n max.append(\"1\")\n break\n }\n if(l[i] != r[i + diff]){\n if(l[i] == '1')\n continue\n max = StringBuilder(\"1\")\n flag = true\n }\n }\n if(!flag){\n max = StringBuilder(\"0\")\n }\n print(max.toString().toLong(2))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fc4883590ec7b44ec8114e922a621235", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(){\n val scanner = Scanner(System.`in`)\n val l = scanner.nextLong().toString(2)\n val r = scanner.nextLong().toString(2)\n\n val diff = r.length - l.length\n var max = StringBuilder(\"\")\n var flag = false\n\n if(diff > 0){\n for(i in 1..diff)\n max.append(\"1\")\n flag = true\n }\n\n for(i in l.indices){\n if(flag){\n for(j in 1..l.length)\n max.append(\"1\")\n break\n }\n if(l[i] != r[i + diff]){\n max = StringBuilder(\"1\")\n flag = true\n }\n }\n if(!flag){\n max = StringBuilder(\"0\")\n }\n print(max.toString().toInt(2))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "78b879ef59b12c2f0e043f20db9ed05a", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(){\n val scanner = Scanner(System.`in`)\n val l = scanner.nextLong().toString(2)\n val r = scanner.nextLong().toString(2)\n\n val diff = r.length - l.length\n var max = StringBuilder(\"\")\n var flag = false\n\n if(diff > 0){\n for(i in 1..diff)\n max.append(\"1\")\n flag = true\n }\n\n for(i in l.indices){\n if(flag){\n for(j in 1..l.length)\n max.append(\"1\")\n break\n }\n if(l[i] != r[i + diff]){\n max = StringBuilder(\"1\")\n flag = true\n }\n }\n if(!flag){\n max = StringBuilder(\"0\")\n }\n print(max.toString().toLong(2))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d02c072599ca93d45f4c06da97556b62", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin 1.6", "source_code": "import java.util.*\n\nfun main() {\n val sc = Scanner(System.`in`)\n // var numberTest: Int = sc.nextInt()\n // while (numberTest-- != 0) {\n val n = sc.nextInt()\n when (n) {\n 1 -> println(3)\n 2 -> println(5)\n 3 -> println(7)\n else -> {\n if (n % 3 == 1) {\n println((n / 3 + 2) * (n / 3 + 2) - (n / 3) * (n / 3))\n }\n if (n % 3 == 0) {\n var a = n / 3\n var b = a + 2\n b = a + b\n a = b - 1\n println(b * b - a * a)\n }\n if (n % 3 == 2) {\n var a = n / 3\n var b = a + 2\n a = a + b\n b = a + 1\n println(b * b - a * a)\n }\n }\n }\n}\n\n/*\n 1,2-> 3\n 2,3-> 5\n 3,4-> 7\n\n 1,3 = 4 -> 8 %3=1\n\n 4,5-> 9 %3=2\n 5,6-> 11 %3=0\n\n 2,4=6-> 12\n\n 6,7-> 13\n 7,8-> 15\n\n 3,5-> 16\n\n 8,9-> 17\n 9,10-> 19\n\n 4,6 = 10 -> 20\n\n 10,11-> 21\n 11,12-> 23\n\n 5,7-> 24\n*/\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fbaec2b975090a1d93d0387cd534f4de", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numStones = readInts()\n var bestSol = 0L\n for (hole in 0 until 14) {\n val initialStonesInHole = numStones[hole]\n val stonesEach = initialStonesInHole / 14\n val extraStones = initialStonesInHole % 14\n var sol = 0L\n for (otherHole in hole + 1..hole + extraStones) {\n val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach + 1\n if (stonesInHole and 1 == 0L) sol += stonesInHole\n }\n for (otherHole in hole + extraStones..hole + 13) {\n val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach\n if (stonesInHole and 1 == 0L) sol += stonesInHole\n }\n if (stonesEach and 1 == 0) sol += stonesEach\n if (sol > bestSol) bestSol = sol\n }\n print(bestSol)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0f17b835506b94c878c05753fd863d07", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val a = System.`in`.reader().readText().trim().split(' ').map(String::toLong)\n println(a.mapIndexed { i, l ->\n a.mapIndexed { j, m ->\n if (i == j) m / 14\n else m + (l + (i - j + 14).rem(14)) / 14\n }.filter { it.rem(2) == 0L }.sum()\n }.max())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4f99b15dac094588e1db77703bf59223", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numStones = readInts()\n var bestSol = 0L\n for (hole in 0 until 14) {\n val initialStonesInHole = numStones[hole]\n val stonesEach = initialStonesInHole / 14\n val extraStones = initialStonesInHole % 14\n var sol = 0L\n for (otherHole in hole + 1..hole + extraStones) {\n val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach + 1\n if (stonesInHole and 1 == 0L) sol += stonesInHole\n }\n for (otherHole in hole + extraStones + 1..hole + 13) {\n val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach\n if (stonesInHole and 1 == 0L) sol += stonesInHole\n }\n if (stonesEach and 1 == 0) sol += stonesEach\n if (sol > bestSol) bestSol = sol\n }\n print(bestSol)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "20a5980cce8c7cdcc4b7af5dc2da2c1e", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!\n val nLong = n.toLong()\n\n fun recursion(sb: StringBuilder, fours: Int, sevens: Int): String? {\n if (fours == 0 && sevens == 0) {\n return if (sb.toString().toLong() >= nLong) sb.toString()\n else null\n } else {\n if (fours > 0) {\n sb.append('4')\n val option1 = recursion(sb, fours - 1, sevens)\n if (option1 != null) return option1\n sb.deleteCharAt(sb.lastIndex)\n }\n if (sevens > 0) {\n sb.append('7')\n val option2 = recursion(sb, fours, sevens - 1)\n if (option2 != null) return option2\n sb.deleteCharAt(sb.lastIndex)\n return null\n }\n return null\n }\n }\n\n for (length in n.length .. n.length + 2) {\n if (length % 2 == 1) continue\n val sb = StringBuilder()\n val sol = recursion(sb, length / 2, length / 2)\n if (sol != null) return print(sol)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dcede6e8835a16617c4d4e23219ecbc7", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!\n val nInt = n.toInt()\n// val occsEach = (n.length + 1) / 2\n// if (n.length % 2 == 1) {\n// val sb = StringBuilder()\n// repeat(occsEach) { sb.append('4') }\n// repeat(occsEach) { sb.append('7') }\n// return print(sb.toString())\n// }\n// val big = n.map { it >= '7' }.reduce { a, b -> a and b } // all digits 7 or bigger\n// if (big) {\n// val sb = StringBuilder()\n// repeat(occsEach + 1) { sb.append('4') }\n// repeat(occsEach + 1) { sb.append('7') }\n// return print(sb.toString())\n// }\n//\n fun recursion(sb: StringBuilder, fours: Int, sevens: Int): String? {\n if (fours == 0 && sevens == 0) {\n if (sb.toString().toInt() >= nInt) return sb.toString()\n else return null\n } else {\n if (fours > 0) {\n sb.append('4')\n val option1 = recursion(sb, fours - 1, sevens)\n if (option1 != null) return option1\n sb.deleteCharAt(sb.lastIndex)\n }\n if (sevens > 0) {\n sb.append('7')\n val option2 = recursion(sb, fours, sevens - 1)\n if (option2 != null) return option2\n sb.deleteCharAt(sb.lastIndex)\n return null\n }\n return null\n }\n }\n\n for (length in n.length .. n.length + 2) {\n if (length % 2 == 1) continue\n val sb = StringBuilder()\n val sol = recursion(sb, length / 2, length / 2)\n if (sol != null) return print(sol)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "23c8d23f2d71bb94ccb62366ebb1f45f", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, k) = readLine()!!.split(' ').map { it.toInt() }\n\n var str = readLine()!!\n var g = str.indexOf('G')\n var t = str.indexOf('T')\n\n var min = minOf(g, t) + k\n var max = maxOf(g, t)\n\n if (min > max) {\n println(\"NO\")\n return\n }\n\n while (min <= max) {\n if (str[min] == '#') {\n println(\"NO\")\n return\n }\n if (str[min] == 'T' || str[min] == 'G'){\n println(\"YES\")\n return\n }\n min += k\n\n }\n println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ca95ddb8f027f6a24d558b01c12a035c", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun DataReader.solve(out: PrintWriter) {\n val n = nextInt()\n val k = nextInt()\n\n val s = nextToken()\n\n val used = BooleanArray(n)\n\n fun dfs(u: Int): Boolean {\n if (u < 0 || u >= n || used[u] || s[u] == '#') return false\n if (s[u] == 'T') return true\n used[u] = true\n\n return dfs(u - k) || dfs(u + k)\n }\n\n out.println(dfs(s.indexOf('G')).toYesNo())\n}\n\nfun Boolean.toYesNo() = if (this) \"YES\" else \"NO\"\n\nclass DataReader(private val reader: BufferedReader) {\n var st : StringTokenizer? = null\n companion object {\n fun createFromFile(name: String) = DataReader(BufferedReader(FileReader(name)))\n }\n\n fun next() : String? {\n while (st == null || !st!!.hasMoreTokens()) {\n val s = reader.readLine() ?: return null\n st = StringTokenizer(s)\n }\n\n return st?.nextToken()\n }\n\n fun nextToken() = next()!!\n\n fun nextInt() = nextToken().toInt()\n fun nextLong() = nextToken().toLong()\n fun readIntArray(n: Int) : IntArray {\n val result = IntArray(n)\n result.indices.forEach { i -> result[i] = nextInt() }\n return result\n }\n\n fun nextLine() = reader.readLine()\n}\n\nfun main(args: Array) {\n val r: Reader\n val out: PrintWriter\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n r = FileReader(\"input.txt\")\n out = PrintWriter(\"output.txt\")\n } else {\n r = InputStreamReader(System.`in`)\n out = PrintWriter(System.out)\n }\n\n DataReader(BufferedReader(r)).solve(out)\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "36fe0814dd4bb9a0c24014800c0be9ff", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val s = readLine()!!\n var f = false\n var pos = 0\n for (i in 0 until s.length) {\n if (s[i] in setOf('T','G')) {\n if (f) {\n pos = (pos + 1) % k\n if (pos == 0) println(\"YES\")\n else println(\"NO\")\n return\n } else f = true\n } else if (f) {\n pos = (pos + 1) % k\n if ((pos == 0) && (s[i] != '.')) {\n println(\"NO\")\n return\n }\n }\n }\n println(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b6b567c5d5dd1f055d55bbcbf314b22d", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, jumpLength) = readInts()\n val s = readLine()!!\n var grasshopper = s.indexOfFirst { it == 'G' }\n var target = s.indexOfFirst { it == 'T' }\n if (target < grasshopper) {\n val temp = grasshopper\n grasshopper = target\n target = temp\n }\n while (grasshopper < target) {\n if (s[grasshopper] == '#')\n return print(\"NO\")\n grasshopper += jumpLength\n }\n print(if (grasshopper == target) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0578b3465673a14688866066129bb949", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.File\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val onlineJudge = System.getProperty(\"ONLINE_JUDGE\") == \"true\"\n val input = if (onlineJudge) System.`in`.bufferedReader() else File(\"input.txt\").bufferedReader()\n val output = if (onlineJudge) PrintWriter(System.out.writer(), true) else PrintWriter(File(\"output.txt\"))\n\n solve(input, output)\n\n output.flush()\n output.close()\n}\n\nprivate fun String.words() = split(\" \")\n\nprivate fun String.toInts() = split(\" \").map { it.toInt() }\nprivate fun String.toLongs() = split(\" \").map { it.toLong() }\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val (n, k) = input.readLine().toInts()\n val line = input.readLine()\n val indexOfG = line.indexOf(\"G\")\n val indexOfT = line.indexOf(\"T\")\n val rem = indexOfG % k\n val path = line\n .replaceRange(0..Math.min(indexOfG, indexOfT) - 1, String(CharArray(Math.min(indexOfG, indexOfT)) { '.' }))\n .replaceRange(Math.max(indexOfG, indexOfT) + 1, line.lastIndex + 1, String(CharArray(Math.min(indexOfG, indexOfT)) { '.' }))\n .filterIndexed { index, c -> index % k == rem }\n if (path.contains(\"G\") && path.contains(\"T\") && !path.contains(\"#\")) {\n output.println(\"YES\")\n } else {\n output.println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1a34de8c06aa2d7fb54b8c3eb86f2ed9", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.math.*\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\nfun main(args: Array){\n\topen class A(a: Int, b: Int) {\n\t\tpublic open var i: Int = a;\n\t\tpublic open var r: Int = b;\n\t}\n\tvar inp = readInts();\n\tvar n = inp[0];\n\tvar k = inp[1];\n\tvar s = readLn();\n\tvar j = 0;\n\tvar t = 0;\n\tfor(i in s.indices){\n\t\tif(s[i] == 'G'){\n\t\t\tj = i;\n\t\t}\n\t\tif(s[i] == 'T'){\n\t\t\tt = i;\n\t\t}\n\t}\n\tvar flag = false;\n\tfor(i in j..(s.length - 1) step k){\n\t\tif(s[i] == 'T'){\n\t\t\tflag = true;\n\t\t\tbreak;\n\t\t}\n\t\tif(s[i] == '#') break;\n\t}\n\tfor(i in t..(s.length - 1) step k){\n\t\tif(s[i] == 'G'){\n\t\t\tflag = true;\n\t\t\tbreak;\n\t\t}\n\t\tif(s[i] == '#') break;\n\t}\n\tif(flag){\n\t\tprintln(\"YES\");\n\t}else{\n\t\tprintln(\"NO\");\n\t}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce1a65471d622f323adca4bf1b272029", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val n = readInt()\n if (n and 1 == 0) return print(\"No\")\n val arr = readInts()\n print(if (arr.first() and 1 == 1 && arr.last() and 1 == 1) \"Yes\" else \"No\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e163929f2cd8605700c5fc280b3497d3", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toInt()\n var list = readLine()!!.split(' ').map { it.toInt() }\n if (list.size % 2 == 1 && list[0] % 2 == 1 && list[n - 1] % 2 == 1) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5d95f28efd598e9a0769ec2f96f93ca3", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.FileReader\nimport java.io.InputStreamReader\n\nval ONLINE = System.getProperty(\"ONLINE_JUDGE\") != null\nval inp = BufferedReader(if (ONLINE) InputStreamReader(System.`in`) else FileReader(\"in.txt\"))\n\ninline fun readTokens() = inp.readLine()!!.split(' ')\ninline fun readInts() = readTokens().map { it.toInt() }\ninline fun readInt() = inp.readLine()!!.toInt()\ninline fun readLine() = inp.readLine()!!\n\nfun main(args: Array) {\n val n=readInt()\n val a=readInts().toIntArray()\n if((a[0]%2==1)&&(a[n-1]%2==1)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94cf08d37ec57bd0ef12a981e6f5d9d9", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()\n val x = \"9\".repeat(n!!.length - 1)\n val y = (n.toBigInteger() - x.toBigInteger()).toString()\n println(x.map {it -> it.toString().toInt()}.reduce {s, sum -> s + sum}\n + y.map {it -> it.toString().toInt()}.reduce {s, sum -> s + sum})\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "425da20d4033cec55c67e86829a9506d", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLong() = readLine()!!.toLong()\n\n val n = readLong()\n var a = 0L\n while (a * 10 + 9 <= n) a = a * 10 + 9\n var b = n - a\n var sol = 0L\n while (a > 0) {\n sol += a % 10\n a /= 10\n }\n while (b > 0) {\n sol += b % 10\n b /= 10\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b49cf33c0e41bc4a14a3cd1bbd175dad", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.log10\nfun ffff(d : Int):Long\n{\n var s = 0L\n var d2 = d\n while(d2>0){\n s += Math.pow(10.0,(d2-1L).toDouble()).toLong()*9\n d2--\n }\n return s\n}\nfun main(args: Array) {\n val n = readLine()!!.toLong()\n val bas = log10(n.toDouble()).toInt() + 1\n //println(bas)\n val s1 = ffff(bas-1)\n var s2 = n-s1\n var t = 0\n //println(s2)\n while (s2>0)\n {\n t+=(s2 % 10L).toInt()\n s2/=10L\n }\n t += 9*(bas-1)\n println(t)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "40968246b6118f126d9447f9c2c5fbe5", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.util.*\nimport kotlin.Comparator\n\nobject programkt {\n fun S(n0: Long): Long {\n var res = 0L\n var n = n0\n while (n > 0) {\n res += n % 10\n n = n / 10\n }\n return res\n }\n\n fun solveDumb(n: Long) =\n LongRange(0, n)\n .map { it -> Pair(S(it) + S(n - it), it) }\n .maxWith(\n object : Comparator> {\n override fun compare(o1: Pair, o2: Pair): Int {\n if (o1.first == o2.first)\n return o1.second.compareTo(o2.second)\n else\n return o1.first.compareTo(o2.first)\n }\n }\n )!!\n\n fun solve(n: Long): Long {\n if (n < 10)\n return n\n else {\n var n10 = 1L\n while (n10 * 10 <= n) {\n n10 *= 10\n }\n val a = n / n10 * n10 - 1\n val b = n - a\n return S(a) + S(b)\n }\n }\n\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n //val sc = Scanner(System.`in`)\n\n LongRange(0, 100).forEach {\n //println(\"$it \" + solveDumb(it))\n assert(solveDumb(it).first == solve(it))\n }\n\n println(solve(BigDecimal(readLine()).toLong()))\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "35e77640b69e3268275a0d5ac71e76e9", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()\n val x = if (n!!.length > 1) \"9\".repeat(n.length - 1) else \"0\"\n val y = (n.toBigInteger() - x.toBigInteger()).toString()\n println(x.map {it -> it.toString().toInt()}.reduce {s, sum -> s + sum}\n + y.map {it -> it.toString().toInt()}.reduce {s, sum -> s + sum})\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7f0fec827a99179d70a8ba669dbf04c8", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.util.*\nimport kotlin.Comparator\n\nobject programkt {\n fun S(n0: Long): Long {\n var res = 0L\n var n = n0\n while (n > 0) {\n res += n % 10\n n = n / 10\n }\n return res\n }\n\n fun solveDumb(n: Long) =\n LongRange(0, n)\n .map { it -> Pair(S(it) + S(n - it), it) }\n .maxWith(\n object : Comparator> {\n override fun compare(o1: Pair, o2: Pair): Int {\n if (o1.first == o2.first)\n return o1.second.compareTo(o2.second)\n else\n return o1.first.compareTo(o2.first)\n }\n }\n )!!\n\n fun solve(n: Long): Long {\n if (n < 10)\n return n\n else {\n val a = n - (n % 10) - 1\n val b = n - a\n return S(a) + S(b)\n }\n }\n\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n //val sc = Scanner(System.`in`)\n\n LongRange(0, 1000).forEach {\n //println(\"$it \" + solveDumb(it))\n assert(solveDumb(it).first == solve(it))\n }\n\n println(solve(BigDecimal(readLine()).toLong()))\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6d76b0ed336348a7314a41348e339dc6", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.util.*\nimport kotlin.Comparator\n\nobject programkt {\n fun S(n0: Long): Long {\n var res = 0L\n var n = n0\n while (n > 0) {\n res += n % 10\n n = n / 10\n }\n return res\n }\n\n fun solveDumb(n: Long) =\n LongRange(0, n)\n .map { it -> Pair(S(it) + S(n - it), it) }\n .maxWith(\n object : Comparator> {\n override fun compare(o1: Pair, o2: Pair): Int {\n if (o1.first == o2.first)\n return o1.second.compareTo(o2.second)\n else\n return o1.first.compareTo(o2.first)\n }\n }\n )!!\n\n fun solve(n: Long): Long {\n if (n < 10)\n return n\n else {\n var n10 = 1L\n while (n10 * 10 <= n) {\n n10 *= 10\n }\n val a = n / n10 * n10 - 1\n val b = n - a\n return S(a) + S(b)\n }\n }\n\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n //val sc = Scanner(System.`in`)\n\n LongRange(0, 100).forEach {\n println(\"$it \" + solveDumb(it))\n assert(solveDumb(it).first == solve(it))\n }\n\n println(solve(BigDecimal(readLine()).toLong()))\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0ee9903bdcdd206ad418b3e358bb6395", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.floor\n\nfun main() {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val q = LinkedList()\n for (j in 1..3) {\n q.add(x)\n }\n var answer = 0\n while (!q.all { it == y }) {\n answer++\n q.remove()\n q.add(maxOf(y, floor(q.last().toDouble() / 1.61803398875).toInt() + 1))\n }\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "73015a5132ae2e9f6495af5991a5ba28", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.min\n\nfun main() {\n val iin = BufferedReader(InputStreamReader(System.`in`))\n val (x, y) = iin.readLine()!!.split(\" \").map { it.toInt() }\n val q = LinkedList()\n for (i in 1..3) {\n q.add(y)\n }\n var ans = 0\n while (q[2] != x) {\n ans++\n q.addFirst(min(x, q[0] + q[1] - 1))\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b1088f627ec54c2c287a245ca6910c73", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(' ').map(String::toInt)\n var (a, b, c) = listOf(y, y, y)\n var ans = 0\n while (c < x) {\n c = b\n b = a\n a = b + c - 1\n ans++\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9eab7767b961809d4a8e640162c26a2b", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.InputStream\nimport java.lang.StringBuilder\nimport kotlin.math.min\n\ninternal class Parserdoubt(`in`: InputStream) {\n private val BUFFER_SIZE = 1 shl 17\n\n private val din: DataInputStream\n private val buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n init {\n din = DataInputStream(`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(Exception::class)\n fun nextString(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > ' '.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun wholeLine(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= '\\n'.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > '\\n'.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun nextChar(): Char {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n return c.toChar()\n }\n\n @Throws(Exception::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n private fun fillBuffer() {\n bufferPointer = 0\n bytesRead = din.read(buffer, 0, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n\n @Throws(Exception::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n}\n\ndata class E (\n val cnt:Int,\n val id: Int\n): Comparable {\n override fun compareTo(other: E): Int {\n return other.cnt - cnt\n }\n}\n\nfun main(args : Array) {\n val input = Parserdoubt(`in` = System.`in`)\n val NT = 1//input.nextInt()\n val sb = StringBuilder()\n for(test in 1..NT){\n val c = input.nextInt()\n val r = input.nextInt()\n val n = input.nextInt() - 1\n var ans = 0\n\n for(i in -5000 .. 5000 step 2){\n if(i<0){\n val start = -i\n val num = min(r - start, c)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 >= n)ans +=2\n }\n } else {\n val end = c - i\n val num = min(r, end)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 > n)ans +=2\n }\n }\n }\n println(ans)\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "389172d13f6be34924e15e4bf9e68b7f", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n,m)=readLine()!!.split(' ').take(2).map { it.toInt() }\n val x = readLine()!!.toInt().dec()\n val (r, c) = n - 2 * x to m - 2 * x\n val ans =\n if (r<0 || c<0)\n 0\n else\n ((r / 2) * ((c+1)/ 2)) + ((r - (r / 2)) * (if (c > 1) (c / 2) else 1))\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1531e74de54ee7b6545bdd64a03dd62b", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.InputStream\nimport java.lang.StringBuilder\nimport kotlin.math.min\n\ninternal class Parserdoubt(`in`: InputStream) {\n private val BUFFER_SIZE = 1 shl 17\n\n private val din: DataInputStream\n private val buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n init {\n din = DataInputStream(`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(Exception::class)\n fun nextString(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > ' '.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun wholeLine(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= '\\n'.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > '\\n'.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun nextChar(): Char {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n return c.toChar()\n }\n\n @Throws(Exception::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n private fun fillBuffer() {\n bufferPointer = 0\n bytesRead = din.read(buffer, 0, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n\n @Throws(Exception::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n}\n\ndata class E (\n val cnt:Int,\n val id: Int\n): Comparable {\n override fun compareTo(other: E): Int {\n return other.cnt - cnt\n }\n}\n\nfun main(args : Array) {\n val input = Parserdoubt(`in` = System.`in`)\n val NT = 1//input.nextInt()\n val sb = StringBuilder()\n for(test in 1..NT){\n val r = input.nextInt()\n val c = input.nextInt()\n val n = input.nextInt() - 1\n var ans = 0\n\n for(i in -5000 .. 5000 step 2){\n if(i<0){\n val start = -i\n val num = min(r - start, c)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 >= n)ans +=2\n }\n } else {\n val end = c - i\n val num = min(r, end)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 >= n)ans +=2\n }\n }\n }\n println(ans)\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bdd68816b4ec433d87626cfc0f12e25a", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.InputStream\nimport java.lang.StringBuilder\nimport kotlin.math.min\n\ninternal class Parserdoubt(`in`: InputStream) {\n private val BUFFER_SIZE = 1 shl 17\n\n private val din: DataInputStream\n private val buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n init {\n din = DataInputStream(`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(Exception::class)\n fun nextString(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > ' '.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun wholeLine(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= '\\n'.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > '\\n'.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun nextChar(): Char {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n return c.toChar()\n }\n\n @Throws(Exception::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n private fun fillBuffer() {\n bufferPointer = 0\n bytesRead = din.read(buffer, 0, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n\n @Throws(Exception::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n}\n\ndata class E (\n val cnt:Int,\n val id: Int\n): Comparable {\n override fun compareTo(other: E): Int {\n return other.cnt - cnt\n }\n}\n\nfun main(args : Array) {\n val input = Parserdoubt(`in` = System.`in`)\n val NT = 1//input.nextInt()\n val sb = StringBuilder()\n for(test in 1..NT){\n val c = input.nextInt()\n val r = input.nextInt()\n val n = input.nextInt() - 1\n var ans = 0\n\n for(i in -10 .. 10 step 2){\n if(i<0){\n val start = -i\n val num = min(r - start, c)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 >= n)ans +=2\n }\n } else {\n val end = c - i\n val num = min(r, end)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 > n)ans +=2\n }\n }\n }\n println(ans)\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a69acafe5f5e9901124f7fc4d4687689", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.InputStream\nimport java.lang.StringBuilder\nimport kotlin.math.min\n\ninternal class Parserdoubt(`in`: InputStream) {\n private val BUFFER_SIZE = 1 shl 17\n\n private val din: DataInputStream\n private val buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n init {\n din = DataInputStream(`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(Exception::class)\n fun nextString(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > ' '.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun wholeLine(): String {\n val sb = StringBuffer(\"\")\n var c = read()\n while (c <= '\\n'.toByte())\n c = read()\n do {\n sb.append(c.toChar())\n c = read()\n } while (c > '\\n'.toByte())\n return sb.toString()\n }\n\n @Throws(Exception::class)\n fun nextChar(): Char {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n return c.toChar()\n }\n\n @Throws(Exception::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c > ' '.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(Exception::class)\n private fun fillBuffer() {\n bufferPointer = 0\n bytesRead = din.read(buffer, 0, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n\n @Throws(Exception::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n}\n\ndata class E (\n val cnt:Int,\n val id: Int\n): Comparable {\n override fun compareTo(other: E): Int {\n return other.cnt - cnt\n }\n}\n\nfun main(args : Array) {\n val input = Parserdoubt(`in` = System.`in`)\n val NT = 1//input.nextInt()\n val sb = StringBuilder()\n for(test in 1..NT){\n val c = input.nextInt()\n val r = input.nextInt()\n val n = input.nextInt() - 1\n var ans = 0\n\n for(i in -5000 .. 5000 step 2){\n if(i<0){\n val start = -i\n val num = min(r - start, c)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 > n)ans +=2\n }\n } else {\n val end = c - i\n val num = min(r, end)\n if(num <= 0)continue\n if(num%2==1){\n if(num/2 == n)ans ++\n else if(num/2 > n)ans +=2\n }else {\n if(num/2 > n)ans +=2\n }\n }\n }\n println(ans)\n\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9b361597f9aa54f88fc9df7ea7fddb33", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (a, b, c, d) = readInts()\n val diff = max(3 * a / 10, a - a / 250 * c) - max(3 * b / 10, b - b / 250 * d)\n print(\n when {\n diff > 0 -> \"Misha\"\n diff == 0 -> \"Tie\"\n else -> \"Vasya\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1ccb59d50fc5a4b3931c922e5271c124", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.io.BufferedOutputStream\nimport java.io.OutputStreamWriter\nimport java.util.*\nimport kotlin.math.max\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n val output = OutputStreamWriter(BufferedOutputStream(System.out))\n\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val c = scanner.nextInt()\n val d = scanner.nextInt()\n\n val p1 = points(a, c)\n val p2 = points(b, d)\n\n when {\n p1 == p2 -> output.write(\"Tie\\n\")\n p1 > p2 -> output.write(\"Misha\\n\")\n else -> output.write(\"Vasya\\n\")\n }\n\n output.flush()\n output.close()\n scanner.close()\n}\n\nfun points(p: Int, t: Int) = max(3*p/10f, p - (p/250f * t))", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8581ed4a16a6aa76efab5900a559bafd", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.max\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val mishaP = sc.nextInt()\n val VasyaP = sc.nextInt()\n val mishaT = sc.nextInt()\n val vasyaT = sc.nextInt()\n val mishaPoints = getPoints(mishaP, mishaT)\n val vasyaPoints = getPoints(VasyaP, vasyaT)\n if (mishaPoints > vasyaPoints) {\n print(\"Misha\")\n } else if (mishaPoints == vasyaPoints) {\n print(\"Tie\")\n } else print(\"Vasya\")\n\n}\n\nfun getPoints(p: Int, t: Int) = max(p * 3 / 10f, p - p / 250f * t)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d870b7bdaf4dbe99d441565278fd25d6", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import com.sun.xml.internal.fastinfoset.util.StringArray\nimport kotlin.math.min\n\nfun main() {\n\n var (a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() }\n\n var max1 = Math.max(3*a/10,a-(a/250*c))\n var max2 = Math.max(3*b/10,b-(b/250*d))\n if (max1>max2){\n println(\"Misha\")\n }else if (max1bob -> \"Misha\"\n bob >alice -> \"Vasya\"\n else -> \"Tie\"\n })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a52bcfa969554d5039f2ed27af7f52d3", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedInputStream\nimport java.io.BufferedOutputStream\nimport java.io.OutputStreamWriter\nimport java.util.*\nimport kotlin.math.max\n\nfun main(args: Array) {\n val scanner = Scanner(BufferedInputStream(System.`in`))\n val output = OutputStreamWriter(BufferedOutputStream(System.out))\n\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val c = scanner.nextInt()\n val d = scanner.nextInt()\n\n val p1 = points(a, c)\n val p2 = points(b, d)\n\n when {\n p1 == p2 -> output.write(\"TIE\\n\")\n p1 > p2 -> output.write(\"Misha\\n\")\n else -> output.write(\"Vasya\\n\")\n }\n\n output.flush()\n output.close()\n scanner.close()\n}\n\nfun points(p: Int, t: Int) = max(3*p/10f, p - (p/250f * t))", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a947f2eabab34655689265f79032f7e0", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import com.sun.xml.internal.fastinfoset.util.StringArray\nimport kotlin.math.min\n\nfun main() {\n\n var (a, b, c, d) = readLine()!!.split(\" \").map { it.toInt() }\n\n var max1 = Math.max(3*a,a-(a/250*c))\n var max2 = Math.max(3*b,b-(b/250*d))\n if (max1>max2){\n println(\"Misha\")\n }else if (max1 a + b * 2})\n val half = customers\n .sum()\n\n val result = apples * p - half * p / 2\n writer.println(result)\n\n writer.close()\n }\n}\n\nfun main(args : Array) {\n A().solve(System.`in`, System.out)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "492fc65ce5ca8232917624f8e95de10c", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val n = ir.nextInt()\n val p = ir.nextInt()\n val s = arrayOfNulls(n)\n var total: Long = 0\n var res: Long = 0\n\n repeat(n) {\n s[it] = ir.next()\n }\n\n for (i in (n - 1) downTo 0) {\n total *= 2\n if (s[i] == \"halfplus\")\n total++\n res += (p * (total / 2.0)).toLong()\n }\n\n pw.print(res)\n\n}\n\n\n\nprivate fun sort(array: IntArray, barray: IntArray, low: Int, high: Int) {\n\n var i = low\n var j = high\n val x = array[low + (high - low) / 2]\n\n do {\n while (array[i] < x) ++i\n while (array[j] > x) --j\n if (i <= j) {\n val tmp = array[i]\n array[i] = array[j]\n array[j] = tmp\n\n val pmt = barray[i]\n barray[i] = barray[j]\n barray[j] = pmt\n\n i++\n j--\n }\n } while (i <= j)\n\n if (low < j) sort(array, barray, low, j)\n if (i < high) sort(array, barray, i, high)\n\n}\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "052a246a6a22843c83896d385924f1a5", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\n\nclass A {\n fun solve(input : InputStream, output : OutputStream) {\n val scanner = Scanner(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n val n = scanner.nextInt()\n val p = scanner.nextLong()\n\n val customers = (1..n)\n .map { scanner.next() }\n .map { if (it == \"halfplus\") 1 else 0 }\n .toCollection(ArrayList())\n\n val apples : Long = customers\n .foldRight(0L, { a: Int, b: Long -> a + b * 2})\n val half = customers\n .sum()\n\n val result = apples * p - half * p / 2\n writer.println(result)\n\n writer.close()\n }\n}\n\nfun main(args : Array) {\n A().solve(System.`in`, System.out)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "54dd8b8a02f727225a2c1c4d226c72a8", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n var str = readLine()!!\n var four = 0\n var seven = 0\n\n for (i in str){\n if (i=='4'){\n four++\n }else if (i=='7'){\n seven++\n }\n }\n if (four>seven){\n println(4)\n }else if (seven>four){\n println(7)\n }else if (seven==four && seven!=0){\n println(4)\n }else{\n println(-1)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e1f04d87e6bbe7deda1a210804784161", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val s = readLine()!!\n val numFours = s.count { it == '4' }\n val numSevens = s.count { it == '7' }\n print(\n when {\n numFours == 0 && numSevens == 0 -> -1\n numFours >= numSevens -> 4\n else -> 7\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9faa6d7824db96e9f64014b7a0fb6bf2", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (f, I, t) = readLine()!!.split(\" \").map { it.toInt() };\n val arr = Array(f) { CharArray(I) }\n for (i in 0 until f) {\n val nl = readLine()!!.toCharArray()\n for (j in 0 until I) {\n arr[i][j] = nl[j]\n }\n }\n var ans = 0\n for (i in 0 until I) {\n var count = 0\n for (j in 0 until f) {\n if (arr[j][i] == 'Y') {\n count++\n }\n }\n if (count >= t) {\n ans++\n }\n }\n println(ans)\n println(\"a kitten\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "16d9741108f992bdf24e933eedffa070", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (f, I, t) = readLine()!!.split(\" \").map { it.toInt() };\n val arr = Array(f) { CharArray(I) }\n for (i in 0 until f) {\n val nl = readLine()!!.toCharArray()\n for (j in 0 until I) {\n arr[i][j] = nl[j]\n }\n }\n var ans = 0\n for (i in 0 until I) {\n var count = 0\n for (j in 0 until f) {\n if (arr[j][i] == 'Y') {\n count++\n }\n }\n if (count >= t) {\n ans++\n }\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b08f9f3c20d03848cf095f164e08e509", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (f, I, t) = readLine()!!.split(\" \").map { it.toInt() };\n val arr = Array(f) { CharArray(I) }\n for (i in 0 until f) {\n val nl = readLine()!!.toCharArray()\n for (j in 0 until I) {\n arr[i][j] = nl[j]\n }\n }\n var ans = 0\n for (i in 0 until I) {\n var count = 0\n for (j in 0 until f) {\n if (arr[j][i] == 'Y') {\n count++\n }\n }\n if (count >= t) {\n ans++\n }\n }\n println(ans)\n System.err.println(\"kitten\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8b1951053526e6262f1fbdcced7a2462", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject YourAProfessional {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val f = sc.nextInt()\n val I = sc.nextInt()\n val t = sc.nextInt()\n sc.nextLine()\n val arr = Array(f) { CharArray(I) }\n for (i in 0 until f) {\n val nl = sc.nextLine().toCharArray()\n for (j in 0 until I) {\n arr[i][j] = nl[j]\n }\n }\n var ans = 0\n for (i in 0 until I) {\n var count = 0\n for (j in 0 until f) {\n if (arr[j][i] == 'Y') {\n count++\n }\n }\n if (count >= t) {\n ans++\n }\n }\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb2dac6e2f7fbfb59a2628bee515e062", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, s) = readInts()\n val a = readInts()\n print(if (a.sum() - a.max()!! <= s) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fe0e86db9ea3afe4f350d6c39a57e950", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun min(a:Double,b:Double) = if (ab) a else b \nfun min(a:Int,b:Int) = if (ab) a else b \nfun printD(d: Double) { print(d) }\nfun printI(d:Int) { print(d) }\nfun printS(d: String) { print(d) }\nfun printL(d: Long) { print(d) }\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readInts() = readLn().split(\" \").map{it.toInt()}\nfun readLong() = readLn().toLong()\nclass pair (var first:Int, var second:Int) \n \nfun solve() {\n val cin = Scanner(System.`in`)\n \n /* \n map[q] <=> map.getOrDefault(q,0) \n \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0430\u0440 - k=v.sortedWith(compareBy({it.first},{it.second})); \n print(\"${k[i].second}\"); - \u0432\u044b\u0432\u043e\u0434 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0430\u0440\u044b \n var m=ArrayList (); <=> vector \n getline(cin,a) <=> readLine()!!.last()\n \n readInt() - \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \n readInts() - \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b \n \n */ \n \n \n \n /* --------- */ \n \n var (a,b)=readInts();\n var q=readInts(); \n var sum=0; \n var max1=0; \n for (i in q) {\n max1=max(max1,i); sum+=i; }\n if (b>=sum-max1) print(\"YES\"); else print(\"NO\"); \n /* --------- */ \n \n}\n \n fun main() {\n val cin = Scanner(System.`in`)\n \n var T=1; \n //T=readLine()!!.toInt(); \n \n for (i55555 in 1..T) solve()\n}\n ", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c08584332005921ed42a6dc92b2f51b5", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.sqrt\n\nfun prime (n: Int): Boolean {\n if (n == 1 || n == 2 || n == 3) return true\n else {\n var isPrime = true\n var i = 2\n while (i <= sqrt(n.toFloat()).toInt() && isPrime) {\n if (n % i == 0) {\n isPrime = false\n } else {\n i++\n }\n }\n return isPrime\n }\n}\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, m) = br.readLine().split(\" \").map { it.toInt() }\n if (!prime(m)){\n println(\"NO\")\n } else {\n for (i in n + 1 .. m) {\n if (prime(i)){\n println(if (i == m) \"YES\" else \"NO\")\n break\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "017a5c40f40f32f6583776e5277df82f", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n val n = reader.nextInt()\n val m = reader.nextInt()\n for (i in n + 1..m) {\n if (prime(i)) {\n if (i == m)\n println(\"YES\")\n else println(\"NO\")\n return\n }\n if(i==m)\n println(\"NO\")\n }\n}\n\nfun prime(a: Int): Boolean {\n for (i in 2 until a) {\n if (a % i == 0) return false\n }\n return true\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e1ecddaa80da2c1ce88ffcab96ab90ec", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\n\n val (a, b) = readLine()!!.split(' ')\n var n = a.toInt()\n var m = b.toInt()\n var x = 0\n for(i in n+1..m){\n if(checkPrime(i)==1){\n x = i\n break\n }\n }\n\n if(x==m){\n println(\"YES\")\n }\n else{\n println(\"NO\")\n }\n}\n\nfun checkPrime(n: Int):Int{\n var a = 0\n for(i in 2..n/2) {\n if (n % i==0) {\n a++\n }\n }\n if(a==0) return 1\n else return 0\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1d371c8547eb934bbf04943536bac0f8", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n\n fun isPrime(int: Int):Boolean = !(2..int-1).fold(false){notPrime, i -> notPrime||(int%i==0)}\n //val n = r.readLine()!!.toInt()\n var (n, k) = r.readLine()!!.split(\" \").map { it.toInt() }\n var next = n+1\n while (!isPrime(next)){\n next++\n }\n println(if (next==k) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "44ab09feeefe2d47539e3b4f64ea4a41", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.sqrt\n\nfun prime (n: Int): Boolean {\n if (n == 1 || n == 2 || n == 3) return true\n else {\n var isPrime = true\n var i = 2\n while (i <= sqrt(n.toFloat()).toInt() && isPrime) {\n if (n % i == 0) {\n isPrime = false\n } else {\n i++\n }\n }\n return isPrime\n }\n}\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, m) = br.readLine().split(\" \").map { it.toInt() }\n println(if (prime(m)) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5cc84c6327c226ce5145daf83a56a0ee", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n val n = reader.nextInt()\n val m = reader.nextInt()\n for (i in n + 1..m) {\n if (prime(i)) {\n if (i == m)\n println(\"YES\")\n else println(\"NO\")\n return\n }\n }\n}\n\nfun prime(a: Int): Boolean {\n for (i in 2 until a) {\n if (a % i == 0) return false\n }\n return true\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3634e85a1a9c7473ce94561033ed88c2", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class House(var human: Int) {\n val neighbours = mutableListOf()\n}\n\nfun main() {\n val n = readLine()!!.toInt()\n val vertices = List(n) { House(it + 1) }\n repeat(n - 1) {\n val (u, v) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n vertices[u].neighbours.add(vertices[v])\n vertices[v].neighbours.add(vertices[u])\n }\n\n var answer = 0\n\n fun DFS(vertex: House, old: House): Boolean {\n if (vertex.neighbours.size == 1 && vertex != old) {\n val ch = vertex.human\n vertex.human = old.human\n old.human = ch\n answer++\n return true\n } else {\n var vym = false\n vertex.neighbours.forEach {\n if (it != old) {\n vym = vym or DFS(it, vertex)\n }\n }\n if (!vym) {\n val ch = vertex.human\n vertex.human = old.human\n old.human = ch\n answer++\n }\n return !vym\n }\n }\n\n DFS(vertices[0], vertices[0])\n if (vertices[0].human == 1) {\n val ch = vertices[0].human\n vertices[0].human = vertices[0].neighbours[0].human\n vertices[0].neighbours[0].human = ch\n }\n\n println(answer * 2)\n println(vertices.map { it.human }.joinToString(\" \"))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e26e6f547b0913ab236069d729cc23ca", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n val h = h(n)\n\n fun id(j: Int, k: Int, l: Int, m: Int) = j\n .times(h+1).plus(k)\n .times(3).plus(l)\n .times(3).plus(m)\n\n var D = ModIntArray(id(h, h, 2, 2)+1)\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(j, k, l, m)] = d\n }\n\n for(i in 2 until n) {\n val Di = ModIntArray(D.size)\n val hi = h(i)\n for(j in 0..hi) for(k in 0..min(hi, i-j)) for(l in 0..2) for(m in 0..2) {\n val d = D[id(j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n Di[id(jn, kn, m, p)] += dn\n }\n }\n D = Di\n }\n\n val S = Array(h+2) { ModIntArray(h+2) }\n\n for(j in 0..h) for(k in 0..h) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(j, k, l, m)]\n }\n\n fun S(a: Int, b: Int, c: Int, d: Int): ModInt {\n val a = min(h+1, a)\n val b = min(h+1, b)\n val c = min(h+1, c)\n val d = min(h+1, d)\n\n return S[c][d] - S[a][d] - S[c][b] + S[a][b]\n }\n\n var ans = S[h+1][h+1]\n\n for(i in 0 until 26) {\n ans -= S(C[i]+1, 0, n, n)\n for(j in i+1 until 26) {\n ans += S(C[i]+1, C[j]+1, n, n)\n }\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun h(n: Int) = n/4*2 + min(2, n%4)\nfun Boolean.toInt() = if(this) 1 else 0\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2b15142b7ccd417a8d3ad3e5d725b24d", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n val h = h(n)\n\n fun id(j: Int, k: Int, l: Int, m: Int) = j\n .times(h+1).plus(k)\n .times(3).plus(l)\n .times(3).plus(m)\n\n var D = ModIntArray(id(h, h, 2, 2)+1)\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(j, k, l, m)] = d\n }\n\n for(i in 2 until n) {\n val Di = ModIntArray(D.size)\n val hi = h(i)\n for(j in 0..hi) for(k in 0..min(hi, i-j)) for(l in 0..2) for(m in 0..2) {\n val d = D[id(j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n Di[id(jn, kn, m, p)] += dn\n }\n }\n D = Di\n }\n\n val S = Array(h+2) { ModIntArray(h+2) }\n\n for(j in 0..h) for(k in 0..h) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(j, k, l, m)]\n }\n\n fun S(a: Int, b: Int, c: Int, d: Int): ModInt {\n val a = min(h+1, a)\n val b = min(h+1, b)\n val c = min(h+1, c)\n val d = min(h+1, d)\n\n return S[c][d] - S[a][d] - S[c][b] + S[a][b]\n }\n\n var ans = S[h+1][h+1]\n\n for(i in 0 until 26) {\n ans -= S(C[i]+1, 0, n, n)\n for(j in i+1 until 26) {\n ans += S(C[i]+1, C[j]+1, n, n)\n }\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun h(n: Int) = n.shr(2).shl(1) + min(2, n and 3)\nfun Boolean.toInt() = if(this) 1 else 0\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "590dcd9e148571a17096d2f1e3f9cd48", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n val h = n/4*2 + min(2, n%4)\n\n fun id(j: Int, k: Int, l: Int, m: Int) = j\n .times(h+1).plus(k)\n .times(3).plus(l)\n .times(3).plus(m)\n\n var D = ModIntArray(id(h, h, 2, 2)+1)\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(j, k, l, m)] = d\n }\n\n for(i in 2 until n) {\n val Di = ModIntArray(D.size)\n for(j in 0..min(h,i)) for(k in 0..min(h, i-j)) for(l in 0..2) for(m in 0..2) {\n val d = D[id(j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n Di[id(jn, kn, m, p)] += dn\n }\n }\n D = Di\n }\n\n val S = Array(h+2) { ModIntArray(h+2) }\n\n for(j in 0..h) for(k in 0..h) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(j, k, l, m)]\n }\n\n fun S(a: Int, b: Int, c: Int, d: Int): ModInt {\n val a = min(h+1, a)\n val b = min(h+1, b)\n val c = min(h+1, c)\n val d = min(h+1, d)\n\n return S[c][d] - S[a][d] - S[c][b] + S[a][b]\n }\n\n var ans = S[h+1][h+1]\n\n for(i in 0 until 26) {\n ans -= S(C[i]+1, 0, n, n)\n for(j in i+1 until 26) {\n ans += S(C[i]+1, C[j]+1, n, n)\n }\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun Boolean.toInt() = if(this) 1 else 0\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dcbe22aab1d8946e529f43ab5906c1ff", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "import kotlin.math.min\r\n\r\nprivate fun readLn() = readLine()!!\r\nprivate fun readInt() = readLn().toInt()\r\nprivate fun readStrings() = readLn().split(\" \")\r\nprivate fun readInts() = readStrings().map { it.toInt() }\r\nprivate fun readLong() = readLn().toLong()\r\nprivate fun readLongs() = readStrings().map { it.toLong() }\r\n\r\nfun main() {\r\n val MOD = 998244353\r\n val n = readInt()\r\n val a = readInts()\r\n var result = 26L * 26;\r\n repeat(n - 2) { result = result * 25 % MOD }\r\n val m = (n + 2) / 2\r\n val dp = Array(2) { Array(m + 2) { Array(m + 2) { Array(3) { Array(3) { 0L } } } } }\r\n dp[0][0][0][0][0] = 1\r\n for (i in 0 until n) {\r\n val ci = i % 2\r\n val ni = 1 - ci\r\n for (c1 in 0..(i + 2) / 2)\r\n for (c2 in 0..min(i - c1, (i + 2) / 2))\r\n for (d1 in 0..2)\r\n for (d2 in 0..2)\r\n dp[ni][c1][c2][d1][d2] = 0\r\n for (c1 in 0..(i + 2) / 2)\r\n for (c2 in 0..min(i - c1, (i + 2) / 2))\r\n for (d1 in 0..2)\r\n for (d2 in 0..2)\r\n for (d3 in 0..2)\r\n if (d1 != d3 || d1 == 0) {\r\n val n1 = c1 + d3 % 2\r\n val n2 = c2 + if (d3 == 2) 1 else 0\r\n val mul = if (d3 > 0) 1 else if (d1 > 0 || i <= 1) 24 else 23\r\n dp[ni][n1][n2][d2][d3] = (dp[ni][n1][n2][d2][d3] + dp[ci][c1][c2][d1][d2] * mul) % MOD\r\n }\r\n }\r\n val d2 = dp[n % 2].map { it.map { it.sumOf { it.sum() % MOD } % MOD } }\r\n val d1 = d2.map { it.sum() % MOD }\r\n for (i in a)\r\n for (j in i + 1..m)\r\n result = (result + MOD - d1[j]) % MOD\r\n for (i in 0..25)\r\n for (j in 0 until i)\r\n for (c1 in a[i] + 1..m)\r\n for (c2 in a[j] + 1..m)\r\n result = (result + d2[c1][c2]) % MOD\r\n println(result)\r\n}\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "65a489cdea184cb8f6b7c0f108507865", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n val h = n/4*2+2\n\n fun id(j: Int, k: Int, l: Int, m: Int) = j\n .times(h+1).plus(k)\n .times(3).plus(l)\n .times(3).plus(m)\n\n var D = ModIntArray(id(h, h, 2, 2)+1)\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(j, k, l, m)] = d\n }\n\n for(i in 2 until n) {\n val Di = ModIntArray(D.size)\n for(j in 0..min(h,i)) for(k in 0..min(h, i-j)) for(l in 0..2) for(m in 0..2) {\n val d = D[id(j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n Di[id(jn, kn, m, p)] += dn\n }\n }\n D = Di\n }\n\n val S = Array(h+2) { ModIntArray(h+2) }\n\n for(j in 0..h) for(k in 0..h) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(j, k, l, m)]\n }\n\n fun S(a: Int, b: Int, c: Int, d: Int): ModInt {\n val a = min(h+1, a)\n val b = min(h+1, b)\n val c = min(h+1, c)\n val d = min(h+1, d)\n\n return S[c][d] - S[a][d] - S[c][b] + S[a][b]\n }\n\n val s = S[h+1][h+1]\n var ans = s\n\n for(i in 0 until 26) ans -= S(C[i]+1, 0, n, n)\n\n for(i in 0 until 25) for(j in i+1 until 26) {\n ans += S(C[i]+1, C[j]+1, n, n)\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun Boolean.toInt() = if(this) 1 else 0\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6f0e99c933d14b6c0a131b234b9ab703", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "const val MOD = 998244353L\n\nfun main() {\n val n = readLine()!!.toInt()\n val caps = readLine()!!.split(\" \").map { it.toInt() }\n var answer = 676L\n for (j in 3..n) {\n answer *= 25L\n answer %= MOD\n }\n val dp = Array(3) { Array(((n + 1) / 2) + 1) { LongArray(((n + 1) / 2) + 1) } }\n dp[0][0][0] = 1L\n for (a in 1..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n dp[1][a][b] = ((25L * (dp[0][a - 1][b] + dp[2][a - 1][b])) + (24L * (dp[1][a - 1][b]))) % MOD\n if (b > 0) {\n dp[2][a][b] = (dp[0][a - 1][b - 1] + dp[1][a - 1][b - 1]) % MOD\n }\n }\n }\n for (a in n / 2..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n dp[0][a][b] = (dp[1][a][b] + dp[2][a][b]) % MOD\n }\n }\n val mixed = LongArray(n + 1)\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n mixed[a + b] = (mixed[a + b] + (dp[0][n / 2][a] * dp[0][(n + 1) / 2][b])) % MOD\n }\n }\n for (a in n - 1 downTo 0) {\n mixed[a] = (mixed[a] + mixed[a + 1]) % MOD\n }\n val dp2 = Array(4) { Array(((n + 1) / 2) + 1) { Array(((n + 1) / 2) + 1) { LongArray(((n + 1) / 2) + 1) } } }\n dp2[0][0][0][0] = 1L\n for (a in 1..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n + 1) / 2) {\n dp2[1][a][b][c] = ((24L * (dp2[0][a - 1][b][c] + dp2[2][a - 1][b][c] + dp2[3][a - 1][b][c])) + (23L * (dp2[1][a - 1][b][c]))) % MOD\n if (b > 0) {\n dp2[2][a][b][c] = (dp2[0][a - 1][b - 1][c] + dp2[1][a - 1][b - 1][c] + dp2[3][a - 1][b - 1][c]) % MOD\n }\n if (c > 0) {\n dp2[3][a][b][c] = (dp2[0][a - 1][b][c - 1] + dp2[1][a - 1][b][c - 1] + dp2[2][a - 1][b][c - 1]) % MOD\n }\n }\n }\n }\n for (a in n / 2..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n + 1) / 2) {\n dp2[0][a][b][c] = (dp2[1][a][b][c] + dp2[2][a][b][c] + dp2[3][a][b][c]) % MOD\n }\n }\n }\n val mixed2 = Array(n + 1) { LongArray(n + 1) }\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n / 2) - a) {\n for (d in 0..((n + 1) / 2) - b) {\n mixed2[a + b][c + d] = (mixed2[a + b][c + d] + (dp2[0][n / 2][a][c] * dp2[0][(n + 1) / 2][b][d])) % MOD\n }\n }\n }\n }\n for (a in n downTo 0) {\n for (b in n downTo 0) {\n if (a < n) {\n mixed2[a][b] += mixed2[a + 1][b]\n }\n if (b < n) {\n mixed2[a][b] += mixed2[a][b + 1]\n }\n if (a < n && b < n) {\n mixed2[a][b] -= mixed2[a + 1][b + 1]\n }\n mixed2[a][b] %= MOD\n }\n }\n for (chara in 0..25) {\n if (caps[chara] < n) {\n answer -= mixed[caps[chara] + 1]\n answer %= MOD\n for (frisk in chara + 1..25) {\n if (caps[frisk] < n) {\n answer += mixed2[caps[chara] + 1][caps[frisk] + 1]\n answer %= MOD\n }\n }\n }\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7fe131de56a334f090f3f18900b2908f", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "const val MOD = 998244353L\n\nfun main() {\n val n = readLine()!!.toInt()\n val caps = readLine()!!.split(\" \").map { it.toInt() }\n var answer = 676L\n for (j in 3..n) {\n answer *= 25L\n answer %= MOD\n }\n val dp = Array(3) { Array(((n + 1) / 2) + 1) { LongArray(((n + 1) / 2) + 1) } }\n dp[0][0][0] = 1L\n for (a in 1..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n dp[1][a][b] = ((25L * (dp[0][a - 1][b] + dp[2][a - 1][b])) + (24L * (dp[1][a - 1][b]))) % MOD\n if (b > 0) {\n dp[2][a][b] = (dp[0][a - 1][b - 1] + dp[1][a - 1][b - 1]) % MOD\n }\n }\n }\n val mixed = LongArray(n + 1)\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n mixed[a + b] = (mixed[a + b] + ((dp[1][n / 2][a] + dp[2][n / 2][a]) * (dp[1][(n + 1) / 2][b] + dp[2][(n + 1) / 2][b]))) % MOD\n }\n }\n for (a in n - 1 downTo 0) {\n mixed[a] = (mixed[a] + mixed[a + 1]) % MOD\n }\n val dp2 = Array(4) { Array(((n + 1) / 2) + 1) { Array(((n + 1) / 2) + 1) { LongArray(((n + 1) / 2) + 1) } } }\n dp2[0][0][0][0] = 1L\n for (a in 1..(n + 1) / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n + 1) / 2) {\n dp2[1][a][b][c] = ((24L * (dp2[0][a - 1][b][c] + dp2[2][a - 1][b][c] + dp2[3][a - 1][b][c])) + (23L * (dp2[1][a - 1][b][c]))) % MOD\n if (b > 0) {\n dp2[2][a][b][c] = (dp2[0][a - 1][b - 1][c] + dp2[1][a - 1][b - 1][c] + dp2[3][a - 1][b - 1][c]) % MOD\n }\n if (c > 0) {\n dp2[3][a][b][c] = (dp2[0][a - 1][b][c - 1] + dp2[1][a - 1][b][c - 1] + dp2[2][a - 1][b][c - 1]) % MOD\n }\n }\n }\n }\n val mixed2 = Array(n + 1) { LongArray(n + 1) }\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n / 2) - a) {\n for (d in 0..((n + 1) / 2) - b) {\n mixed2[a + b][c + d] = (mixed2[a + b][c + d] + ((dp2[1][n / 2][a][c] + dp2[2][n / 2][a][c] + dp2[3][n / 2][a][c]) * (dp2[1][(n + 1) / 2][b][d] + dp2[2][(n + 1) / 2][b][d] + dp2[3][(n + 1) / 2][b][d]))) % MOD\n }\n }\n }\n }\n for (a in n downTo 0) {\n for (b in n downTo 0) {\n if (a < n) {\n mixed2[a][b] += mixed2[a + 1][b]\n }\n if (b < n) {\n mixed2[a][b] += mixed2[a][b + 1]\n }\n if (a < n && b < n) {\n mixed2[a][b] -= mixed2[a + 1][b + 1]\n }\n mixed2[a][b] %= MOD\n }\n }\n for (chara in 0..25) {\n if (caps[chara] < n) {\n answer -= mixed[caps[chara] + 1]\n answer %= MOD\n for (frisk in chara + 1..25) {\n if (caps[frisk] < n) {\n answer += mixed2[caps[chara] + 1][caps[frisk] + 1]\n answer %= MOD\n }\n }\n }\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "005a44738897da71b9b893f56c6c8d32", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "import kotlin.math.min\r\n\r\nprivate fun readLn() = readLine()!!\r\nprivate fun readInt() = readLn().toInt()\r\nprivate fun readStrings() = readLn().split(\" \")\r\nprivate fun readInts() = readStrings().map { it.toInt() }\r\nprivate fun readLong() = readLn().toLong()\r\nprivate fun readLongs() = readStrings().map { it.toLong() }\r\n\r\nfun main() {\r\n val MOD = 998244353\r\n val n = readInt()\r\n val a = readInts()\r\n var result = 26L * 26;\r\n repeat(n - 2) { result = result * 25 % MOD }\r\n val m = (n + 1) / 2\r\n val dp = Array(2) { Array(m + 2) { Array(m + 2) { Array(3) { Array(3) { 0L } } } } }\r\n dp[0][0][0][0][0] = 1\r\n for (i in 0 until n) {\r\n val ci = i % 2\r\n val ni = 1 - ci\r\n dp[ni].forEach { it.forEach { it.forEach { it.fill(0) } } }\r\n for (c1 in 0..min(i, m))\r\n for (c2 in 0..min(i - c1, m))\r\n for (d1 in 0..2)\r\n for (d2 in 0..2)\r\n for (d3 in 0..2)\r\n if (d1 != d3 || d1 == 0) {\r\n val n1 = c1 + if (d3 == 1) 1 else 0\r\n val n2 = c2 + if (d3 == 2) 1 else 0\r\n val mul = if (d3 > 0) 1 else if (d1 > 0 || i <= 1) 24 else 23\r\n dp[ni][n1][n2][d2][d3] = (dp[ni][n1][n2][d2][d3] + dp[ci][c1][c2][d1][d2] * mul) % MOD\r\n }\r\n }\r\n val d2 = dp[n % 2].map { it.map { it.sumOf { it.sum() % MOD } % MOD } }\r\n val d1 = d2.map { it.sum() % MOD }\r\n for (i in a)\r\n for (j in i + 1..m)\r\n result = (result + MOD - d1[j]) % MOD\r\n for (i in 0..25)\r\n for (j in 0 until i)\r\n for (c1 in a[i] + 1..m)\r\n for (c2 in a[j] + 1..m)\r\n result = (result + d2[c1][c2]) % MOD\r\n println(result)\r\n}\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "66adbee7209f556a59aae8cd895f7638", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n val D = IntModIntMap()\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(2, j, k, l, m)] = d\n }\n\n for(i in 2 until n) for(j in 0..i) for(k in 0..i-j) for(l in 0..2) for(m in 0..2) {\n val d = D[id(i, j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n D[id(i+1, jn, kn, m, p)] += dn\n }\n }\n\n val S = Array(n+2) { ModIntArray(n+2) }\n\n for(j in 0..n) for(k in 0..n) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(n, j, k, l, m)]\n }\n\n val s = S[n+1][n+1]\n var ans = s\n\n for(i in 0 until 25) for(j in i+1 until 26) {\n ans -= s - (S[C[i]+1][C[j]+1])\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun Boolean.toInt() = if(this) 1 else 0\n\nfun id(i: Int, j: Int, k: Int, l: Int, m: Int) = i\n .shl(9).or(j)\n .shl(9).or(k)\n .shl(2).or(l)\n .shl(2).or(m)\n\ntypealias IntModIntMap = _Ez_Int__ModInt_HashMap\ninline operator fun IntModIntMap.set(key: Int, value: ModInt) { put(key, value) }\ninline operator fun IntModIntMap.contains(key: Int) = containsKey(key)\n\nclass _Ez_Int__ModInt_HashMap(capacity: Int = DEFAULT_CAPACITY, val nullValue: ModInt = ModInt(0)) :\n _Ez_Int__ModInt_Map {\n companion object {\n private const val DEFAULT_CAPACITY = 8\n // There are three invariants for size, removedCount and arraysLength:\n// 1. size + removedCount <= 1/2 arraysLength\n// 2. size > 1/8 arraysLength\n// 3. size >= removedCount\n// arraysLength can be only multiplied by 2 and divided by 2.\n// Also, if it becomes >= 32, it can't become less anymore.\n private const val REBUILD_LENGTH_THRESHOLD = 32\n private const val HASHCODE_INITIAL_VALUE = -0x7ee3623b\n private const val HASHCODE_MULTIPLIER = 0x01000193\n private const val FREE: Byte = 0\n private const val REMOVED: Byte = 1\n private const val FILLED: Byte = 2\n private val hashSeed = random.nextInt()\n private val gamma = random.nextInt() or 1\n }\n\n private lateinit var keys: IntArray\n private lateinit var _values: IntArray\n private var values get() = ModIntArray(_values); set(value) { _values = value.intArray }\n private lateinit var status: ByteArray\n override var size = 0\n private set\n private var removedCount = 0\n private var mask = 0\n\n constructor(map: _Ez_Int__ModInt_Map) : this(map.size) {\n val it = map.iterator()\n while (it.hasNext()) {\n put(it.key, it.value)\n it.next()\n }\n }\n\n constructor(javaMap: Map) : this(javaMap.size) {\n for ((key, value) in javaMap) {\n put(key, value)\n }\n }\n\n private fun getStartPos(h: Int): Int {\n var x = (h xor hashSeed) * gamma\n x = (x xor (x ushr 16)) * 0x7feb352d\n x = (x xor (x ushr 15)) * 0x846ca68b.toInt()\n return (x xor (x ushr 16)) and mask\n }\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun containsKey(\n key: Int\n ): Boolean {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return true\n }\n pos = pos + 1 and mask\n }\n return false\n }\n\n override fun get(\n key: Int\n ): ModInt {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return values[pos]\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun put(\n key: Int,\n value: ModInt\n ): ModInt {\n var pos = getStartPos(key)\n while (status[pos] == FILLED) {\n if (keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n if (status[pos] == FREE) {\n status[pos] = FILLED\n keys[pos] = key\n values[pos] = value\n size++\n if ((size + removedCount) * 2 > keys.size) {\n rebuild(keys.size * 2) // enlarge the table\n }\n return nullValue\n }\n val removedPos = pos\n pos = pos + 1 and mask\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n status[removedPos] = FILLED\n keys[removedPos] = key\n values[removedPos] = value\n size++\n removedCount--\n return nullValue\n }\n\n override fun remove(\n key: Int\n ): ModInt {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val removedValue = values[pos]\n status[pos] = REMOVED\n size--\n removedCount++\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n if (8 * size <= keys.size) {\n rebuild(keys.size / 2) // compress the table\n } else if (size < removedCount) {\n rebuild(keys.size) // just rebuild the table\n }\n }\n return removedValue\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun clear() {\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n initEmptyTable(REBUILD_LENGTH_THRESHOLD)\n } else {\n status.fill(FREE)\n size = 0\n removedCount = 0\n }\n }\n\n override fun keys(): IntArray {\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < keys.size) {\n if (status[i] == FILLED) {\n result[j++] = keys[i]\n }\n i++\n }\n return result\n }\n\n override fun values(): ModIntArray {\n val result = ModIntArray(size)\n var i = 0\n var j = 0\n while (i < values.size) {\n if (status[i] == FILLED) {\n result[j++] = values[i]\n }\n i++\n }\n return result\n }\n\n override fun iterator(): _Ez_Int__ModInt_MapIterator {\n return _Ez_Int__ModInt_HashMapIterator()\n }\n\n private fun rebuild(newLength: Int) {\n val oldKeys = keys\n\n val oldValues = values\n val oldStatus = status\n initEmptyTable(newLength)\n for (i in oldKeys.indices) {\n if (oldStatus[i] == FILLED) {\n put(oldKeys[i], oldValues[i])\n }\n }\n }\n\n private fun initEmptyTable(length: Int) {\n keys = IntArray(length)\n values = ModIntArray(length)\n status = ByteArray(length)\n size = 0\n removedCount = 0\n mask = length - 1\n }\n\n fun contentEquals(that: _Ez_Int__ModInt_HashMap): Boolean {\n if (size != that.size) {\n return false\n }\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n val thatValue = that[keys[i]]\n if (thatValue != values[i]) {\n return false\n }\n }\n }\n return true\n }\n\n override fun toString(): String {\n val sb = StringBuilder()\n sb.append('{')\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n if (sb.length > 1) {\n sb.append(\", \")\n }\n sb.append(keys[i])\n sb.append('=')\n sb.append(values[i])\n }\n }\n sb.append('}')\n return sb.toString()\n }\n\n private inner class _Ez_Int__ModInt_HashMapIterator : _Ez_Int__ModInt_MapIterator {\n private var curIndex = 0\n override fun hasNext(): Boolean {\n return curIndex < status.size\n }\n\n\n override val key: Int\n\n get() {\n if (curIndex == keys.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return keys[curIndex]\n }\n\n\n override val value: ModInt\n\n get() {\n if (curIndex == values.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return values[curIndex]\n }\n\n override fun next() {\n if (curIndex == status.size) {\n return\n }\n curIndex++\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n\n init {\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n }\n\n init {\n require(capacity >= 0) { \"Capacity must be non-negative\" }\n val length = Integer.highestOneBit(4 * max(1, capacity) - 1)\n // Length is a power of 2 now\n initEmptyTable(length)\n }\n}\n\ninterface _Ez_Int__ModInt_Map {\n\n val size: Int\n\n fun isEmpty(): Boolean\n\n fun containsKey(\n key: Int\n ): Boolean\n\n operator fun get(\n key: Int\n ): ModInt\n\n fun put(\n key: Int,\n value: ModInt\n ): ModInt\n\n fun remove(\n key: Int\n ): ModInt\n\n fun clear()\n\n fun keys(): IntArray\n\n fun values(): ModIntArray\n\n operator fun iterator(): _Ez_Int__ModInt_MapIterator\n\n override fun toString(): String\n}\n\ninterface _Ez_Int__ModInt_MapIterator {\n operator fun hasNext(): Boolean\n\n val key: Int\n\n val value: ModInt\n\n operator fun next()\n}\n\ninline fun IntModIntMap.forEach(act: (key: Int, value: ModInt) -> Unit) {\n val ite = iterator()\n while(ite.hasNext()) {\n act(ite.key, ite.value)\n ite.next()\n }\n}\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "771a40d418c147b9b80c6c68536cf7d5", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val C = readIntArray(26)\n\n fun id(i: Int, j: Int, k: Int, l: Int, m: Int) = i\n .times(n+1).plus(j)\n .times(n+1).plus(k)\n .times(3).plus(l)\n .times(3).plus(m)\n\n val D = ModIntArray(id(n, n, n, 2, 2)+1)\n\n for(l in 0..2) for(m in 0..2) {\n val j = (l == 0).toInt() + (m == 0).toInt()\n val k = (l == 1).toInt() + (m == 1).toInt()\n\n var d = ModInt(1)\n if(l == 2) d *= 24\n if(m == 2) d *= 24\n\n D[id(2, j, k, l, m)] = d\n }\n\n for(i in 2 until n) for(j in 0..i) for(k in 0..i-j) for(l in 0..2) for(m in 0..2) {\n val d = D[id(i, j, k, l, m)]\n if(d.int == 0) continue\n for(p in 0..2) {\n val dn = if(p == 2) {\n if(l == 2) d*23 else d*24\n } else {\n if(p == l) continue else d\n }\n\n val jn = j + (p == 0).toInt()\n val kn = k + (p == 1).toInt()\n D[id(i+1, jn, kn, m, p)] += dn\n }\n }\n\n val S = Array(n+2) { ModIntArray(n+2) }\n\n for(j in 0..n) for(k in 0..n) {\n S[j+1][k+1] = S[j+1][k] + S[j][k+1] - S[j][k]\n for(l in 0..2) for(m in 0..2) S[j+1][k+1] += D[id(n, j, k, l, m)]\n }\n\n val s = S[n+1][n+1]\n var ans = s\n\n for(i in 0 until 25) for(j in i+1 until 26) {\n ans -= s - (S[C[i]+1][C[j]+1])\n }\n\n println(ans.int)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nfun Boolean.toInt() = if(this) 1 else 0\n\nconst val MOD = 998244353\nconst val TOTIENT = MOD - 1 // assumes MOD is prime\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n if(mod == 1) return 0\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\nfun Int.modPowArray(n: Int, mod: Int): IntArray {\n val res = IntArray(n+1)\n res[0] = 1\n for(i in 1..n) res[i] = mulMod(res[i-1], mod)\n return res\n}\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) {\n require(int != 0) { \"Can't invert/divide by 0\" }\n exponent modulo TOTIENT\n } else exponent\n return ModInt(int.powMod(e, MOD))\n }\n\n fun pow(exponent: Long) = if(int == 0) when {\n exponent > 0 -> this\n exponent == 0L -> ModInt(1)\n else -> error(\"Can't invert/divide by 0\")\n } else pow(exponent modulo TOTIENT)\n\n inline fun inverse() = inv_unmemoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(TOTIENT - 1)\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\ninline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "850026e930da620633723c2f9eb604be", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin 1.4", "source_code": "const val MOD = 998244353L\n\nfun main() {\n val n = readLine()!!.toInt()\n val caps = readLine()!!.split(\" \").map { it.toInt() }\n var answer = 676L\n for (j in 3..n) {\n answer *= 25L\n answer %= MOD\n }\n val dp = Array(3) { Array(n + 1) { LongArray(n + 1) } }\n dp[0][0][0] = 1L\n for (a in 1..n) {\n for (b in 0..n) {\n dp[1][a][b] = ((25L * (dp[0][a - 1][b] + dp[2][a - 1][b])) + (24L * (dp[1][a - 1][b]))) % MOD\n if (b > 0) {\n dp[2][a][b] = (dp[0][a - 1][b - 1] + dp[1][a - 1][b - 1]) % MOD\n }\n }\n }\n val mixed = LongArray(n + 1)\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n mixed[a + b] = (mixed[a + b] + ((dp[1][n / 2][a] + dp[2][n / 2][a]) * (dp[1][(n + 1) / 2][b] + dp[2][(n + 1) / 2][b]))) % MOD\n }\n }\n for (a in n - 1 downTo 0) {\n mixed[a] = (mixed[a] + mixed[a + 1]) % MOD\n }\n val dp2 = Array(4) { Array(n + 1) { Array(n + 1) { LongArray(n + 1) } } }\n dp2[0][0][0][0] = 1L\n for (a in 1..n) {\n for (b in 0..n) {\n for (c in 0..n) {\n dp2[1][a][b][c] = ((24L * (dp2[0][a - 1][b][c] + dp2[2][a - 1][b][c] + dp2[3][a - 1][b][c])) + (23L * (dp2[1][a - 1][b][c]))) % MOD\n if (b > 0) {\n dp2[2][a][b][c] = (dp2[0][a - 1][b - 1][c] + dp2[1][a - 1][b - 1][c] + dp2[3][a - 1][b - 1][c]) % MOD\n }\n if (c > 0) {\n dp2[3][a][b][c] = (dp2[0][a - 1][b][c - 1] + dp2[1][a - 1][b][c - 1] + dp2[2][a - 1][b][c - 1]) % MOD\n }\n }\n }\n }\n val mixed2 = Array(n + 1) { LongArray(n + 1) }\n for (a in 0..n / 2) {\n for (b in 0..(n + 1) / 2) {\n for (c in 0..(n / 2) - a) {\n for (d in 0..((n + 1) / 2) - b) {\n mixed2[a + b][c + d] = (mixed2[a + b][c + d] + ((dp2[1][n / 2][a][c] + dp2[2][n / 2][a][c] + dp2[3][n / 2][a][c]) * (dp2[1][(n + 1) / 2][b][d] + dp2[2][(n + 1) / 2][b][d] + dp2[3][(n + 1) / 2][b][d]))) % MOD\n }\n }\n }\n }\n for (a in n downTo 0) {\n for (b in n downTo 0) {\n if (a < n) {\n mixed2[a][b] += mixed2[a + 1][b]\n }\n if (b < n) {\n mixed2[a][b] += mixed2[a][b + 1]\n }\n if (a < n && b < n) {\n mixed2[a][b] -= mixed2[a + 1][b + 1]\n }\n mixed2[a][b] %= MOD\n }\n }\n for (chara in 0..25) {\n if (caps[chara] < n) {\n answer -= mixed[caps[chara] + 1]\n answer %= MOD\n for (frisk in chara + 1..25) {\n if (caps[frisk] < n) {\n answer += mixed2[caps[chara] + 1][caps[frisk] + 1]\n answer %= MOD\n }\n }\n }\n }\n answer += MOD\n answer %= MOD\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "57c852a9467853e3ffef673769c19a6c", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLong() = readLine()!!.toLong()\n val n = readLong()\n print( 1 + n * (n + 1) * 3) // (n * (n + 1) / 2) * 6 == n * (n + 1) * 3\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "14aab717d3a5164867a3fe65638278a3", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n) = readLine()!!.split(' ').map(String::toLong)\n println((3*n*n)+(3*n)+1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "258262323e10f71e85b58c31d2ea4f98", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val num = r.readLine()!!.toInt()\n //var (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n val m = r.readLine()!!.split(\" \").map { it.toInt() }\n val n = r.readLine()!!.split(\" \").map { it.toInt() }\n val c1 = m.subList(1, m[0]+1).toMutableList()\n val c2 = n.subList(1, n[0]+1).toMutableList()\n val hash = mutableSetOf()\n var ans = 0\n while (c1.size!=0&&c2.size!=0){\n ans ++\n when{\n c1[0]>c2[0] -> {\n c1 += c2[0]\n c1 += c1[0]\n c1.removeAt(0)\n c2.removeAt(0)\n }\n c1[0] {\n c2 += c1[0]\n c2 += c2[0]\n c1.removeAt(0)\n c2.removeAt(0)\n }\n }\n if ((c1+c2).hashCode() !in hash) {\n hash += (c1+c2).hashCode()\n } else {\n ans = -1\n break\n }\n }\n val win = if (c1.size==0) 2 else 1\n println(if (ans==-1) -1 else \"$ans $win\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "252ff8b646930840ee826252b83758c6", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n val num = r.readLine()!!.toInt()\n //var (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n val m = r.readLine()!!.split(\" \").map { it.toInt() }\n val n = r.readLine()!!.split(\" \").map { it.toInt() }\n val c1 = m.subList(1, m[0]+1).toMutableList()\n val c2 = n.subList(1, n[0]+1).toMutableList()\n val hash = mutableSetOf((c1+c2).hashCode())\n var ans = 0\n while (c1.size!=0&&c2.size!=0){\n ans ++\n when{\n c1[0]>c2[0] -> {\n c1 += c2[0]\n c1 += c1[0]\n c1.removeAt(0)\n c2.removeAt(0)\n }\n c1[0] {\n c2 += c1[0]\n c2 += c2[0]\n c1.removeAt(0)\n c2.removeAt(0)\n }\n }\n if ((c1+c2).hashCode() !in hash) {\n hash += (c1+c2).hashCode()\n } else {\n ans = -1\n break\n }\n }\n val win = if (c1.size==0) 2 else 1\n println(if (ans==-1) -1 else \"$ans $win\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "483aadacc057b7192b903d236f720660", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val numCards = readInt()\n val soldier1 = readInts().toMutableList()\n val soldier2 = readInts().toMutableList()\n var pos = 0\n while (++pos < 1000 && pos < soldier1.size && pos < soldier2.size) {\n if (soldier1[pos] > soldier2[pos]) {\n soldier1.add(soldier2[pos])\n soldier1.add(soldier1[pos])\n } else {\n soldier2.add(soldier1[pos])\n soldier2.add(soldier2[pos])\n }\n }\n print(\n when (pos) {\n 1000 -> -1\n soldier1.size -> \"${pos - 1} 2\"\n else -> \"${pos - 1} 1\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5a12b2ff9bf33fecce8a117d7c6f7111", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "var _debug = false;\nfun debug(vararg vals: T): Unit {\n if (!_debug) { return }\n for (v in vals) { System.err.print(v); System.err.print(\" \") }\n System.err.println()\n}\n\nval MOD = 998_244_353\nval MAXN = 5000\n\n//fun getBinomTriangle() : List> {\nfun getBinomTriangle() : Array {\n var p = Array(MAXN+1, { LongArray(MAXN+1) })\n //debug(\"p\", p.size)\n p[0][0] = 1\n for (i in 1..MAXN) {\n p[i][0] = 1\n for (j in 1..i) {\n p[i][j]=(p[i-1][j-1]+p[i-1][j]) % MAXN\n }\n }\n return p\n}\n\nfun getFactorialTable() : LongArray {\n var ft = LongArray(MAXN+1)\n ft[0] = 1\n for (i in 1..MAXN) {\n ft[i] = ft[i-1] * i\n }\n return ft\n}\n\nval btr = getBinomTriangle()\nval ft = getFactorialTable()\n\nfun calculateCombinationsOfTwo(x : Int, y : Int) : Long {\n var res = 0L\n\n for (k in 0..(minOf(x,y))) {\n var summand = ft[k]\n summand = (summand * btr[x][k]) % MOD\n summand = (summand * btr[y][k]) % MOD\n res = (res + summand) % MOD\n }\n //debug(\"calc\", res)\n return res\n}\n\nfun main(args: Array) {\n if (args.size > 0 && args[0] == \"-d\") {\n _debug = true;\n }\n\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n val ab = calculateCombinationsOfTwo(a, b)\n val ac = calculateCombinationsOfTwo(a, c)\n val bc = calculateCombinationsOfTwo(b, c)\n\n println(ab * ac * bc)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7d40ded1c6fc8d109803245ccc195cf1", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "val MOD = 998244353\nval MAXN = 5000\n\nvar dp = Array(MAXN+5, { IntArray(MAXN+5) })\nfun D(a: Int, b: Int) : Int\n{\n if (a == 0 || b == 0) return 1;\n\n if (dp[a][b] == 0)\n {\n dp[a][b] = ((b.toLong() * D(a - 1, b - 1) + D(a - 1, b)) % MOD).toInt();\n }\n\n return dp[a][b];\n}\n\n\nfun main(args: Array) {\n if (args.size > 0 && args[0] == \"-d\") {\n _debug = true;\n }\n\n val xs = readLine()!!.split(' ').map(String::toInt).sorted()\n val (a, b, c) = xs\n\n println(((D(a, b).toLong() * D(b, c).toLong()) % MOD * D(a, c).toLong()) % MOD);\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7a8d745998a9be5f4ec6216ddf3104d6", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "var _debug = false;\nfun debug(vararg vals: T): Unit {\n if (!_debug) { return }\n for (v in vals) { System.err.print(v); System.err.print(\" \") }\n System.err.println()\n}\n\nval MOD = 998244353\nval MAXN = 5000\n\n//fun getBinomTriangle() : List> {\nfun getBinomTriangle() : Array {\n var p = Array(MAXN+1, { LongArray(MAXN+1) })\n //debug(\"p\", p.size)\n p[0][0] = 1\n for (i in 1..MAXN) {\n p[i][0] = 1\n for (j in 1..i) {\n p[i][j]=(p[i-1][j-1]+p[i-1][j]) % MAXN\n }\n }\n return p\n}\n\nfun getFactorialTable() : LongArray {\n var ft = LongArray(MAXN+1)\n ft[0] = 1\n for (i in 1..MAXN) {\n ft[i] = ft[i-1] * i\n }\n return ft\n}\n\nval btr = getBinomTriangle()\nval ft = getFactorialTable()\n\nfun calculateCombinationsOfTwo(x : Int, y : Int) : Long {\n var res = 0L\n\n val the_min = listOf(x,y).min()!!\n for (k in 0..the_min) {\n var summand = ft[k]\n summand = (summand * btr[x][k]) % MOD\n summand = (summand * btr[y][k]) % MOD\n res = (res + summand) % MOD\n }\n //debug(\"calc\", res)\n return res\n}\n\nfun main(args: Array) {\n if (args.size > 0 && args[0] == \"-d\") {\n _debug = true;\n }\n\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n val ab = calculateCombinationsOfTwo(a, b)\n val ac = calculateCombinationsOfTwo(a, c)\n val bc = calculateCombinationsOfTwo(b, c)\n\n println(ab * ac * bc)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bc37428a7752755fb62e51853092dcce", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "var _debug = false;\nfun debug(vararg vals: T): Unit {\n if (!_debug) { return }\n for (v in vals) { System.err.print(v); System.err.print(\" \") }\n System.err.println()\n}\n\nval MOD = 998244353\nval MAXN = 5000\n\n//fun getBinomTriangle() : List> {\nfun getBinomTriangle() : Array {\n var p = Array(MAXN+1, { LongArray(MAXN+1) })\n //debug(\"p\", p.size)\n p[0][0] = 1\n for (i in 1..MAXN) {\n p[i][0] = 1\n for (j in 1..i) {\n p[i][j]=(p[i-1][j-1]+p[i-1][j]) % MOD\n }\n }\n return p\n}\n\nfun getFactorialTable() : LongArray {\n var ft = LongArray(MAXN+1)\n ft[0] = 1\n for (i in 1..MAXN) {\n ft[i] = ft[i-1] * i\n }\n return ft\n}\n\nval btr = getBinomTriangle()\nval ft = getFactorialTable()\n\nfun calculateCombinationsOfTwo(x : Int, y : Int) : Long {\n var res = 0L\n\n val the_min = listOf(x,y).min()!!\n for (k in 0..the_min) {\n var summand = ft[k]\n summand = (summand * btr[x][k]) % MOD\n summand = (summand * btr[y][k]) % MOD\n res = (res + summand) % MOD\n }\n //debug(\"calc\", res)\n return res\n}\n\nfun main(args: Array) {\n if (args.size > 0 && args[0] == \"-d\") {\n _debug = true;\n }\n\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n val ab = calculateCombinationsOfTwo(a, b)\n val ac = calculateCombinationsOfTwo(a, c)\n val bc = calculateCombinationsOfTwo(b, c)\n\n var res = ab\n res = (res * bc) % MOD\n res = (res * ac) % MOD\n\n println(res)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8c4dbea9ad17040d1fc708551b43f226", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "var _debug = false;\nfun debug(vararg vals: T): Unit {\n if (!_debug) { return }\n for (v in vals) { System.err.print(v); System.err.print(\" \") }\n System.err.println()\n}\n\nval MOD = 998244353\nval MAXN = 5000\n\n//fun getBinomTriangle() : List> {\nfun getBinomTriangle() : Array {\n var p = Array(MAXN+1, { LongArray(MAXN+1) })\n //debug(\"p\", p.size)\n p[0][0] = 1\n for (i in 1..MAXN) {\n p[i][0] = 1\n for (j in 1..i) {\n p[i][j]=(p[i-1][j-1]+p[i-1][j]) % MOD\n }\n }\n return p\n}\n\nfun getFactorialTable() : LongArray {\n var ft = LongArray(MAXN+1)\n ft[0] = 1\n for (i in 1..MAXN) {\n ft[i] = (ft[i-1] * i) % MOD\n }\n return ft\n}\n\nval btr = getBinomTriangle()\nval ft = getFactorialTable()\n\nfun calculateCombinationsOfTwo(x : Int, y : Int) : Long {\n var res = 0L\n\n val the_min = listOf(x,y).min()!!\n for (k in 0..the_min) {\n var summand = ft[k]\n summand = (summand * btr[x][k]) % MOD\n summand = (summand * btr[y][k]) % MOD\n debug(\"kxy\", k, x, y, \"ft\", ft[k], \"btr\", btr[x][k], btr[y][k])\n res = (res + summand) % MOD\n }\n //debug(\"calc\", res)\n return res\n}\n\nfun main(args: Array) {\n if (args.size > 0 && args[0] == \"-d\") {\n _debug = true;\n }\n\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n debug(\"abc\", a, b, c)\n val ab = calculateCombinationsOfTwo(a, b)\n val ac = calculateCombinationsOfTwo(a, c)\n val bc = calculateCombinationsOfTwo(b, c)\n\n debug(\"end\", ab, ac, bc)\n\n var res = ab\n res = (res * bc) % MOD\n res = (res * ac) % MOD\n\n println(res)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "35d677eea15ea3102efa1607bb473e42", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "val MOD = 998244353\nval MAXN = 5000\n\nvar dp = Array(MAXN+5, { IntArray(MAXN+5) })\nfun D(a: Int, b: Int) : Int\n{\n if (a == 0 || b == 0) return 1;\n\n if (dp[a][b] == 0)\n {\n dp[a][b] = ((b.toLong() * D(a - 1, b - 1) + D(a - 1, b)) % MOD).toInt();\n }\n\n return dp[a][b];\n}\n\n\nfun main(args: Array) {\n val xs = readLine()!!.split(' ').map(String::toInt).sorted()\n val (a, b, c) = xs\n\n println(((D(a, b).toLong() * D(b, c).toLong()) % MOD * D(a, c).toLong()) % MOD);\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9e595c500f58e1a16a8c183187387c39", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n\n val points = List(4*n + 1) { readInts().let { (x, y) -> Point(x, y) } }\n\n val xcnt = points.groupingBy { it.x }.eachCount()\n val ycnt = points.groupingBy { it.y }.eachCount()\n\n fun Map.squareBoundaries() = run {\n val f = keys.filter {\n this[it]!! >= n\n }\n listOf(f.min()!!, f.max()!!)\n }\n\n val xb = xcnt.squareBoundaries()\n val yb = ycnt.squareBoundaries()\n\n val ans = points.first {\n when {\n it.x in xb -> it.y !in yb[0]..yb[1]\n it.y in yb -> it.x !in xb[0]..xb[1]\n else -> true\n }\n }\n\n println(\"${ans.x} ${ans.y}\")\n}\n\ndata class Point(val x: Int, val y: Int)\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit)\n { Output().apply(block).nowPrint() }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cdeddd9c8d114544c47df872019bd800", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n\n val points = List(4*n + 1) { readInts().let { (x, y) -> Point(x, y) } }\n\n val xcnt = points.groupingBy { it.x }.eachCount()\n val ycnt = points.groupingBy { it.y }.eachCount()\n\n fun Map.squareBoundaries() = run {\n val f = keys.filter {\n this[it]!! >= n\n }\n listOf(f.min()!!, f.max()!!)\n }\n\n val xb = xcnt.squareBoundaries()\n val yb = ycnt.squareBoundaries()\n\n val ans = points.first {\n when {\n it.x in xb -> it.y in yb[0]..yb[1]\n it.y in yb -> it.x in xb[0]..xb[1]\n else -> false\n }.not()\n }\n\n println(\"${ans.x} ${ans.y}\")\n}\n\ndata class Point(val x: Int, val y: Int)\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit)\n { Output().apply(block).nowPrint() }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0960784bdf31427ee565b7acea505421", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\nimport kotlin.math.min\n\nfun main(args: Array) {\n val (n, s, k) = readLine()!!.split(' ').map(String::toInt)\n val r = readLine()!!.split(' ').map(String::toInt).toIntArray()\n val c = readLine()!!.map {\n when (it) {\n 'R' -> 0\n 'G' -> 1\n 'B' -> 2\n else -> throw Exception()\n }\n }\n val dp = Array(n) { IntArray(2501) { Int.MAX_VALUE } }\n for (i in 0 until n) dp[i][r[i]] = abs((s - 1) - i)\n for (sAll in 1..2500) {\n for (i in 0 until n) {\n if (dp[i][sAll] != Int.MAX_VALUE) {\n for (j in 0 until n) if (c[j] != c[i] && r[j] > r[i]) {\n dp[j][sAll + r[j]] = min(dp[j][sAll + r[j]], dp[i][sAll] + abs(i - j))\n }\n }\n }\n }\n println(dp.map { it.drop(k).min()!! }.min().let { if (it != Int.MAX_VALUE) it else -1 })\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d98c50b6c29ca992661513f6a5ab0ebd", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var str = arrayOf(\"\",\"\",\"\",\"\",\"\",\"\")\n for(i in 0..5) {\n str[i] = readLine()!!\n }\n var bx = 0\n var by = 0\n var bm = 0\n for(i in 0..5) {\n var ry = 0\n for(j in 0..7) {\n if(str[i][j] == '-')\n continue\n if(str[i][j] != '*') {\n var mark = 3 - (i / 2)\n if(ry == 2 || ry == 3)\n mark++\n if(mark > bm) {\n bm = mark\n bx = i\n by = j\n }\n }\n ry++\n }\n }\n for(i in 0..5) {\n for(j in 0..7) {\n if(i==bx && j == by) {\n print('P')\n } else {\n print(str[i][j])\n }\n }\n print(\"\\n\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b720820c94b000fec5fa758bbcb42f2f", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main(arg: Array){\n var s = Array(6, {i -> \"\".toCharArray()})\n val n = 6\n val m = 8\n val l1:IntArray = intArrayOf(3, 3, 0, 4, 4, 0, 3, 3)\n val l2:IntArray = intArrayOf(2, 2, 0, 3, 3, 0, 2, 2)\n val l3:IntArray = intArrayOf(1, 1, 0, 2, 2, 0, 1, 1)\n val a:Array = arrayOf(l1, l1, l2, l2, l3, l3)\n var x = -1\n var y = -1\n var best = 0\n for (i in 0..(n-1)) {\n s[i] = (readLine()!!).toCharArray()\n for (j in 0..(m-1)) {\n if (s[i].get(j) == '.' && a[i][j] > best) {\n x = i\n y = j\n best = a[i][j]\n }\n }\n \n }\n s[x][y] = 'P'\n for (i in 0..(n-1))\n println(s[i])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "09d30b4670929a3da44150d5aeac2821", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.Comparator\n\nfun main(args : Array){\n val scan = BufferedReader(InputStreamReader(System.`in`));\n var s1 = scan.readLine();\n var s2 = scan.readLine();\n var s3 = scan.readLine();\n var s4 = scan.readLine();\n var s5 = scan.readLine();\n var s6 = scan.readLine();\n var ss1 = s1.toCharArray();\n var ss2 = s2.toCharArray();\n var ss3 = s3.toCharArray();\n var ss4 = s4.toCharArray();\n var ss5 = s5.toCharArray();\n var ss6 = s6.toCharArray();\n var sh1 = intArrayOf(3, 3, -1, 4, 4, -1, 3, 3);\n var sh2 = intArrayOf(3, 3, -1, 4, 4, -1, 3, 3);\n var sh3 = intArrayOf(2, 2, -1, 3, 3, -1, 2, 2);\n var sh4 = intArrayOf(2, 2, -1, 3, 3, -1, 2, 2);\n var sh5 = intArrayOf(1, 1, -1, 2, 2, -1, 1, 1);\n var sh6 = intArrayOf(1, 1, -1, 2, 2, -1, 1, 1);\n var arrsh = arrayOf(sh1, sh2, sh3, sh4, sh5, sh6);\n var arrss = arrayOf(ss1, ss2, ss3, ss4, ss5, ss6);\n var x = 0;\n var y = 0;\n var vl = 0;\n var i = 0;\n while (i < 6){\n var j = 0;\n while (j < 8){\n if (arrss[i][j] == '.' && arrsh[i][j] > vl){\n x = j;\n y = i;\n vl = arrsh[i][j];\n }\n j++;\n }\n i++;\n }\n i = 0;\n while (i < 6){\n var j = 0;\n while (j < 8){\n if (x == j && y == i){\n System.out.print('P');\n }else{\n System.out.print(arrss[i][j]);\n }\n j++;\n }\n System.out.println();\n i++;\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "119b0ce974c7d36fb6e9fdba3d774659", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numBalls = readLine()!!.toInt()\n val sizes = readInts().toSet().toList().sorted()\n for (pos in 0 until numBalls - 2)\n if (sizes[pos] + 1 == sizes[pos + 1] && sizes[pos] + 2 == sizes[pos + 2]) return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "95ce7842b3c6372521f28b86a15f6514", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n val sizes = readInts().toSet().toList().sorted()\n for (pos in 0 until sizes.size - 2)\n if (sizes[pos] + 1 == sizes[pos + 1] && sizes[pos] + 2 == sizes[pos + 2]) return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f52cfa51e4511c63037692ebad7f0ecb", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nconst val INPUT_FILE_NAME = \"input\"\nconst val OUTPUT_FILE_NAME = \"output\"\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n// solve(FileInputStream(\"$INPUT_FILE_NAME.txt\"), FileOutputStream(\"$OUTPUT_FILE_NAME.txt\"))\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val b = BooleanArray(1001)\n reader.nextArrayInt(n).forEach { b[it] = true }\n for (i in 1..998) {\n if (b[i] && b[i + 1] && b[i + 2]) {\n writer.println(\"YES\")\n return\n }\n }\n writer.println(\"NO\")\n}\n\nfun gcd(a: Int, b: Int): Int {\n return if (b == 0) a else gcd(b, a % b)\n}\n\nclass InputReader(stream: InputStream) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3e9f8b0c9d0de69ae1d719bdabf3f1be", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numBalls = readLine()!!.toInt()\n val sizes = readInts().sorted()\n for (pos in 0 until numBalls - 2)\n if (sizes[pos] + 1 == sizes[pos + 1] && sizes[pos] + 2 == sizes[pos + 2]) return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3df546862db7604f61bb2bc41dee5287", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args : Array){\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n var k: Int = reader.nextInt()\n var list1: MutableList = mutableListOf()\n var b = 0\n for(i in 2..n){\n if(Prime(i) == 1) {\n for (j in 2..i) {\n if (Prime(j) == 1) {\n list1.add(j)\n }\n }\n for (x in 1..list1.size - 1) {\n if (list1[x - 1] + list1[x] + 1 == i) {\n b++\n }\n }\n list1.clear()\n }\n }\n\n if(b>=k){ println(\"YES\")}\n else { println(\"NO\")}\n\n\n}\n\n fun Prime(n: Int):Int{\n var a = 0\n for(i in 2..n/2) {\n if (n % i==0) {\n a++\n }\n }\n if(a==0) return 1\n else return 0\n }\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1f5e1229b0f934afd3b0a6be7929d4e3", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass InputReader(val stream: InputStream) {\n val buf = ByteArray(1024)\n var curChar: Int = 0\n var numChars: Int = 0\n\n fun read(): Char {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0)\n return '\\uFFFF'\n }\n return buf[curChar++].toChar()\n }\n\n fun nextInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0L\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.append(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Char): Boolean {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == '\\uFFFF'\n }\n}\n\nclass OutputWriter(val stream: OutputStream) {\n val buf = ByteArray(65536)\n var curPos: Int = 0\n\n fun write(c: Char) {\n if (buf.size - curPos < 1) flush()\n buf[curPos++] = c.toByte()\n }\n\n fun write(s: String) {\n if (buf.size - curPos < s.length) flush()\n var idx = 0\n if (s.length > buf.size) {\n var remaining = s.length\n while (remaining > buf.size) {\n while (curPos < buf.size) buf[curPos++] = s[idx++].toByte()\n flush()\n remaining -= buf.size\n }\n }\n while (idx < s.length) buf[curPos++] = s[idx++].toByte()\n }\n\n fun flush() {\n stream.write(buf, 0, curPos)\n curPos = 0\n }\n}\n\nfun isprime(n: Int): Boolean {\n if (n == 2 || n == 3)\n return true\n if (n % 2 == 0 || n % 3 == 0 || n == 1)\n return false\n var i = 5\n var w = 2\n while (i * i <= n) {\n if (n % i == 0)\n return false\n i += w\n w = 6 - w\n }\n return true\n}\n\nfun main(args: Array) {\n if (args.isNotEmpty()) System.setIn(FileInputStream(args[0]))\n val ir = InputReader(System.`in`)\n val ow = OutputWriter(System.out)\n\n var answer = 0\n val n = ir.nextInt()\n val k = ir.nextInt()\n for (i in 2 .. n / 2) {\n if (!isprime(i)) continue\n for (j in i + 1 .. n - 1) {\n if (!isprime(j)) continue\n if (isprime(i + j + 1) && (i + j + 1) <= n) {\n ++answer\n //println(\"$i $j\")\n }\n break\n }\n }\n\n if (answer >= k) ow.write(\"YES\\n\")\n else ow.write(\"NO\\n\")\n ow.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a7828f1be78f17f628f7252d76d7a827", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass InputReader(val stream: InputStream) {\n val buf = ByteArray(1024)\n var curChar: Int = 0\n var numChars: Int = 0\n\n fun read(): Char {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0)\n return '\\uFFFF'\n }\n return buf[curChar++].toChar()\n }\n\n fun nextInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0L\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.append(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Char): Boolean {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == '\\uFFFF'\n }\n}\n\nclass OutputWriter(val stream: OutputStream) {\n val buf = ByteArray(65536)\n var curPos: Int = 0\n\n fun write(c: Char) {\n if (buf.size - curPos < 1) flush()\n buf[curPos++] = c.toByte()\n }\n\n fun write(s: String) {\n if (buf.size - curPos < s.length) flush()\n var idx = 0\n if (s.length > buf.size) {\n var remaining = s.length\n while (remaining > buf.size) {\n while (curPos < buf.size) buf[curPos++] = s[idx++].toByte()\n flush()\n remaining -= buf.size\n }\n }\n while (idx < s.length) buf[curPos++] = s[idx++].toByte()\n }\n\n fun flush() {\n stream.write(buf, 0, curPos)\n curPos = 0\n }\n}\n\nfun isprime(n: Int): Boolean {\n if (n == 2 || n == 3)\n return true\n if (n % 2 == 0 || n % 3 == 0 || n == 1)\n return false\n var i = 5\n var w = 2\n while (i * i <= n) {\n if (n % i == 0)\n return false\n i += w\n w = 6 - w\n }\n return true\n}\n\nfun main(args: Array) {\n if (args.isNotEmpty()) System.setIn(FileInputStream(args[0]))\n val ir = InputReader(System.`in`)\n val ow = OutputWriter(System.out)\n\n var answer = 0\n val n = ir.nextInt()\n val k = ir.nextInt()\n for (i in 2 .. n / 2) {\n if (!isprime(i)) continue\n for (j in i + 1 .. n - i) {\n if (!isprime(j)) continue\n if (isprime(i + j + 1) && (i + j + 1) <= n) {\n ++answer\n //println(\"$i $j\")\n }\n break\n }\n }\n\n if (answer >= k) ow.write(\"YES\\n\")\n else ow.write(\"NO\\n\")\n ow.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a1a4e5a703270fa20255ba440931115c", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun sieve(limit: Int): List {\n val notPrimes = mutableSetOf()\n val primes = ArrayList()\n for (num in 2..limit) {\n if (num !in notPrimes) {\n primes.add(num)\n var notPrime = num + num\n while (notPrime <= limit) {\n notPrimes.add(notPrime)\n notPrime += num\n }\n }\n }\n return primes\n }\n val (n, k) = readInts()\n val primes = sieve(n)\n var sol = 0\n for (goal in primes)\n for (pos in 1 until primes.size)\n if (primes[pos] + primes[pos - 1] + 1 > goal) break\n else if (primes[pos] + primes[pos - 1] + 1 == goal) {\n sol++\n break\n }\n print(if (sol >= k) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "307ae62085918ec6548b31b33243990f", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, k) = readLine()!!.split(' ').map { it.toInt() }\n var prime = Array(1001, { true })\n var primenumbers = mutableListOf()\n\n var p = 2\n var count = 0\n while (p * p <= 1001) {\n if (prime[p] == true) {\n\n for (i in p * 2..n step p) {\n prime[i] = false\n }\n }\n p++\n }\n\n for (i in 2..n) {\n if (prime[i]) {\n primenumbers.add(i)\n }\n }\n\n var i = 0\n while (i < primenumbers.size) {\n for (j in 0 until primenumbers.size-1) {\n var index = primenumbers[i] + primenumbers[j] + 1\n if (primenumbers[j] + primenumbers[j + 1] + 1 == primenumbers[i]) {\n count++\n }\n }\n i++\n }\n println(if (count >= k) \"YES\" else \"NO\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "03d4f5b753fa95f2a7c8a3f66fdcb980", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, k) = readLine()!!.split(' ').map { it.toInt() }\n var prime = Array(n + 1, { true })\n var primenumbers = mutableListOf()\n\n var p = 2\n var count = 0\n while (p * p <= n) {\n if (prime[p] == true) {\n\n for (i in p * 2..n step p) {\n prime[i] = false\n }\n }\n p++\n }\n\n for (i in 2..n) {\n if (prime[i]) {\n primenumbers.add(i)\n }\n }\n\n var i = 0\n while (i < primenumbers.size - 1) {\n var flag = false\n for (j in i + 1 until primenumbers.size) {\n if (primenumbers.contains(primenumbers[i] + primenumbers[j] + 1)) {\n count++\n primenumbers.removeAt(i)\n primenumbers.removeAt(j)\n flag = true\n break\n }\n }\n if (!flag) i++\n\n }\n println(if (count >= k) \"YES\" else \"NO\")\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce99a55b63aa8677faaee7baec98ad22", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass InputReader(val stream: InputStream) {\n val buf = ByteArray(1024)\n var curChar: Int = 0\n var numChars: Int = 0\n\n fun read(): Char {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0)\n return '\\uFFFF'\n }\n return buf[curChar++].toChar()\n }\n\n fun nextInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextLong(): Long {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-') {\n sgn = -1\n c = read()\n }\n var res = 0L\n do {\n if (c < '0' || c > '9')\n throw InputMismatchException()\n res *= 10\n res += c.toInt() and 15\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun nextString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.append(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Char): Boolean {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == '\\uFFFF'\n }\n}\n\nclass OutputWriter(val stream: OutputStream) {\n val buf = ByteArray(65536)\n var curPos: Int = 0\n\n fun write(c: Char) {\n if (buf.size - curPos < 1) flush()\n buf[curPos++] = c.toByte()\n }\n\n fun write(s: String) {\n if (buf.size - curPos < s.length) flush()\n var idx = 0\n if (s.length > buf.size) {\n var remaining = s.length\n while (remaining > buf.size) {\n while (curPos < buf.size) buf[curPos++] = s[idx++].toByte()\n flush()\n remaining -= buf.size\n }\n }\n while (idx < s.length) buf[curPos++] = s[idx++].toByte()\n }\n\n fun flush() {\n stream.write(buf, 0, curPos)\n curPos = 0\n }\n}\n\nfun isprime(n: Int): Boolean {\n if (n == 2 || n == 3)\n return true\n if (n % 2 == 0 || n % 3 == 0 || n == 1)\n return false\n var i = 5\n var w = 2\n while (i * i <= n) {\n if (n % i == 0)\n return false\n i += w\n w = 6 - w\n }\n return true\n}\n\nfun main(args: Array) {\n if (args.isNotEmpty()) System.setIn(FileInputStream(args[0]))\n val ir = InputReader(System.`in`)\n val ow = OutputWriter(System.out)\n\n var answer = 0\n val n = ir.nextInt()\n val k = ir.nextInt()\n for (i in 2 .. n / 2) {\n if (!isprime(i)) continue\n for (j in i + 1 .. n / 2) {\n if (!isprime(j)) continue\n if (isprime(i + j + 1) && (i + j + 1) <= n) ++answer\n break\n }\n }\n\n if (answer >= k) ow.write(\"YES\\n\")\n else ow.write(\"NO\\n\")\n ow.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e4edafd807f22045b901350e6564af8f", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args : Array){\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n var k: Int = reader.nextInt()\n var list1: MutableList = mutableListOf()\n var b = 0\n for(i in 2..n){\n if(checkPrime(i) == 1) {\n for (j in 2..i) {\n if (checkPrime(j) == 1) {\n list1.add(j)\n }\n }\n for (x in 1..list1.size - 1) {\n if (list1[x - 1] + list1[x] + 1 == i) {\n b++\n }\n }\n list1.clear()\n }\n }\n\n if(b>=k){ println(\"YES\")}\n else { println(\"NO\")}\n\n\n}\n\n fun Prime(n: Int):Int{\n var a = 0\n for(i in 2..n/2) {\n if (n % i==0) {\n a++\n }\n }\n if(a==0) return 1\n else return 0\n }\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2105e3c8b1b6f5154dc994db1de9bb88", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "val MOD = 1000000007\n\nfun multiplyMatrices(firstMatrix: Array>, secondMatrix: Array>, r1: Int, c1: Int, c2: Int): Array> {\n val product = Array(r1) { IntArray(c2).toTypedArray() }\n for (i in 0 until r1) {\n for (j in 0 until c2) {\n for (k in 0 until c1) {\n product[i][j] = ((product[i][j].toLong() + firstMatrix[i][k].toLong() * secondMatrix[k][j].toLong()) % MOD).toInt()\n }\n }\n }\n\n return product\n}\n\nfun rise(matrix: Array>, p: Long): Array> {\n var ind = 0\n var multiArray = Array>(matrix.size) { Array(matrix.size) {0} }\n for (row in 0 until matrix.size) {\n multiArray[row][row] = 1\n }\n var factor = matrix\n while ((p shr ind) > 0) {\n if ((p shr ind) and 1L == 1L)\n multiArray = multiplyMatrices(multiArray, factor, matrix.size, matrix.size, matrix.size)\n factor = multiplyMatrices(factor, factor, matrix.size, matrix.size, matrix.size)\n ind++\n }\n return multiArray\n}\n\nfun main(args: Array) {\n val (n, ml) = readLine()!!.split(' ').map(String::toLong)\n val m = ml.toInt()\n val multiArray = Array>(m) { Array(m) {0} }\n for (row in 0 until m-1) {\n multiArray[row][row+1] = 1\n }\n multiArray[m-1][0] = 1\n multiArray[m-1][m-1] = 1\n\n val finar = rise(multiArray, n-1)\n\n val init = Array>(m) { Array(1) {1} }\n\n val result = multiplyMatrices(finar, init, m, m, 1)\n\n print(result[m-1][0])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e5b3d6e29c7b8ae270793e8c46bcb868", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "val MOD = 1000000007\n\nfun multiplyMatrices(firstMatrix: Array>, secondMatrix: Array>, r1: Int, c1: Int, c2: Int): Array> {\n val product = Array(r1) { IntArray(c2).toTypedArray() }\n for (i in 0 until r1) {\n for (j in 0 until c2) {\n for (k in 0 until c1) {\n product[i][j] = ((product[i][j].toLong() + firstMatrix[i][k].toLong() * secondMatrix[k][j].toLong()) % MOD).toInt()\n }\n }\n }\n\n return product\n}\n\nfun rise(matrix: Array>, p: Int): Array> {\n var ind = 0\n var multiArray = Array>(matrix.size) { Array(matrix.size) {0} }\n for (row in 0 until matrix.size) {\n multiArray[row][row] = 1\n }\n var factor = matrix\n while ((p shr ind) > 0) {\n if ((p shr ind) and 1 == 1)\n multiArray = multiplyMatrices(multiArray, factor, matrix.size, matrix.size, matrix.size)\n factor = multiplyMatrices(factor, factor, matrix.size, matrix.size, matrix.size)\n ind++\n }\n return multiArray\n}\n\nfun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val multiArray = Array>(m) { Array(m) {0} }\n for (row in 0 until m-1) {\n multiArray[row][row+1] = 1\n }\n multiArray[m-1][0] = 1\n multiArray[m-1][m-1] = 1\n\n val finar = rise(multiArray, n-1)\n\n val init = Array>(m) { Array(1) {1} }\n\n val result = multiplyMatrices(finar, init, m, m, 1)\n\n print(result[m-1][0])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fdafa6750ba4da1fde65488d7b3c9809", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.lang.Math.*\nimport java.util.*\n\nprivate fun readInt() = readLine()!!.toInt()\nprivate fun readLong() = readLine()!!.toLong()\nprivate fun readInts() = readLine()!!.split(\" \").map(String::toInt)\nprivate fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n\nfun matmul(matA: Array, matB: Array, mod: Long): Array {\n val (x, y, z) = Triple(matA.size, matB[0].size, matA[0].size)\n val res = Array(x) { LongArray(y) }\n\n for (i in 0 until x) for (j in 0 until y) for (k in 0 until z) {\n res[i][j] = (res[i][j] + matA[i][k] * matB[k][j]) % mod\n }\n\n return res\n}\n\nfun main(args: Array) {\n var (n, m) = readLongs()\n val mod: Long = 1000000007\n var matA = Array(m.toInt()) { LongArray(m.toInt()) }\n var matB = Array(m.toInt()) { LongArray(1) }\n\n for (i in 1 until m.toInt()) matA[i-1][i] = 1\n matA[0][0] = 1\n matA.last()[0] = 1\n matB[0][0] = 1\n\n while (n > 0) {\n if (n.and(1) == 1L) {\n matB = matmul(matA, matB, mod)\n }\n matA = matmul(matA, matA, mod)\n n = n.shr(1)\n }\n\n println(matB[0][0])\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ebfb8d1cd3b34f630c73e3ffa9cfec5b", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(args : Array){\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n\n if(n<0) {n =-n}\n var res = 0\n var tot = 0\n while(tot, D: IntArray): Boolean {\n for (u in 0 until N) {\n for (v in 0 until N) {\n if (!g[u][v]) continue\n if (D[v] % 2 == D[u] % 2) {\n return false\n }\n }\n }\n\n return true\n}\n/**\n * (dist, parent, queue)\n * @param rt \u30eb\u30fc\u30c8\u30ce\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3002null\u306e\u5834\u5408\u306f\u5168\u30ce\u30fc\u30c9\u8fbf\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\n */\nfun traceBfs(g: Array, rt: Int? = 0): Array {\n val n = g.size\n val q = IntArray(n)\n val d = IntArray(n)\n val p = IntArray(n){-2}\n var h = 0\n var t = 0\n\n fun bfs(rt: Int) {\n p[rt] = -1\n q[t++] = rt\n d[rt] = 0\n while (h < t) {\n val u = q[h++]\n for (v in 0 until n) {\n if (!g[u][v]) continue\n if (p[v] == -2) {\n p[v] = u\n q[t++] = v\n d[v] = d[u] + 1\n }\n }\n }\n }\n\n if (rt != null) {\n bfs(rt)\n } else {\n for (u in 0 until n) {\n if (p[u] != -2) continue\n bfs(u)\n }\n }\n return arrayOf(d, p, q)\n}\nfun packUGraph(n: Int, from: IntArray, to: IntArray): Array {\n val p = IntArray(n)\n val m = from.size\n for (i in 0 until m) {\n ++p[from[i]]\n ++p[to[i]]\n }\n val g = Array(n){IntArray(p[it])}\n for (i in 0 until m) {\n g[from[i]][--p[from[i]]] = to[i]\n g[to[i]][--p[to[i]]] = from[i]\n }\n return g\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n\n private val N = ni()\n private val M = ni()\n fun solve() {\n val g = Array(N){BooleanArray(N){true} }\n for (i in 0 until N) {\n g[i][i] = false\n }\n\n for (i in 0 until M) {\n val u = ni() - 1\n val v = ni() - 1\n g[u][v] = false\n g[v][u] = false\n }\n\n if (isDebug) {\n for (i in 0 until N) {\n debug(g[i])\n }\n }\n\n val (dist, _, _) = traceBfs(g, null)\n if (!testBipartite(N, g, dist)) {\n out.println(\"No\")\n return\n }\n\n val ans = CharArray(N)\n for (i in 0 until N) {\n if (g[i].count{it} == 0) {\n ans[i] = 'b'\n } else {\n ans[i] = if (dist[i] % 2 == 0) 'a' else 'c'\n }\n }\n\n out.println(\"Yes\")\n out.println(ans.joinToString(\"\"))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { toString(a) }\n }\n\n private inline fun toString(a: BooleanArray) = run{a.map { if (it) 1 else 0 }.joinToString(\"\")}\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5c584d184d763ac2d08c658731b70ff6", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun testBipartite(N: Int, g: Array, D: IntArray): Boolean {\n for (u in 0 until N) {\n for (v in 0 until N) {\n if (!g[u][v]) continue\n if (D[v] % 2 == D[u] % 2) {\n return false\n }\n }\n }\n\n return true\n}\n/**\n * (dist, parent, queue)\n * @param rt \u30eb\u30fc\u30c8\u30ce\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3002null\u306e\u5834\u5408\u306f\u5168\u30ce\u30fc\u30c9\u8fbf\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\n */\nfun traceBfs(g: Array): Array? {\n val n = g.size\n val q = IntArray(n)\n val d = IntArray(n)\n val p = IntArray(n){-2}\n var h = 0\n var t = 0\n\n fun bfs(rt: Int) {\n p[rt] = -1\n q[t++] = rt\n d[rt] = 0\n while (h < t) {\n val u = q[h++]\n for (v in 0 until n) {\n if (!g[u][v]) continue\n if (p[v] == -2) {\n p[v] = u\n q[t++] = v\n d[v] = d[u] + 1\n }\n }\n }\n }\n\n var traced = false\n for (u in 0 until n) {\n if (g[u].all{!it}) continue\n if (p[u] != -2) continue\n if (traced) return null\n bfs(u)\n traced = true\n }\n return arrayOf(d, p, q)\n}\nfun packUGraph(n: Int, from: IntArray, to: IntArray): Array {\n val p = IntArray(n)\n val m = from.size\n for (i in 0 until m) {\n ++p[from[i]]\n ++p[to[i]]\n }\n val g = Array(n){IntArray(p[it])}\n for (i in 0 until m) {\n g[from[i]][--p[from[i]]] = to[i]\n g[to[i]][--p[to[i]]] = from[i]\n }\n return g\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n\n private val N = ni()\n private val M = ni()\n fun solve() {\n if (!solve2()) {\n out.println(\"No\")\n }\n }\n\n fun solve2(): Boolean {\n val g = Array(N){BooleanArray(N){true} }\n for (i in 0 until N) {\n g[i][i] = false\n }\n\n for (i in 0 until M) {\n val u = ni() - 1\n val v = ni() - 1\n g[u][v] = false\n g[v][u] = false\n }\n\n if (isDebug) {\n for (i in 0 until N) {\n debug(g[i])\n }\n }\n\n val (dist, _, _) = traceBfs(g) ?: return false\n if (!testBipartite(N, g, dist)) {\n return false\n }\n\n val ans = CharArray(N)\n for (i in 0 until N) {\n if (g[i].count{it} == 0) {\n ans[i] = 'b'\n } else {\n ans[i] = if (dist[i] % 2 == 0) 'a' else 'c'\n }\n }\n\n out.println(\"Yes\")\n out.println(ans.joinToString(\"\"))\n return true\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { toString(a) }\n }\n\n private inline fun toString(a: BooleanArray) = run{a.map { if (it) 1 else 0 }.joinToString(\"\")}\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "314dcb58802b5cbebbd1e33427987a5b", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun testBipartite(N: Int, g: Array, D: IntArray): Boolean {\n for (u in 0 until N) {\n for (v in 0 until N) {\n if (!g[u][v]) continue\n if (D[v] % 2 == D[u] % 2) {\n return false\n }\n }\n }\n\n return true\n}\n/**\n * (dist, parent, queue)\n * @param rt \u30eb\u30fc\u30c8\u30ce\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3002null\u306e\u5834\u5408\u306f\u5168\u30ce\u30fc\u30c9\u8fbf\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\n */\nfun traceBfs(g: Array): Array? {\n val n = g.size\n val q = IntArray(n)\n val d = IntArray(n)\n val p = IntArray(n){-2}\n var h = 0\n var t = 0\n\n fun bfs(rt: Int) {\n p[rt] = -1\n q[t++] = rt\n d[rt] = 0\n while (h < t) {\n val u = q[h++]\n for (v in 0 until n) {\n if (!g[u][v]) continue\n if (p[v] == -2) {\n p[v] = u\n q[t++] = v\n d[v] = d[u] + 1\n }\n }\n }\n }\n\n var traced = false\n for (u in 0 until n) {\n if (g[u].all{!it}) continue\n if (p[u] != -2) continue\n if (traced) return null\n bfs(u)\n traced = true\n }\n return arrayOf(d, p, q)\n}\nfun packUGraph(n: Int, from: IntArray, to: IntArray): Array {\n val p = IntArray(n)\n val m = from.size\n for (i in 0 until m) {\n ++p[from[i]]\n ++p[to[i]]\n }\n val g = Array(n){IntArray(p[it])}\n for (i in 0 until m) {\n g[from[i]][--p[from[i]]] = to[i]\n g[to[i]][--p[to[i]]] = from[i]\n }\n return g\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n\n private val N = ni()\n private val M = ni()\n fun solve() {\n if (!solve2()) {\n out.println(\"No\")\n }\n }\n\n fun solve2(): Boolean {\n val g = Array(N){BooleanArray(N){true} }\n for (i in 0 until N) {\n g[i][i] = false\n }\n\n for (i in 0 until M) {\n val u = ni() - 1\n val v = ni() - 1\n g[u][v] = false\n g[v][u] = false\n }\n\n if (isDebug) {\n for (i in 0 until N) {\n debug(g[i])\n }\n }\n\n val (dist, _, _) = traceBfs(g) ?: return false\n if (!testBipartite(N, g, dist)) {\n return false\n }\n\n val ans = CharArray(N)\n for (i in 0 until N) {\n if (g[i].count{it} == 0) {\n ans[i] = 'b'\n } else {\n ans[i] = if (dist[i] % 2 == 0) 'a' else 'c'\n }\n }\n\n for (i in 0 until N) {\n for (j in 0 until N) {\n if (i == j) continue\n abs(ans[i] - ans[j]) <= 1\n if (abs(ans[i] - ans[j]) <= 1 != !g[i][j]) {\n return false\n }\n }\n }\n\n out.println(\"Yes\")\n out.println(ans.joinToString(\"\"))\n return true\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { toString(a) }\n }\n\n private inline fun toString(a: BooleanArray) = run{a.map { if (it) 1 else 0 }.joinToString(\"\")}\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "07be11dcfe1e350e0556a64e09f79822", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.math.BigInteger\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = read().toBigInteger()\n\n val ones = Array(51) { one }\n for(i in 1..ones.lastIndex) ones[i] = (ones[i-1] * ten).inc()\n\n val heap = DijkHeap()\n heap.promote(n, 0)\n\n val ans = run ans@ {\n while(heap.isNotFinished()) {\n val x = heap.remove()\n val c = heap.cost(x)\n\n if(x == BigInteger.ZERO) return@ans c\n\n val i = ones.bsIndexOfLast { it <= x }\n heap.promote(x - ones[i], c + i + 1)\n heap.promote(ones[i+1] - x, c + i + 2)\n }\n\n -1\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nval one = BigInteger.ONE\nval ten = BigInteger.TEN!!\n\nfun splitmix64(seed: Long): Long {\n var x = seed // * -7046029254386353131\n x = (x xor (x ushr 30)) * -4658895280553007687\n x = (x xor (x ushr 27)) * -7723592293110705685\n return (x xor (x ushr 31))\n}\n@JvmField val nonce64 = random.nextLong()\n@JvmField val gamma64 = random.nextLong() or 1\nfun Long.hash() = splitmix64((nonce64 xor this) * gamma64)\n\nfun BigInteger.hash(): Long = toByteArray().asUByteArray().run {\n var res = size.toLong()\n for(i in indices) {\n if(i and 7 == 0) res = res.hash()\n res = res xor get(i).toLong().shl(i.and(7) * 8)\n }\n\n return res//.hash()\n}\n\ninline fun bsFirst(first: Int, last: Int, predicate: (Int) -> Boolean): Int {\n var low = first\n var high = last\n\n while (low <= high) {\n val mid = low.and(high) + low.xor(high).shr(1)\n if(predicate(mid)) high = mid - 1\n else low = mid + 1\n }\n return low\n}\ninline fun IntRange.bsFirst(predicate: (Int) -> Boolean) = bsFirst(first, last, predicate)\n\ninline fun bsLast(first: Int, last: Int, predicate: (Int) -> Boolean) = bsFirst(first, last) { !predicate(it) } - 1\ninline fun IntRange.bsLast(predicate: (Int) -> Boolean) = bsLast(first, last, predicate)\n\ninline fun Array.bsIndexOfFirst(predicate: (T) -> Boolean) = bsFirst(0, lastIndex) { predicate(get(it)) }\ninline fun Array.bsFirst(predicate: (T) -> Boolean) = get(bsIndexOfFirst(predicate))\ninline fun Array.bsFirstOrNull(predicate: (T) -> Boolean) = getOrNull(bsIndexOfFirst(predicate))\ninline fun Array.bsIndexOfLast(predicate: (T) -> Boolean) = bsLast(0, lastIndex) { predicate(get(it)) }\ninline fun Array.bsLast(predicate: (T) -> Boolean) = get(bsIndexOfLast(predicate))\ninline fun Array.bsLastOrNull(predicate: (T) -> Boolean) = getOrNull(bsIndexOfLast(predicate))\n\nconst val inf = Int.MAX_VALUE\nclass DijkHeap {\n val h = intListOf(-1)\n val pos = IntList()\n val cost = IntList()\n val map = LongIntMap(nullValue = -1)\n val keys = mutableListOf()\n\n val inHeap get() = h.lastIndex\n\n private fun swap(i: Int, j: Int) {\n val hi = h[i]; val hj = h[j]\n h[j] = hi; h[i] = hj\n pos[hi] = j; pos[hj] = i\n }\n\n fun promote(key0: BigInteger, newCost: Int): Boolean {\n val key = run {\n val hash = key0.hash()\n map[hash].let { if(it != -1) return@run it }\n keys.size.also {\n map[hash] = it\n keys.add(key0)\n h.add(it)\n pos.add(inHeap)\n cost.add(inf)\n }\n }\n if(newCost >= cost[key]) return false\n var i = pos[key]\n\n while(i > 1) {\n val par = i shr 1\n if (newCost >= cost[h[par]]) break\n swap(i, par)\n i = par\n }\n\n cost[key] = newCost\n return true\n }\n\n val head get() = h[1]\n fun isNotFinished() = inHeap > 0\n\n fun remove() = head.let { hd ->\n swap(1, inHeap)\n pos[hd] = -1\n h.pop()\n\n var i = 1\n while(true) {\n val l = i shl 1\n if(l > inHeap) break\n val r = l or 1\n\n var best = l\n var p = cost[h[l]]\n if(r <= inHeap) {\n val pr = cost[h[r]]\n if(pr < p) {\n best = r\n p = pr\n }\n }\n\n if(cost[h[i]] <= p) break\n\n swap(i, best)\n i = best\n }\n\n keys[hd]\n }\n\n fun cost(key: BigInteger): Int {\n val hash = key.hash()\n val i = map[hash]\n return if(i == -1) inf else cost[i]\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var arr = IntArray(initialCapacity)\n val _arr get() = arr\n private val capacity get() = arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n arr = arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list.arr.copyInto(arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n arr.copyInto(arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n arr.copyInto(arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n\n inline fun sortWith(cmp: (Int, Int) -> Int) { _mergeSort(_arr, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\n inline fun > sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\n inline fun > sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\n fun sort() { sortBy { it } }\n fun sortDescending() { sortByDescending { it } }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\ntypealias LongIntMap = _Ez_Long__Int_HashMap\ninline operator fun LongIntMap.set(key: Long, value: Int) { put(key, value) }\ninline operator fun LongIntMap.contains(key: Long) = containsKey(key)\n\nclass _Ez_Long__Int_HashMap(capacity: Int = DEFAULT_CAPACITY, val nullValue: Int = 0) :\n _Ez_Long__Int_Map {\n companion object {\n private const val DEFAULT_CAPACITY = 8\n // There are three invariants for size, removedCount and arraysLength:\n// 1. size + removedCount <= 1/2 arraysLength\n// 2. size > 1/8 arraysLength\n// 3. size >= removedCount\n// arraysLength can be only multiplied by 2 and divided by 2.\n// Also, if it becomes >= 32, it can't become less anymore.\n private const val REBUILD_LENGTH_THRESHOLD = 32\n private const val HASHCODE_INITIAL_VALUE = -0x7ee3623b\n private const val HASHCODE_MULTIPLIER = 0x01000193\n private const val FREE: Byte = 0\n private const val REMOVED: Byte = 1\n private const val FILLED: Byte = 2\n private val hashSeed = random.nextLong()\n private val gamma = random.nextLong() or 1\n }\n\n private lateinit var keys: LongArray\n private lateinit var values: IntArray\n private lateinit var status: ByteArray\n override var size = 0\n private set\n private var removedCount = 0\n private var mask = 0\n\n constructor(map: _Ez_Long__Int_Map) : this(map.size) {\n val it = map.iterator()\n while (it.hasNext()) {\n put(it.key, it.value)\n it.next()\n }\n }\n\n constructor(javaMap: Map) : this(javaMap.size) {\n for ((key, value) in javaMap) {\n put(key, value)\n }\n }\n\n private fun getStartPos(h: Long): Int {\n var x = (h xor hashSeed) * gamma\n x = (x xor (x ushr 30)) * -4658895280553007687\n x = (x xor (x ushr 27)) * -7723592293110705685\n return (x xor (x ushr 31)).toInt() and mask\n }\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun containsKey(\n key: Long\n ): Boolean {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return true\n }\n pos = pos + 1 and mask\n }\n return false\n }\n\n override fun get(\n key: Long\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return values[pos]\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun put(\n key: Long,\n value: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] == FILLED) {\n if (keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n if (status[pos] == FREE) {\n status[pos] = FILLED\n keys[pos] = key\n values[pos] = value\n size++\n if ((size + removedCount) * 2 > keys.size) {\n rebuild(keys.size * 2) // enlarge the table\n }\n return nullValue\n }\n val removedPos = pos\n pos = pos + 1 and mask\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n status[removedPos] = FILLED\n keys[removedPos] = key\n values[removedPos] = value\n size++\n removedCount--\n return nullValue\n }\n\n override fun remove(\n key: Long\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val removedValue = values[pos]\n status[pos] = REMOVED\n size--\n removedCount++\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n if (8 * size <= keys.size) {\n rebuild(keys.size / 2) // compress the table\n } else if (size < removedCount) {\n rebuild(keys.size) // just rebuild the table\n }\n }\n return removedValue\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun clear() {\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n initEmptyTable(REBUILD_LENGTH_THRESHOLD)\n } else {\n status.fill(FREE)\n size = 0\n removedCount = 0\n }\n }\n\n override fun keys(): LongArray {\n val result = LongArray(size)\n var i = 0\n var j = 0\n while (i < keys.size) {\n if (status[i] == FILLED) {\n result[j++] = keys[i]\n }\n i++\n }\n return result\n }\n\n override fun values(): IntArray {\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < values.size) {\n if (status[i] == FILLED) {\n result[j++] = values[i]\n }\n i++\n }\n return result\n }\n\n override fun iterator(): _Ez_Long__Int_MapIterator {\n return _Ez_Long__Int_HashMapIterator()\n }\n\n private fun rebuild(newLength: Int) {\n val oldKeys = keys\n\n val oldValues = values\n val oldStatus = status\n initEmptyTable(newLength)\n for (i in oldKeys.indices) {\n if (oldStatus[i] == FILLED) {\n put(oldKeys[i], oldValues[i])\n }\n }\n }\n\n private fun initEmptyTable(length: Int) {\n keys = LongArray(length)\n values = IntArray(length)\n status = ByteArray(length)\n size = 0\n removedCount = 0\n mask = length - 1\n }\n\n fun contentEquals(that: _Ez_Long__Int_HashMap): Boolean {\n if (size != that.size) {\n return false\n }\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n val thatValue = that[keys[i]]\n if (thatValue != values[i]) {\n return false\n }\n }\n }\n return true\n }\n\n override fun toString(): String {\n val sb = StringBuilder()\n sb.append('{')\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n if (sb.length > 1) {\n sb.append(\", \")\n }\n sb.append(keys[i])\n sb.append('=')\n sb.append(values[i])\n }\n }\n sb.append('}')\n return sb.toString()\n }\n\n private inner class _Ez_Long__Int_HashMapIterator : _Ez_Long__Int_MapIterator {\n private var curIndex = 0\n override fun hasNext(): Boolean {\n return curIndex < status.size\n }\n\n\n override val key: Long\n\n get() {\n if (curIndex == keys.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return keys[curIndex]\n }\n\n\n override val value: Int\n\n get() {\n if (curIndex == values.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return values[curIndex]\n }\n\n override fun next() {\n if (curIndex == status.size) {\n return\n }\n curIndex++\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n\n init {\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n }\n\n init {\n require(capacity >= 0) { \"Capacity must be non-negative\" }\n val length = Integer.highestOneBit(4 * max(1, capacity) - 1)\n // Length is a power of 2 now\n initEmptyTable(length)\n }\n}\n\ninterface _Ez_Long__Int_Map {\n\n val size: Int\n\n fun isEmpty(): Boolean\n\n fun containsKey(\n key: Long\n ): Boolean\n\n operator fun get(\n key: Long\n ): Int\n\n fun put(\n key: Long,\n value: Int\n ): Int\n\n fun remove(\n key: Long\n ): Int\n\n fun clear()\n\n fun keys(): LongArray\n\n fun values(): IntArray\n\n operator fun iterator(): _Ez_Long__Int_MapIterator\n\n override fun toString(): String\n}\n\ninterface _Ez_Long__Int_MapIterator {\n operator fun hasNext(): Boolean\n\n val key: Long\n\n val value: Int\n\n operator fun next()\n}\n\ninline fun LongIntMap.forEach(act: (key: Long, value: Int) -> Unit) {\n val ite = iterator()\n while(ite.hasNext()) {\n act(ite.key, ite.value)\n ite.next()\n }\n}\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1043bda6f50231512693b4de6b12c041", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Kotlin 1.4", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n@file:OptIn(ExperimentalUnsignedTypes::class, ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.math.BigInteger\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = read().toBigInteger()\n\n val ones = Array(51) { one }\n for(i in 1..ones.lastIndex) ones[i] = (ones[i-1] * ten).inc()\n\n val heap = DijkHeap()\n heap.promote(n, 0)\n\n val ans = run ans@ {\n while(heap.isNotFinished()) {\n val x = heap.remove()\n val c = heap.cost(x)\n\n if(x == BigInteger.ZERO) return@ans c\n\n val i = ones.bsIndexOfLast { it <= x }\n heap.promote(x - ones[i], c + i + 1)\n heap.promote(ones[i+1] - x, c + i + 2)\n }\n\n -1\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\nval one = BigInteger.ONE\nval ten = BigInteger.TEN!!\n\nfun splitmix64(seed: Long): Long {\n var x = seed // * -7046029254386353131\n x = (x xor (x ushr 30)) * -4658895280553007687\n x = (x xor (x ushr 27)) * -7723592293110705685\n return (x xor (x ushr 31))\n}\n@JvmField val nonce64 = random.nextLong()\n@JvmField val gamma64 = random.nextLong() or 1\nfun Long.hash() = splitmix64((nonce64 xor this) * gamma64)\n\nfun BigInteger.hash(): Long = toByteArray().run {\n var res = size.toLong()\n for(i in indices) {\n if(i and 7 == 0) res = res.hash()\n res = res xor get(i).toLong().shl(i.and(7) * 8)\n }\n\n return res//.hash()\n}\n\ninline fun bsFirst(first: Int, last: Int, predicate: (Int) -> Boolean): Int {\n var low = first\n var high = last\n\n while (low <= high) {\n val mid = low.and(high) + low.xor(high).shr(1)\n if(predicate(mid)) high = mid - 1\n else low = mid + 1\n }\n return low\n}\ninline fun IntRange.bsFirst(predicate: (Int) -> Boolean) = bsFirst(first, last, predicate)\n\ninline fun bsLast(first: Int, last: Int, predicate: (Int) -> Boolean) = bsFirst(first, last) { !predicate(it) } - 1\ninline fun IntRange.bsLast(predicate: (Int) -> Boolean) = bsLast(first, last, predicate)\n\ninline fun Array.bsIndexOfFirst(predicate: (T) -> Boolean) = bsFirst(0, lastIndex) { predicate(get(it)) }\ninline fun Array.bsFirst(predicate: (T) -> Boolean) = get(bsIndexOfFirst(predicate))\ninline fun Array.bsFirstOrNull(predicate: (T) -> Boolean) = getOrNull(bsIndexOfFirst(predicate))\ninline fun Array.bsIndexOfLast(predicate: (T) -> Boolean) = bsLast(0, lastIndex) { predicate(get(it)) }\ninline fun Array.bsLast(predicate: (T) -> Boolean) = get(bsIndexOfLast(predicate))\ninline fun Array.bsLastOrNull(predicate: (T) -> Boolean) = getOrNull(bsIndexOfLast(predicate))\n\nconst val inf = Int.MAX_VALUE\nclass DijkHeap {\n val h = intListOf(-1)\n val pos = IntList()\n val cost = IntList()\n val map = LongIntMap(nullValue = -1)\n val keys = mutableListOf()\n\n val inHeap get() = h.lastIndex\n\n private fun swap(i: Int, j: Int) {\n val hi = h[i]; val hj = h[j]\n h[j] = hi; h[i] = hj\n pos[hi] = j; pos[hj] = i\n }\n\n fun promote(key0: BigInteger, newCost: Int): Boolean {\n val key = run {\n val hash = key0.hash()\n map[hash].let { if(it != -1) return@run it }\n keys.size.also {\n map[hash] = it\n keys.add(key0)\n h.add(it)\n pos.add(inHeap)\n cost.add(inf)\n }\n }\n if(newCost >= cost[key]) return false\n var i = pos[key]\n\n while(i > 1) {\n val par = i shr 1\n if (newCost >= cost[h[par]]) break\n swap(i, par)\n i = par\n }\n\n cost[key] = newCost\n return true\n }\n\n val head get() = h[1]\n fun isNotFinished() = inHeap > 0\n\n fun remove() = head.let { hd ->\n swap(1, inHeap)\n pos[hd] = -1\n h.pop()\n\n var i = 1\n while(true) {\n val l = i shl 1\n if(l > inHeap) break\n val r = l or 1\n\n var best = l\n var p = cost[h[l]]\n if(r <= inHeap) {\n val pr = cost[h[r]]\n if(pr < p) {\n best = r\n p = pr\n }\n }\n\n if(cost[h[i]] <= p) break\n\n swap(i, best)\n i = best\n }\n\n keys[hd]\n }\n\n fun cost(key: BigInteger): Int {\n val hash = key.hash()\n val i = map[hash]\n return if(i == -1) inf else cost[i]\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var arr = IntArray(initialCapacity)\n val _arr get() = arr\n private val capacity get() = arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n arr = arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list.arr.copyInto(arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n arr.copyInto(arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n arr.copyInto(arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Int): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Int): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }\n\n inline fun sortWith(cmp: (Int, Int) -> Int) { _mergeSort(_arr, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\n inline fun > sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\n inline fun > sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\n fun sort() { sortBy { it } }\n fun sortDescending() { sortByDescending { it } }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\ntypealias LongIntMap = _Ez_Long__Int_HashMap\ninline operator fun LongIntMap.set(key: Long, value: Int) { put(key, value) }\ninline operator fun LongIntMap.contains(key: Long) = containsKey(key)\n\nclass _Ez_Long__Int_HashMap(capacity: Int = DEFAULT_CAPACITY, val nullValue: Int = 0) :\n _Ez_Long__Int_Map {\n companion object {\n private const val DEFAULT_CAPACITY = 8\n // There are three invariants for size, removedCount and arraysLength:\n// 1. size + removedCount <= 1/2 arraysLength\n// 2. size > 1/8 arraysLength\n// 3. size >= removedCount\n// arraysLength can be only multiplied by 2 and divided by 2.\n// Also, if it becomes >= 32, it can't become less anymore.\n private const val REBUILD_LENGTH_THRESHOLD = 32\n private const val HASHCODE_INITIAL_VALUE = -0x7ee3623b\n private const val HASHCODE_MULTIPLIER = 0x01000193\n private const val FREE: Byte = 0\n private const val REMOVED: Byte = 1\n private const val FILLED: Byte = 2\n private val hashSeed = random.nextLong()\n private val gamma = random.nextLong() or 1\n }\n\n private lateinit var keys: LongArray\n private lateinit var values: IntArray\n private lateinit var status: ByteArray\n override var size = 0\n private set\n private var removedCount = 0\n private var mask = 0\n\n constructor(map: _Ez_Long__Int_Map) : this(map.size) {\n val it = map.iterator()\n while (it.hasNext()) {\n put(it.key, it.value)\n it.next()\n }\n }\n\n constructor(javaMap: Map) : this(javaMap.size) {\n for ((key, value) in javaMap) {\n put(key, value)\n }\n }\n\n private fun getStartPos(h: Long): Int {\n var x = (h xor hashSeed) * gamma\n x = (x xor (x ushr 30)) * -4658895280553007687\n x = (x xor (x ushr 27)) * -7723592293110705685\n return (x xor (x ushr 31)).toInt() and mask\n }\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun containsKey(\n key: Long\n ): Boolean {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return true\n }\n pos = pos + 1 and mask\n }\n return false\n }\n\n override fun get(\n key: Long\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return values[pos]\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun put(\n key: Long,\n value: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] == FILLED) {\n if (keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n if (status[pos] == FREE) {\n status[pos] = FILLED\n keys[pos] = key\n values[pos] = value\n size++\n if ((size + removedCount) * 2 > keys.size) {\n rebuild(keys.size * 2) // enlarge the table\n }\n return nullValue\n }\n val removedPos = pos\n pos = pos + 1 and mask\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n status[removedPos] = FILLED\n keys[removedPos] = key\n values[removedPos] = value\n size++\n removedCount--\n return nullValue\n }\n\n override fun remove(\n key: Long\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val removedValue = values[pos]\n status[pos] = REMOVED\n size--\n removedCount++\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n if (8 * size <= keys.size) {\n rebuild(keys.size / 2) // compress the table\n } else if (size < removedCount) {\n rebuild(keys.size) // just rebuild the table\n }\n }\n return removedValue\n }\n pos = pos + 1 and mask\n }\n return nullValue\n }\n\n override fun clear() {\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n initEmptyTable(REBUILD_LENGTH_THRESHOLD)\n } else {\n status.fill(FREE)\n size = 0\n removedCount = 0\n }\n }\n\n override fun keys(): LongArray {\n val result = LongArray(size)\n var i = 0\n var j = 0\n while (i < keys.size) {\n if (status[i] == FILLED) {\n result[j++] = keys[i]\n }\n i++\n }\n return result\n }\n\n override fun values(): IntArray {\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < values.size) {\n if (status[i] == FILLED) {\n result[j++] = values[i]\n }\n i++\n }\n return result\n }\n\n override fun iterator(): _Ez_Long__Int_MapIterator {\n return _Ez_Long__Int_HashMapIterator()\n }\n\n private fun rebuild(newLength: Int) {\n val oldKeys = keys\n\n val oldValues = values\n val oldStatus = status\n initEmptyTable(newLength)\n for (i in oldKeys.indices) {\n if (oldStatus[i] == FILLED) {\n put(oldKeys[i], oldValues[i])\n }\n }\n }\n\n private fun initEmptyTable(length: Int) {\n keys = LongArray(length)\n values = IntArray(length)\n status = ByteArray(length)\n size = 0\n removedCount = 0\n mask = length - 1\n }\n\n fun contentEquals(that: _Ez_Long__Int_HashMap): Boolean {\n if (size != that.size) {\n return false\n }\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n val thatValue = that[keys[i]]\n if (thatValue != values[i]) {\n return false\n }\n }\n }\n return true\n }\n\n override fun toString(): String {\n val sb = StringBuilder()\n sb.append('{')\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n if (sb.length > 1) {\n sb.append(\", \")\n }\n sb.append(keys[i])\n sb.append('=')\n sb.append(values[i])\n }\n }\n sb.append('}')\n return sb.toString()\n }\n\n private inner class _Ez_Long__Int_HashMapIterator : _Ez_Long__Int_MapIterator {\n private var curIndex = 0\n override fun hasNext(): Boolean {\n return curIndex < status.size\n }\n\n\n override val key: Long\n\n get() {\n if (curIndex == keys.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return keys[curIndex]\n }\n\n\n override val value: Int\n\n get() {\n if (curIndex == values.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return values[curIndex]\n }\n\n override fun next() {\n if (curIndex == status.size) {\n return\n }\n curIndex++\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n\n init {\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n }\n\n init {\n require(capacity >= 0) { \"Capacity must be non-negative\" }\n val length = Integer.highestOneBit(4 * max(1, capacity) - 1)\n // Length is a power of 2 now\n initEmptyTable(length)\n }\n}\n\ninterface _Ez_Long__Int_Map {\n\n val size: Int\n\n fun isEmpty(): Boolean\n\n fun containsKey(\n key: Long\n ): Boolean\n\n operator fun get(\n key: Long\n ): Int\n\n fun put(\n key: Long,\n value: Int\n ): Int\n\n fun remove(\n key: Long\n ): Int\n\n fun clear()\n\n fun keys(): LongArray\n\n fun values(): IntArray\n\n operator fun iterator(): _Ez_Long__Int_MapIterator\n\n override fun toString(): String\n}\n\ninterface _Ez_Long__Int_MapIterator {\n operator fun hasNext(): Boolean\n\n val key: Long\n\n val value: Int\n\n operator fun next()\n}\n\ninline fun LongIntMap.forEach(act: (key: Long, value: Int) -> Unit) {\n val ite = iterator()\n while(ite.hasNext()) {\n act(ite.key, ite.value)\n ite.next()\n }\n}\n\n/** IO */\n//@JvmField val ONLINE_JUDGE = System.getProperty(\"ONLINE_JUDGE\") != null\n//const val PATH = \"src/main/resources/\"\n//@JvmField val INPUT = File(PATH + \"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(PATH + \"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar() else c\n }\n}\n\n/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */\nfun readCharArray(n: Int, skipNext: Boolean = true): CharArray {\n val res = CharArray(n) { readChar() }\n if(skipNext) readChar()\n return res\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** sort overrides to avoid quicksort attacks */\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\ninline fun _mergeSort(a0: A, n: Int, tmp0: A, get: A.(Int) -> T, set: A.(Int, T) -> Unit, cmp: (T, T) -> Int) {\n var a = a0\n var tmp = tmp0\n var len = 1\n while(len < n) {\n var l = 0\n while(true) {\n val m = l + len\n if(m >= n) break\n val r = min(n, m + len)\n var i = l\n var j = m\n for(k in l until r) {\n if(i != m && (j == r || cmp(a.get(i), a.get(j)) <= 0)) {\n tmp.set(k, a.get(i++))\n } else tmp.set(k, a.get(j++))\n }\n l = r\n }\n for(i in l until n) tmp.set(i, a.get(i))\n val t = a; a = tmp; tmp = t\n len += len\n }\n if(a !== a0) for(i in 0 until n) a0.set(i, tmp0.get(i))\n}\n\ninline fun IntArray.sortWith(cmp: (Int, Int) -> Int) { _mergeSort(this, size, IntArray(size), IntArray::get, IntArray::set, cmp) }\ninline fun > IntArray.sortBy(func: (Int) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > IntArray.sortByDescending(func: (Int) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun IntArray.sort() { sortBy { it } }\nfun IntArray.sortDescending() { sortByDescending { it } }\n\ninline fun LongArray.sortWith(cmp: (Long, Long) -> Int) { _mergeSort(this, size, LongArray(size), LongArray::get, LongArray::set, cmp) }\ninline fun > LongArray.sortBy(func: (Long) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > LongArray.sortByDescending(func: (Long) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun LongArray.sort() { sortBy { it } }\nfun LongArray.sortDescending() { sortByDescending { it } }\n\ninline fun DoubleArray.sortWith(cmp: (Double, Double) -> Int) { _mergeSort(this, size, DoubleArray(size), DoubleArray::get, DoubleArray::set, cmp) }\ninline fun > DoubleArray.sortBy(func: (Double) -> T) { sortWith { a, b -> func(a).compareTo(func(b)) } }\ninline fun > DoubleArray.sortByDescending(func: (Double) -> T) { sortWith { a, b -> func(b).compareTo(func(a)) } }\nfun DoubleArray.sort() { sortBy { it } }\nfun DoubleArray.sortDescending() { sortByDescending { it } }\n\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\n// import preserving junk function\n@Suppress(\"NonAsciiCharacters\") fun \u96ea\u82b1\u98c4\u98c4\u5317\u98a8\u562f\u562f\u5929\u5730\u4e00\u7247\u84bc\u832b() { iprintln(max(1, 2)) }\n\nfun IntArray.sumLong() = sumOf { it.toLong() }\n\nfun IntArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun IntArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun LongArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun LongArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun DoubleArray.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun DoubleArray.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > Array.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > Array.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\nfun > List.sortedIndices() = IntArray(size) { it }.also { it.sortBy(::get) }\nfun > List.sortedIndicesDescending() = IntArray(size) { it }.also { it.sortByDescending(::get) }\n\n// max/min Kotlin 1.6 -> 1.4 shim\nfun IntArray.max() = maxOf { it }\nfun IntArray.min() = minOf { it }\nfun LongArray.max() = maxOf { it }\nfun LongArray.min() = minOf { it }\nfun CharArray.max() = maxOf { it }\nfun CharArray.min() = minOf { it }\nfun > Iterable.max() = maxOf { it }\nfun > Iterable.min() = minOf { it }\nfun > Sequence.max() = maxOf { it }\nfun > Sequence.min() = minOf { it }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2c40acd7ce02f315ba6cd61d9d7d763d", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main(args: Array) {\n val a = readLine()!!.splitToIntArray().toRect()\n val b = readLine()!!.splitToIntArray().toRect()\n val h = (b.x1 - b.x0) / 2\n val s0 = b.x1 + b.y0 - h\n val s1 = b.x1 + b.y0 + h\n val d0 = b.x0 - b.y0 - h\n val d1 = b.x0 - b.y0 + h\n for (x in a.x0..a.x1) {\n for (y in a.y0..a.y1) {\n if ((x + y) in s0..s1 && (x - y) in d0..d1) {\n println(\"YES\")\n return\n }\n }\n }\n println(\"NO\")\n}\n\nfun IntArray.toRect(): Rect {\n var x0 = Int.MAX_VALUE\n var x1 = Int.MIN_VALUE\n var y0 = Int.MAX_VALUE\n var y1 = Int.MIN_VALUE\n for (i in 0..3) {\n x0 = min(get(2 * i), x0)\n x1 = max(get(2 * i), x1)\n y0 = min(get(2 * i + 1), y0)\n y1 = max(get(2 * i + 1), y1)\n }\n return Rect(x0, x1, y0, y1)\n}\n\nclass Rect(val x0: Int, val x1: Int, val y0: Int, val y1: Int)\n\nprivate fun String.splitToIntArray(): IntArray {\n val n = length\n if (n == 0) return IntArray(0) // EMPTY\n var res = IntArray(4)\n var m = 0\n var i = 0\n while (true) {\n var cur = 0\n var neg = false\n var c = get(i) // expecting number, IOOB if there is no number\n if (c == '-') {\n neg = true\n i++\n c = get(i) // expecting number, IOOB if there is no number\n }\n while (true) {\n val d = c.toInt() - '0'.toInt()\n require(d >= 0 && d <= 9) { \"Unexpected character '$c' at $i\" }\n require(cur >= Integer.MIN_VALUE / 10) { \"Overflow at $i\" }\n cur = cur * 10 - d\n require(cur <= 0) { \"Overflow at $i\" }\n i++\n if (i >= n) break\n c = get(i)\n if (c == ' ') break\n }\n if (m >= res.size) res = res.copyOf(res.size * 2)\n res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { \"Overflow at $i\" } }\n if (i >= n) break\n i++\n }\n if (m < res.size) res = res.copyOf(m)\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8797b831443cb67cc20dcc78bcd5370a", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLine()!!.toInt()\n\nvar FF = MutableList>(21) { _ -> MutableList(1_000_001) { _->-1L}}\nvar FF3 = MutableList>(21) {_-> MutableList(1_000_001) {_->-1L}}\nvar n = 0\nvar k = 0\n\nfun F3(q:Int, w:Int) : Long {\n if (q < 0 || w < 0 || q > FF3.size || w > FF3[q].size) {\n println(\"$q $w\")\n return 0\n }\n if (FF3[q][w] == -1L) {\n if (q >= k - 1 || w > n / (3 shl q) || w == 0) {\n FF3[q][w] = 0\n return 0\n }\n FF3[q][w] = F3(q+1, w-1)*(n / (3 shl q) - n / (3 shl (q+1))) + F3(q, w-1)*(n / (3 shl q) - w + 1)\n FF3[q][w] = FF3[q][w]%1_000_000_007\n }\n return FF3[q][w]\n}\n\nfun F(q:Int, w:Int) : Long {\n if (FF[q][w] == -1L) {\n if (q >= k || w > n / (1 shl q) || w == 0) {\n FF[q][w] = 0\n return 0\n }\n FF[q][w] = F3(q, w-1)*(n / (1 shl q) - n / (3 shl q)) + F(q+1, w-1)*(n / (1 shl q) - n / (1 shl (q+1))) + F(q, w-1)*(n / (1 shl q) - w + 1)\n FF[q][w] = FF[q][w] % 1_000_000_007\n }\n return FF[q][w]\n}\n\nfun main() {\n n = readInt()\n k = 1\n while (n >= (1 shl k)) k++\n k--\n if (k > 0 && n >= (1 shl (k-1))*3) FF3[k-1][1] = 1\n FF[k][1] = 1\n println(F(0, n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dd0906408a57163965531bb300e97c62", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLine()!!.toInt()\n\nvar FF = MutableList>(21) { _ -> MutableList(1_000_000) { _->-1L}}\nvar FF3 = MutableList>(21) {_-> MutableList(1_000_000) {_->-1L}}\nvar n = 0\nvar k = 0\n\nfun F3(q:Int, w:Int) : Long {\n if (FF3[q][w] == -1L) {\n if (q >= k - 1 || w > n / (3 shl q) || w == 0) {\n FF3[q][w] = 0\n return 0\n }\n FF3[q][w] = F3(q+1, w-1)*(n / (3 shl q) - n / (3 shl (q+1))) + F3(q, w-1)*(n / (3 shl q) - w + 1)\n FF3[q][w] = FF3[q][w]%1_000_000_007\n }\n return FF3[q][w]\n}\n\nfun F(q:Int, w:Int) : Long {\n if (FF[q][w] == -1L) {\n if (q >= k || w > n / (1 shl q) || w == 0) {\n FF[q][w] = 0\n return 0\n }\n FF[q][w] = F3(q, w-1)*(n / (1 shl q) - n / (3 shl q)) + F(q+1, w-1)*(n / (1 shl q) - n / (1 shl (q+1))) + F(q, w-1)*(n / (1 shl q) - w + 1)\n FF[q][w] = FF[q][w] % 1_000_000_007\n }\n return FF[q][w]\n}\n\nfun main() {\n n = readInt()\n k = 1\n while (n >= (1 shl k)) k++\n k--\n if (k > 0 && n >= (1 shl (k-1))*3) FF3[k-1][1] = 1\n FF[k][1] = 1\n println(F(0, n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cfd4affa510e7ab14dc9ae5741b0d719", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "const val MOD = 1000000007L\n\nfun main() {\n val n = readLine()!!.toInt()\n val factorial = LongArray(n + 1)\n factorial[0] = 1L\n for (j in 1..n) {\n factorial[j] = (j.toLong() * factorial[j - 1]) % MOD\n }\n val factInv = LongArray(n + 1) { factorial[it] pow -1 }\n fun permute(a: Int, b: Int) = (factorial[a] * factInv[b]) % MOD\n fun arrange(a: Int, b: Int): Long {\n val here = n / a\n val above = here / b\n return ((here - above).toLong() * permute(n - above - 1, n - here)) % MOD\n }\n var lg = 0\n while (1 shl lg <= n) {\n lg++\n }\n lg--\n var curr = 1L\n for (e in 0..lg) {\n curr *= arrange(1 shl e, 2)\n curr %= MOD\n }\n var answer = curr\n if (n >= 3 * (1 shl (lg - 1))) {\n for (e in lg downTo 1) {\n curr *= arrange(1 shl e, 3) pow -1\n curr %= MOD\n curr *= arrange(3 * (1 shl (e - 1)), 2)\n curr %= MOD\n curr *= arrange(1 shl (e - 1), 2) pow -1\n curr %= MOD\n curr *= arrange(1 shl (e - 1), 3)\n curr %= MOD\n answer += curr\n }\n answer %= MOD\n }\n println(answer)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "42920e8b397e489369a14496396fafb4", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLine()!!.toInt()\n\nvar FF = MutableList>(21) { _ -> MutableList(1_000_001) { _->-1L}}\nvar FF3 = MutableList>(21) {_-> MutableList(1_000_001) {_->-1L}}\nvar n = 0\nvar k = 0\n\nfun F3(q:Int, w:Int) : Long {\n if (FF3[q][w] == -1L) {\n if (q >= k - 1 || w > n / (3 shl q) || w == 0) {\n FF3[q][w] = 0\n return 0\n }\n FF3[q][w] = F3(q+1, w-1)*(n / (3 shl q) - n / (3 shl (q+1))) + F3(q, w-1)*(n / (3 shl q) - w + 1)\n FF3[q][w] = FF3[q][w]%1_000_000_007\n }\n return FF3[q][w]\n}\n\nfun F(q:Int, w:Int) : Long {\n if (FF[q][w] == -1L) {\n if (q >= k || w > n / (1 shl q) || w == 0) {\n FF[q][w] = 0\n return 0\n }\n FF[q][w] = F3(q, w-1)*(n / (1 shl q) - n / (3 shl q)) + F(q+1, w-1)*(n / (1 shl q) - n / (1 shl (q+1))) + F(q, w-1)*(n / (1 shl q) - w + 1)\n FF[q][w] = FF[q][w] % 1_000_000_007\n }\n return FF[q][w]\n}\n\nfun main() {\n n = readInt()\n k = 1\n while (n >= (1 shl k)) k++\n k--\n if (k > 0 && n >= (1 shl (k-1))*3) FF3[k-1][1] = 1\n FF[k][1] = 1\n for(i in k downTo 0) for(j in 0 .. (n / (3 shl i))) F3(i, j)\n for(i in k downTo 0) for(j in 0 .. (n / (1 shl i))) F(i, j)\n println(F(0, n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0317d0010474c7c7f0dc00f31e7b68b5", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "const val MOD = 1000000007L\n\nfun main() {\n val n = readLine()!!.toInt()\n val inv = LongArray(n + 1) { it.toLong() pow -1 }\n val factorial = LongArray(n + 1)\n val factInv = LongArray(n + 1)\n factorial[0] = 1L\n factInv[0] = 1L\n for (j in 1..n) {\n factorial[j] = (j.toLong() * factorial[j - 1]) % MOD\n factInv[j] = (inv[j] * factInv[j - 1]) % MOD\n }\n fun permute(a: Int, b: Int) = (factorial[a] * factInv[b]) % MOD\n fun arrange(a: Int, b: Int): Long {\n val here = n / a\n val above = here / b\n return ((here - above).toLong() * permute(n - above - 1, n - here)) % MOD\n }\n fun arrangeInv(a: Int, b: Int): Long {\n val here = n / a\n val above = here / b\n return (inv[here - above] * permute(n - here, n - above - 1)) % MOD\n }\n var lg = 0\n while (1 shl lg <= n) {\n lg++\n }\n lg--\n var curr = 1L\n for (e in 0..lg) {\n curr *= arrange(1 shl e, 2)\n curr %= MOD\n }\n var answer = curr\n if (n >= 3 * (1 shl (lg - 1))) {\n for (e in lg downTo 1) {\n curr *= arrangeInv(1 shl e, 3)\n curr %= MOD\n curr *= arrange(3 * (1 shl (e - 1)), 2)\n curr %= MOD\n curr *= arrangeInv(1 shl (e - 1), 2)\n curr %= MOD\n curr *= arrange(1 shl (e - 1), 3)\n curr %= MOD\n answer += curr\n }\n answer %= MOD\n }\n println(answer)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "44c207bbf72972468a5484ccde42b00e", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "private fun readInt() = readLine()!!.toInt()\n\nvar FF = MutableList>(21) { _ -> MutableList(1_000_000) { _->-1L}}\nvar FF3 = MutableList>(21) {_-> MutableList(1_000_000) {_->-1L}}\nvar n = 0\nvar k = 0\n\nfun F3(q:Int, w:Int) : Long {\n if (FF3[q][w] == -1L) {\n if (q >= k - 1 || w > n / (3 shl q) || w == 0) {\n FF3[q][w] = 0\n return 0\n }\n FF3[q][w] = F3(q+1, w-1)*(n / (3 shl q) - n / (3 shl (q+1))) + F3(q, w-1)*(n / (3 shl q) - w + 1)\n FF3[q][w] = FF3[q][w]%1_000_000_009\n }\n return FF3[q][w]\n}\n\nfun F(q:Int, w:Int) : Long {\n if (FF[q][w] == -1L) {\n if (q >= k || w > n / (1 shl q) || w == 0) {\n FF[q][w] = 0\n return 0\n }\n FF[q][w] = F3(q, w-1)*(n / (1 shl q) - n / (3 shl q)) + F(q+1, w-1)*(n / (1 shl q) - n / (1 shl (q+1))) + F(q, w-1)*(n / (1 shl q) - w + 1)\n FF[q][w] = FF[q][w] % 1_000_000_009\n }\n return FF[q][w]\n}\n\nfun main() {\n n = readInt()\n k = 1\n while (n >= (1 shl k)) k++\n k--\n if (k > 0 && n >= (1 shl (k-1))*3) FF3[k-1][1] = 1\n FF[k][1] = 1\n println(F(0, n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "374503caa677d5b09891996b22809ebf", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "const val MOD = 1000000007L\n\nfun main() {\n val n = readLine()!!.toInt()\n val factorial = LongArray(n + 1)\n factorial[0] = 1L\n for (j in 1..n) {\n factorial[j] = (j.toLong() * factorial[j - 1]) % MOD\n }\n val factInv = LongArray(n + 1) { factorial[it] pow -1 }\n fun permute(a: Int, b: Int) = if (b < 0L || b > a) 0L else ((factorial[a] * factInv[b]) % MOD)\n fun arrange(a: Int, b: Int): Long {\n val here = n / a\n val above = here / b\n return ((here - above).toLong() * permute(n - above - 1, n - here)) % MOD\n }\n var lg = 0\n while (1 shl lg <= n) {\n lg++\n }\n lg--\n var curr = factorial[n - (n / 2)]\n for (e in 1..lg) {\n curr *= arrange(1 shl e, 2)\n }\n var answer = curr\n if (n >= 3 * (1 shl (lg - 1))) {\n for (e in lg downTo 1) {\n curr *= arrange(1 shl e, 3) pow -1\n curr %= MOD\n curr *= arrange(3 * (1 shl (e - 1)), 2)\n curr %= MOD\n if (e > 1) {\n curr *= arrange(1 shl (e - 1), 2) pow -1\n curr %= MOD\n curr *= arrange(1 shl (e - 1), 3)\n curr %= MOD\n } else {\n curr *= factInv[n - (n / 2)]\n curr %= MOD\n curr *= factorial[n - (n / 3)]\n curr %= MOD\n }\n answer += curr\n }\n answer %= MOD\n }\n println(answer)\n}\n\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this % MOD\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4171b7d7b1c56a7092f3a5a084a2fe4a", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "fun nextLn() = readLine()!!\nfun nextInt() = nextLn().toInt()\nfun nextStrings() = nextLn().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\n\nvar mod = 998244353\n\nfun main(args: Array) {\n var (n, m) = nextInts()\n var a = MutableList>(456789) {ArrayList()}\n var cntk = nextInts().toMutableList()\n for (i in 1 .. m) {\n var (d, t) =nextInts()\n a[d].add(t - 1)\n }\n fun check(d : Int) : Boolean {\n var money = 0\n var cnt = cntk.toMutableList()\n var lastd = MutableList(n) {d + 1}\n for (i in 1 .. d) {\n for (k in a[i]) {\n lastd[k] = i\n }\n }\n for (i in 1 .. d) {\n money += 1\n for (k in a[i]) {\n if (lastd[k] != i)\n continue\n var c = minOf(cnt[k], money)\n cnt[k] -= c\n money -= c\n }\n }\n for (i in 0 .. n-1) {\n money -= 2 * cnt[i]\n }\n return money >= 0\n }\n var l = 0\n var r = 400001\n while (l + 1 < r) {\n var mid = (l + r) / 2\n if (check(mid)) \n r = mid\n else\n l = mid\n }\n println(r)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7566be2d0a8558d64eada742001dc19f", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeSet\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\nfun main() {\n output {\n val n = readInt()\n val m = readInt()\n val K = readIntArray(n)\n\n val offers = MutableList(m) { Offer(readInt(), readInt() - 1) }\n offers.sortByDescending { it.day }\n\n val ksum = K.sum()\n\n val ans = (ksum..2 * ksum).bsFirst { lastDay ->\n val sub = offers.subList(offers.indices.bsFirst { offers[it].day <= lastDay }, m)\n .distinctBy { it.type }\n .asReversed()\n\n var krem = ksum\n var currDay = 0\n var money = 0\n\n for ((day, type) in sub) {\n money += day - currDay\n currDay = day\n\n val bought = min(money, K[type])\n money -= bought\n krem -= bought\n }\n\n money += lastDay - currDay\n money >= krem * 2\n }\n\n println(ans)\n }\n}\n\ndata class Offer(val day: Int, val type: Int)\n\nfun IntRange.bsFirst(predicate: (Int) -> Boolean): Int {\n var low = start\n var high = endInclusive\n\n while (low <= high) {\n val mid = low.and(high) + low.xor(high).shr(1)\n if(predicate(mid)) high = mid - 1\n else low = mid + 1\n }\n return low\n}\n\ninline fun IntRange.bsLast(crossinline predicate: (Int) -> Boolean) =\n bsFirst{ !predicate(it) } - 1\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "23e2fc657d818f9c0c4e536eb0a35c7f", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\nclass UnionFind(n: Int) {\n private val par = IntArray(n){it}\n val rank = IntArray(n){1} // \u96c6\u5408\u306e\u8981\u7d20\u6570\n private val visits = IntArray(n) // \u8a2a\u308c\u305f\u5834\u6240\u3092find\u6bce\u306b\u7528\u610f\u3059\u308b\u306e\u304c\u3082\u3063\u305f\u3044\u306a\u3044\u306e\u3067\u3064\u304b\u3044\u307e\u308f\u3059\n\n fun find(x: Int): Int {\n var ptr = 0\n var i = x\n while(par[i] != i) {\n visits[ptr++] = i\n i = par[i]\n }\n\n for (j in 0 until ptr) {\n par[visits[j]] = i\n }\n return i\n }\n\n private fun merge(node: Int, rt: Int): Int {\n par[node] = rt\n rank[rt] += rank[node]\n return rt\n }\n\n fun unite(x: Int, y: Int): Boolean {\n val x1 = find(x)\n val y1 = find(y)\n return if (x1 == y1) false\n else {\n if (rank[x1] < rank[y1])\n merge(x1, y1)\n else\n merge(y1, x1)\n\n true\n }\n }\n\n fun isRoot(x: Int) = par[x] == x\n\n /**\n * x\u3092\u89e3\u6c7a\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3068\u304d\u306f\u76f4\u306brank\u3092\u307f\u308b\n */\n fun cntNodes(x: Int): Int = rank[find(x)]\n}\nfun lowerBound(A: LongArray, s: Int, x: Long): Int {\n var l = s - 1\n var h = A.size\n while(h - l > 1) {\n val m = (h + l) / 2\n if (A[m] >= x) h = m\n else l = m\n }\n return h\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n var K = nl() - 1\n val INF = 1e18.toLong() + 10\n val dp = LongArray(N + 10)\n dp[0] = 1\n for (n in 1 .. N) {\n var sum = 0L\n for (i in 1 .. n) {\n if (i > 1) {\n val uf = UnionFind(i)\n for (j in 0 until i) {\n uf.unite(j, i - 1 - j)\n }\n if (uf.cntNodes(0) != i) continue\n }\n\n sum += dp[n - i]\n if (sum >= INF) sum = INF\n }\n dp[n] = sum\n }\n debug(dp)\n\n val part = mutableListOf()\n var n = N\n while(n > 0) {\n val nums = LongArray(n + 1)\n for (i in 1 .. n) {\n nums[i] = dp[n - i]\n }\n for (i in 1 .. n) {\n nums[i] += nums[i - 1]\n if (nums[i] >= INF) nums[i] = INF\n }\n\n debug(nums)\n val num = lowerBound(nums, 0, K + 1)\n debug{\"K:$K num:$num\"}\n part += num\n n -= num\n K -= nums[num - 1]\n }\n\n debug{part.joinToString(\" \")}\n val ans = mutableListOf()\n var l = 0\n for (p in part) {\n for (i in l + p downTo l + 1) {\n ans.add(i)\n }\n l += p\n }\n\n out.println(ans.joinToString(\" \"))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "72c4fe3293f30b646fede2fef39bc285", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n var x = scanner.nextLong()\n var y = scanner.nextLong()\n val m = scanner.nextLong()\n\n if (x + y <= 0) {\n if (checkExcellent(x, y, m)) {\n System.out.println(0)\n } else {\n System.out.println(-1)\n }\n return\n }\n\n var ans: Long = 0\n\n while (true) {\n if (x= m\n}\n\n\nenum class Type {\n OPEN, CLOSE\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "127ad7ad1ccb67b029e404486bff04ba", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n var x = scanner.nextLong()\n var y = scanner.nextLong()\n val m = scanner.nextLong()\n\n if (x <= 0 && y <= 0) {\n if (checkExcellent(x, y, m)) {\n System.out.println(0)\n } else {\n System.out.println(-1)\n }\n return\n }\n\n var ans: Long = 0\n\n while (true) {\n if (x= m\n}\n\n\nenum class Type {\n OPEN, CLOSE\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "db8c577a8feb765b8e0aec8d25679ce0", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n var x = scanner.nextLong()\n var y = scanner.nextLong()\n val m = scanner.nextLong()\n\n if (checkExcellent(x, y, m)) {\n System.out.println(0)\n return\n }\n\n if (x <= 0 && y <= 0) {\n// if (checkExcellent(x, y, m)) {\n// System.out.println(0)\n// } else {\n System.out.println(-1)\n// }\n return\n }\n\n if (x < y) {\n val temp = x\n x = y\n y = temp\n }\n\n var ans: Long = 0\n\n //System.out.println(\"$x $y\")\n\n if (y < 0) {\n val tmp = x - y\n ans += tmp / x\n y += ans * x\n }\n\n if (checkExcellent(x, y, m)) {\n System.out.println(ans)\n return\n }\n\n while (true) {\n if (x < y) {\n x += y\n ans++\n if (checkExcellent(x, y, m)) {\n System.out.println(ans)\n return\n }\n } else {\n y += x\n ans++\n if (checkExcellent(x, y, m)) {\n System.out.println(ans)\n return\n }\n }\n }\n\n\n}\n\nfun checkExcellent(x: Long, y: Long, m: Long): Boolean {\n return Math.max(x, y) >= m\n}\n\n\nenum class Type {\n OPEN, CLOSE\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a08da3c0ce4c11b465ffa1d261f846ca", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.ceil\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val (x, y, m) = readStrings().map { it.toLong() }\n\n var biggest = max(x, y)\n if (biggest >= m) println(0)\n else if (biggest < m && biggest <= 0) println(-1)\n else {\n var smallest = min(x, y)\n var moves = 0L\n if (smallest < 0) {\n moves = ceil(-smallest.toDouble()/biggest).toLong()\n smallest += moves * biggest\n }\n\n while (max(smallest, biggest) < m) {\n biggest = max(smallest, biggest)\n smallest = min(smallest, biggest)\n// println(\"$biggest $smallest $moves\")\n smallest = biggest.also { biggest += smallest }\n moves++\n }\n println(moves)\n }\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7512518b57ea4c85719931cb3aaea51c", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\n\nfun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val len = r.readLine()!!.toInt()\n val (a, b) = r.readLine()!!.split(\" \").map { it.toInt() }\n var q = 0\n var w = 0\n var e = 0\n (1..6).forEach {\n when{\n abs(a-it)< abs(b-it) -> q++\n abs(a-it)== abs(b-it) -> w++\n abs(a-it)> abs(b-it) -> e++\n }\n }\n println(\"$q $w $e\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f603a6fd5c3c5c9f699ea48dbedb18ca", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\nimport kotlin.math.abs\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readDouble() = readLn().toDouble() // single double\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\n\n\nfun main(args: Array) {\n val(a,b)=readInts()\n var x=0\n var y=0\n var z=0\n\n for(dice in 1..6) {\n if(abs(dice-a)abs(dice-b))y++\n else z++\n }\n\n println(\"$x $z $y\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f5e0c540d6aecdeb3c289e73626165d7", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.abs\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val a = nextInt()\n val b = nextInt()\n var res = IntArray(3)\n repeat(6) {\n when {\n abs(a - (it + 1)) < abs(b - (it + 1)) -> res[0]++\n abs(a - (it + 1)) > abs(b - (it + 1)) -> res[2]++\n else -> res[1]++\n }\n }\n res.forEach { s -> print(\"$s \") }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e26cbdb2f1f0e12ec617aca61b8d894c", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (a, b) = readInts()\n var first = 0\n var second = 0\n for (result in 1..6) {\n when {\n abs(a - result) < abs(b - result) -> first++\n abs(a - result) > abs(b - result) -> second++\n }\n }\n print(\"$first ${6 - first - second} $second\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ab3edeb87a2b8566adc53df6f47b9c8e", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main(args: Array) = with(java.util.Scanner(System.`in`)) {\n var a = nextInt()\n var b = nextInt()\n var win = 0\n var draw = 0\n var lose = 0\n for( i in 1..6){\n if(abs(a-i) == abs(i-b))draw++\n else if(abs(a-i)>abs(i-b))lose++\n else win++\n }\n println(\"$win $draw $lose\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0964b7cebba42769857f4e80df2c63cf", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main(args: Array ) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n var b = sc.nextInt()\n val p = ArrayList()\n val d = ArrayList()\n var i = 1\n while ( ++ i * i <= b ) {\n if ( b % i != 0 ) continue\n p.add( i )\n var deg = 0\n while ( b % i == 0 ) {\n deg ++\n b /= i\n }\n d.add( deg )\n }\n if ( b > 1 ) {\n p.add( b )\n d.add( 1 )\n }\n\n var r = n\n for ( j in p.indices ) {\n var deg = 0L\n var t = n\n while ( t > 0 ) {\n t /= p[j]\n deg += t\n }\n r = Math.min( r, deg / d[j] )\n }\n\n println( r )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b77ee0ecd3d15d47f0f248da8e5e97a2", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nclass Pair(val p: Int,val x: Int,var y: Int)\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val b = sc.nextInt()\n val pairs = arrayListOf()\n var j = 2\n var m = b\n\n var times = 0\n while (j <= m){\n if (m%j==0){\n m /= j\n times++\n }else{\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n j++\n times = 0\n }\n }\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n\n var min = Int.MAX_VALUE\n for(pair in pairs){\n m = n\n while (m>0){\n pair.y += m/pair.p\n m /= pair.p\n }\n if (min > pair.y/pair.x){\n min = pair.y/pair.x\n }\n }\n print(min)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "865b61cc5b79954eec1a16a4b5ab9d83", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nclass Pair(val p: Int,val x: Int,var y: Int)\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val b = sc.nextInt()\n val pairs = arrayListOf()\n var j = 2\n var m = b\n\n var times = 0\n while (j <= m){\n if (m%j==0){\n m /= j\n times++\n }else{\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n j++\n times = 0\n }\n }\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n\n var min = 0\n for(pair in pairs){\n m = n\n while (m>0){\n pair.y += m/pair.p\n m /= pair.p\n }\n if (min > pair.y/pair.x){\n min = pair.y/pair.x\n }\n }\n print(min)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "18bee1b023be3446faad6fb1ed3ade77", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nclass Pair(val p: Int,val x: Int,var y: Int)\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val b = sc.nextInt()\n val pairs = arrayListOf()\n var j = 2\n var m = b\n\n var times = 0\n while (j <= m){\n if (m%j==0){\n m /= j\n times++\n }else{\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n j++\n times = 0\n }\n }\n if (times > 0){\n pairs.add(Pair(j,times,0))\n }\n\n var min = Int.MIN_VALUE\n for(pair in pairs){\n m = n\n while (m>0){\n pair.y += m/pair.p\n m /= pair.p\n }\n if (min > pair.y/pair.x){\n min = pair.y/pair.x\n }\n }\n print(min)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d471b662e1dd2c36319d96c7faa65f33", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main() {\n val (n, b) = readLine()!!.split(' ').map { it.toLong() }\n var ans = Long.MAX_VALUE\n factor(b) { p, k ->\n ans = min(ans, pp(n, p) / k)\n }\n println(ans)\n}\n\nfun factor(x: Long, op: (p: Long, k: Int) -> Unit) {\n var rem = x\n var p = 2L\n while (p * p <= rem) {\n var k = 0\n while (rem % p == 0L) {\n rem /= p\n k++\n }\n if (k > 0) op(p, k)\n p++\n }\n if (rem > 1) op(rem, 1)\n}\n\nfun pp(n: Long, p: Long): Long {\n var ans = 0L\n var cur = p\n while (cur <= n) {\n ans += n / cur\n if (cur > (n + p - 1) / p) break\n cur *= p\n }\n return ans\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "66ebbb334bc0b5230cb7ccc290a3a4f9", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main() {\n val tokenizer = BufferedReader(InputStreamReader(System.`in`)).use { StringTokenizer(it.readText()) }\n val n = tokenizer.nextLong()\n var b = tokenizer.nextLong()\n var ans: Long? = null\n for (i in 2..Math.sqrt(b.toDouble()).toLong()) {\n var c = 0\n while (b % i == 0L) {\n b /= i\n c++\n }\n if (c > 0) {\n val t = count(n, i) / c\n if (ans == null || ans > t) ans = t\n }\n }\n if (b > 1L) {\n val t = count(n, b)\n if (ans == null || ans > t) ans = t\n }\n println(ans)\n}\n\nfun count(n: Long, b: Long): Long {\n var t = n\n var ans = 0L\n while (t >= b) {\n t /= b\n ans += t\n }\n return ans\n}\n\nfun StringTokenizer.nextInt() = nextToken().toInt()\nfun StringTokenizer.nextLong() = nextToken().toLong()\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e715cbbbaa801e636988324de5d2fe0d", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "var n:Int=0\nvar arr=Array(5){tuple(0,0,0)}\nfun main(args: Array){\n n= readLine()!!.toInt()\n for (i:Int in 0 until n){\n val inp=readLine()!!.split(' ')\n arr[i]=tuple(inp[0].toInt() , inp[1].toInt() , inp[2].toInt())\n }\n var ans=0\n var num_of_ans=0\n for(i:Int in 123..9876){\n if(!distinct(i)){\n continue\n }\n if(check(i)){\n ans=i\n num_of_ans++\n }\n }\n if(num_of_ans == 0){\n println(\"Incorrect data\")\n }else if(num_of_ans > 1){\n println(\"Need more data\")\n }else{\n print(ans)\n }\n}\nfun distinct(x:Int):Boolean{\n var firstX:Int=x%10\n var secondX:Int=(x%100)/10\n var thirdX:Int=(x%1000)/100\n var fourthX:Int=x/1000\n if(firstX == secondX || firstX == thirdX || firstX == fourthX\n || secondX == thirdX || secondX == fourthX || thirdX == fourthX){\n return false\n }\n return true\n}\n\nfun check(num: Int):Boolean{\n for(i:Int in 0 until n){//bulls the same pos\n if(Bulls(arr[i].x , num) != arr[i].y ||\n Cows(arr[i].x , num) != arr[i].z){\n return false\n }\n }\n return true\n}\nfun Bulls(x:Int , y:Int):Int{\n var ans:Int=0\n if(x%10 == y%10){\n ans++\n }\n if ((x%100)/10 == (y%100)/10){\n ans++\n }\n if ((x%1000)/100 == (y%1000)/100){\n ans++\n }\n if(x/1000 == y/1000){\n ans++\n }\n return ans\n}\nfun Cows(x:Int , y:Int):Int{\n var ans=0\n var firstX:Int=x%10\n var secondX:Int=(x%100)/10\n var thirdX:Int=(x%1000)/100\n var fourthX:Int=x/1000\n\n var firstY:Int=y%10\n var secondY:Int=(y%100)/10\n var thirdY:Int=(y%1000)/100\n var fourthY:Int=y/1000\n if(firstX == secondY || firstX == thirdY || firstX == fourthY){\n ans++\n }\n if(secondX == firstY || secondX == thirdY || secondX == fourthY){\n ans++\n }\n if(thirdX == secondY || thirdX == firstY || thirdX == fourthY){\n ans++\n }\n if(fourthX == secondY || fourthX == thirdY || fourthX == firstY){\n ans++\n }\n return ans\n}\nclass tuple(x:Int , y:Int , z:Int){\n var x:Int=0\n var y:Int=0\n var z:Int=0\n init{\n this.x=x\n this.y=y\n this.z=z\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8cc80bab45675a3bf8eec56cc88494b0", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "var n:Int=0\nvar arr=Array(15){tuple(0,0,0)}\nfun main(args: Array){\n n= readLine()!!.toInt()\n for (i:Int in 0 until n){\n val inp=readLine()!!.split(' ')\n arr[i]=tuple(inp[0].toInt() , inp[1].toInt() , inp[2].toInt())\n }\n var ans=0\n var num_of_ans=0\n for(i:Int in 123..9876){\n if(!distinct(i)){\n continue\n }\n if(check(i)){\n ans=i\n num_of_ans++\n }\n }\n if(num_of_ans == 0){\n println(\"Incorrect data\")\n }else if(num_of_ans > 1){\n println(\"Need more data\")\n }else{\n if(ans/1000 == 0){\n print(0)\n print(ans)\n }else {\n print(ans)\n }\n }\n}\nfun distinct(x:Int):Boolean{\n var firstX:Int=x%10\n var secondX:Int=(x%100)/10\n var thirdX:Int=(x%1000)/100\n var fourthX:Int=x/1000\n if(firstX == secondX || firstX == thirdX || firstX == fourthX\n || secondX == thirdX || secondX == fourthX || thirdX == fourthX){\n return false\n }\n return true\n}\n\nfun check(num: Int):Boolean{\n for(i:Int in 0 until n){//bulls the same pos\n if(Bulls(arr[i].x , num) != arr[i].y ||\n Cows(arr[i].x , num) != arr[i].z){\n return false\n }\n }\n return true\n}\nfun Bulls(x:Int , y:Int):Int{\n var ans:Int=0\n if(x%10 == y%10){\n ans++\n }\n if ((x%100)/10 == (y%100)/10){\n ans++\n }\n if ((x%1000)/100 == (y%1000)/100){\n ans++\n }\n if(x/1000 == y/1000){\n ans++\n }\n return ans\n}\nfun Cows(x:Int , y:Int):Int{\n var ans=0\n var firstX:Int=x%10\n var secondX:Int=(x%100)/10\n var thirdX:Int=(x%1000)/100\n var fourthX:Int=x/1000\n\n var firstY:Int=y%10\n var secondY:Int=(y%100)/10\n var thirdY:Int=(y%1000)/100\n var fourthY:Int=y/1000\n if(firstX == secondY || firstX == thirdY || firstX == fourthY){\n ans++\n }\n if(secondX == firstY || secondX == thirdY || secondX == fourthY){\n ans++\n }\n if(thirdX == secondY || thirdX == firstY || thirdX == fourthY){\n ans++\n }\n if(fourthX == secondY || fourthX == thirdY || fourthX == firstY){\n ans++\n }\n return ans\n}\nclass tuple(x:Int , y:Int , z:Int){\n var x:Int=0\n var y:Int=0\n var z:Int=0\n init{\n this.x=x\n this.y=y\n this.z=z\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2198ae8fb9b78ad4108b40eb4d57b024", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = 0\n for(i in 1..n){\n a = readLine()!!.toInt()\n if ((a % 7 == 0) || (a % 3 == 0) || (((((a-3) % 3 == 0) || (a-3) % 7 == 0)) && ((a-3) > 0)) || (((a-7) % 7 == 0 || (a-7) % 3 == 0) && ((a-7) > 0)) || (((a-10-3) % 3 == 0) || ((a-10-3) % 7 == 0) || ((a-10-7) % 3 == 0) || ((a-10-7) % 7 == 0)) && ((a-10) > 0)){\n println(\"YES\")\n }\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ed7706e04a2a8bff03ce3dc4a2320791", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = 0\n for(i in 1..n){\n a = readLine()!!.toInt()\n if (a % 7 == 0 || a % 3 == 0 || (a-3) % 3 == 0 || (a-7) % 7 == 0 || (a-3) % 7 == 0 || (a-7) % 3 == 0){\n println(\"YES\")\n }\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ab430d2d9128bb74b96eb8d228b12734", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\n\nfun solve(a: Int): String {\n\n for (i in 1..a / 3) {\n if ((a - i * 3) % 7 == 0) return \"YES\"\n }\n return \"NO\"\n}\n\nfun processSuite() {\n val n = readLine()!!.toInt()\n val solution = solve(n)\n println(solution)\n}\n\nfun suitesCount() = readLine()!!.toInt()\n\nfun main() {\n for (i in 0 until suitesCount()) {\n processSuite()\n }\n}\n\n// READER\ninternal val reader = Reader()\ninternal fun readNumber() = reader.nextInt()\ninternal fun readNumbers(n: Int) = reader.nextInts(n)\n\ntypealias DataInputStream = java.io.DataInputStream\n\ninternal class Reader {\n\n private val BUFFER_SIZE = 1 shl 16\n private val din: DataInputStream = DataInputStream(System.`in`)\n private val buffer: ByteArray = ByteArray(BUFFER_SIZE)\n private var bytesRead: Int = 0\n private var bufferPointer: Int = bytesRead\n\n private val stop: Byte = -1\n\n private fun read(): Byte {\n if (bufferPointer == bytesRead) {\n fillBuffer()\n }\n return buffer[bufferPointer++]\n }\n\n private fun fillBuffer() {\n bufferPointer = 0\n bytesRead = din.read(buffer, bufferPointer, BUFFER_SIZE)\n if (bytesRead == -1) {\n buffer[0] = stop\n }\n }\n\n fun nextLine(): String {\n val buf = ByteArray(64) // line length\n var cnt = 0\n var c: Byte\n do {\n c = read().takeUnless { it == '\\n'.toByte() } ?: break\n buf[cnt++] = c\n } while (c != stop)\n\n return String(buf, 0, cnt)\n }\n\n fun nextInts(n: Int): IntArray {\n val arr = IntArray(n) { 0 }\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n return arr\n }\n\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte()) c = read()\n val neg = c == '-'.toByte()\n if (neg) c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n\n return if (neg) -ret else ret\n }\n\n fun nextLong(): Long {\n var ret = 0L\n var c = read()\n while (c <= ' '.toByte()) c = read()\n val neg = c == '-'.toByte()\n if (neg) c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n\n return if (neg) -ret else ret\n }\n\n fun nextDouble(): Double {\n var ret = 0.0\n var div = 1.0\n var c = read()\n while (c <= ' '.toByte()) c = read()\n val neg = c == '-'.toByte()\n if (neg) c = read()\n do {\n ret = ret * 10 + c - '0'.toDouble()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n\n if (c == '.'.toByte()) {\n c = read()\n while (c >= '0'.toByte() && c <= '9'.toByte()) {\n div *= 10\n ret += (c - '0'.toByte()) / div\n c = read()\n }\n }\n\n return if (neg) -ret else ret\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "15f45700682acaa63c437caf6490d965", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var t = readLine()!!.toInt()\n\n for(i in 1..t) {\n var x = readLine()!!.toInt()\n var possible = false\n\n for(j in 1..t) {\n if(x % (3 * j) == 7 || x % (7 * j) == 3) possible = true\n if(x % 3 == 0 || x % 7 == 0) possible = true\n\n if(possible) break\n }\n\n println(if (possible) \"YES\" else \"NO\")\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bf88b2b7605dc1fc198a3331b4233b49", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = 0\n for(i in 1..n){\n a = readLine()!!.toInt()\n if ((a % 7 == 0 || a % 3 == 0 || (a-3) % 3 == 0 || (a-7) % 7 == 0 || (a-3) % 7 == 0 || (a-7) % 3 == 0) && (a-3 >= 0) || (a-7 >= 0)){\n println(\"YES\")\n }\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e29339d08136e1ad0305c061adec39df", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = 0\n for(i in 1..n){\n a = readLine()!!.toInt()\n if ((a % 7 == 0) || (a % 3 == 0) || (((((a-3) % 3 == 0) || (a-3) % 7 == 0)) && ((a-3) > 0)) || (((a-7) % 7 == 0 || (a-7) % 3 == 0) && ((a-7) > 0))){\n println(\"YES\")\n }\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "92fe7eaea0b11be1b36aae76698d8ba5", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var a = 0\n for(i in 1..n){\n a = readLine()!!.toInt()\n if (a % 7 == 0 || a % 3 == 0 || a % 10 == 0){\n println(\"YES\")\n }\n else\n println(\"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b2d692ae68cd3ed432524ec803cdbe4b", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var t = readLine()!!.toInt()\n\n for(i in 1..t) {\n var x = readLine()!!.toInt()\n var possible = false\n\n for(j in 0..x) {\n if((x - 3 * j) % 7 == 0 && x >= 3 * j) possible = true\n if((x - 7 * j) % 3 == 0 && x >= 7 * j) possible = true\n }\n\n println(if (possible) \"YES\" else \"NO\")\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0f08cf4e33d3e75f2b264aa3342b6a8b", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextInt()\n repeat(n) {\n val x = sc.nextInt()\n\n for (i in 0..x) {\n if (i * 3 > x) {\n println(\"NO\")\n break\n }\n if ((x - i * 3) % 7 == 0) {\n println(\"YES\")\n break\n }\n }\n\n }\n\n\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce5db08933f2ec12b9030f89b0914f3f", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val numCases = readInt()\n val sols = BooleanArray(numCases)\n for (numCase in 0 until numCases) {\n val n = readInt()\n for (b in 0 .. n / 7)\n if ((n - 7 * b) % 3 == 0) {\n sols[numCase] = true\n break\n }\n }\n\n print(sols.joinToString(System.lineSeparator()) { b -> if (b) \"YES\" else \"NO\" })\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7c664f527c8ee191b03f89ea5b62486b", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "Kotlin 1.5", "source_code": "private fun readLn() = readLine()!! // string line\r\nprivate fun readInt() = readLn().toInt() // single int\r\nprivate fun readLong() = readLn().toLong() // single long\r\nprivate fun readDouble() = readLn().toDouble() // single double\r\nprivate fun readStrings() = readLn().split(\" \") // list of strings\r\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\r\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\r\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\r\nprivate fun readLis() = readInts().toMutableList()\r\n\r\n//println(res.joinToString(\" \")) - > focus ( \" \" )\r\n//var a1 = readLongs().toMutableList()\r\n//val st = mutableSetOf() -> var find = st.elementAt(i)\r\n//var ar1 = LongArray(3) {100000}\r\n//f2.sortDescending() sort IntArray\r\n//var c = 'a' + i ( from 'a' --> 'z' )\r\n\r\n\r\nfun solve() {\r\n var n = readInt()\r\n var s = readLine()!!.toString()\r\n if (n == 1) {\r\n println(\"0\")\r\n return\r\n }\r\n var ans = 0\r\n var st = -1\r\n for (i in 0 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n break\r\n }\r\n }\r\n if (st == -1) {\r\n println(\"0\")\r\n return\r\n }\r\n var one = 0\r\n while (true) {\r\n var end = 0\r\n var ok = 0\r\n for (i in st + 1 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n if (one >= 2) {\r\n one = 0\r\n } else {\r\n ans += 2 - one\r\n one = 0\r\n }\r\n ok = 1\r\n break\r\n } else {\r\n one++\r\n }\r\n }\r\n if (st >= n - 1 || ok == 0) {\r\n break\r\n }\r\n }\r\n\r\n println(ans)\r\n}\r\n\r\nfun main() {\r\n val n = readInt()\r\n var ok = false\r\n val list = mutableListOf()\r\n for(i in 0 until n){\r\n val s = readLine()!!.toString()\r\n list.add(s)\r\n if (s.contains(\"theseus\")){\r\n ok = true\r\n }\r\n }\r\n if(ok){\r\n println(\"YES\")\r\n }else{\r\n for(i in 0 until n){\r\n var s = \"\"\r\n for(j in 0 until n){\r\n s += list[j][i]\r\n }\r\n if(s.contains(\"theseus\")){\r\n ok = true\r\n break\r\n }\r\n }\r\n if(ok){\r\n println(\"YES\")\r\n }else{\r\n println(\"NO\")\r\n }\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7e1aa4d8df010cd87f72dab73d860cd9", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Kotlin 1.5", "source_code": "private fun readLn() = readLine()!! // string line\r\nprivate fun readInt() = readLn().toInt() // single int\r\nprivate fun readLong() = readLn().toLong() // single long\r\nprivate fun readDouble() = readLn().toDouble() // single double\r\nprivate fun readStrings() = readLn().split(\" \") // list of strings\r\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\r\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\r\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\r\nprivate fun readLis() = readInts().toMutableList()\r\n\r\n//println(res.joinToString(\" \")) - > focus ( \" \" )\r\n//var a1 = readLongs().toMutableList()\r\n//val st = mutableSetOf() -> var find = st.elementAt(i)\r\n//var ar1 = LongArray(3) {100000}\r\n//f2.sortDescending() sort IntArray\r\n//var c = 'a' + i ( from 'a' --> 'z' )\r\n\r\n\r\nfun solve() {\r\n var n = readInt()\r\n var s = readLine()!!.toString()\r\n if (n == 1) {\r\n println(\"0\")\r\n return\r\n }\r\n var ans = 0\r\n var st = -1\r\n for (i in 0 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n break\r\n }\r\n }\r\n if (st == -1) {\r\n println(\"0\")\r\n return\r\n }\r\n var one = 0\r\n while (true) {\r\n var end = 0\r\n var ok = 0\r\n for (i in st + 1 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n if (one >= 2) {\r\n one = 0\r\n } else {\r\n ans += 2 - one\r\n one = 0\r\n }\r\n ok = 1\r\n break\r\n } else {\r\n one++\r\n }\r\n }\r\n if (st >= n - 1 || ok == 0) {\r\n break\r\n }\r\n }\r\n\r\n println(ans)\r\n}\r\n\r\nfun main() {\r\n val n = readInt()\r\n var ok = false\r\n for(i in 0 until n){\r\n val s = readLine()!!.toString()\r\n if (s.contains(\"theseus\")){\r\n ok = true\r\n }\r\n }\r\n if(ok){\r\n println(\"YES\")\r\n }else{\r\n println(\"NO\")\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "605e016246a247c85a0ecb61eac64db0", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Kotlin 1.6", "source_code": "import java.util.*\nimport kotlin.math.*\n\nprivate fun List.toPair(): Pair {\n return Pair(this[0], this[1])\n}\n\nprivate fun maxOf(ans: Pair, b: Pair): Pair {\n return if (ans.first > b.first || ans.first == b.first && ans.second > b.second) ans\n else b\n}\n\nprivate fun , T2 : Comparable> pairCmp(): Comparator> {\n return Comparator { a, b ->\n val res = a.first.compareTo(b.first)\n if (res == 0) a.second.compareTo(b.second) else res\n }\n}\n\n\nprivate val readR = Scanner(System.`in`)\nprivate const val BUFFER_SIZE = 1 shl 16\nprivate val buffer = ByteArray(BUFFER_SIZE)\nprivate var bufferPt = 0\nprivate var bytesRead = 0\nprivate fun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nprivate val INPUT = System.`in`\nprivate tailrec fun readChar(): Char {\n if(bufferPt == bytesRead) {\n bufferPt = 0\n bytesRead = INPUT.read(buffer, 0, BUFFER_SIZE)\n }\n return if(bytesRead < 0) Char.MIN_VALUE\n else {\n val c = buffer[bufferPt++].toInt().toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\nprivate fun readln() = readLine()!!\nprivate fun readInt() = read().toInt()\nprivate fun readDouble() = read().toDouble()\nprivate fun readLong() = read().toLong()\nprivate fun readStrings(n: Int) = List(n) { read() }\nprivate fun readLines(n: Int) = List(n) { readln() }\nprivate fun readInts(n: Int) = List(n) { read().toInt() }\nprivate fun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nprivate fun readDoubles(n: Int) = List(n) { read().toDouble() }\nprivate fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nprivate fun readLongs(n: Int) = List(n) { read().toLong() }\nprivate fun readLongArray(n: Int) = LongArray(n) { read().toLong() }\nprivate fun printWithSpace(vararg x: Any?) = println(x.joinToString(\" \"))\nprivate fun readCharArray(n:Int) = CharArray(n) {_->readChar()}\n//----------------Customizing Functions----------------\n\n//-----------------------Solving-----------------------\n \n //println(res.joinToString(\" \")) - > focus ( \" \" )\n //var a1 = readLongs().toMutableList()\n //val st = mutableSetOf() -> var find = st.elementAt(i)\n //var ar1 = LongArray(3) {100000}\n //f2.sortDescending() sort IntArray\n //var c = 'a' + i ( from 'a' --> 'z' )\n \n \nprivate fun solve() {\n var n = readInt()\n var s = readLine()!!.toString()\n if (n == 1) {\n println(\"0\")\n return\n }\n var ans = 0\n var st = -1\n for (i in 0 until n) {\n if (s[i] == '0') {\n st = i\n break\n }\n }\n if (st == -1) {\n println(\"0\")\n return\n }\n var one = 0\n while (true) {\n var end = 0\n var ok = 0\n for (i in st + 1 until n) {\n if (s[i] == '0') {\n st = i\n if (one >= 2) {\n one = 0\n } else {\n ans += 2 - one\n one = 0\n }\n ok = 1\n break\n } else {\n one++\n }\n }\n if (st >= n - 1 || ok == 0) {\n break\n }\n }\n \n println(ans)\n }\n \n fun main() {\n val n = readInt()\n val arr = Array(n){CharArray(n)}\n for(i in 0 until n){\n val s = readLine()!!.toString()\n for(j in 0 until n){\n arr[i][j] = s[j]\n }\n }\n var ok = false\n for(i in 0 until n){\n for(j in 0 until n){\n if(i < n - 7){\n var cur = \"\"\n for(k in 0 until 7){\n cur += arr[i + k][j]\n }\n if(cur == \"theseus\"){\n ok = true\n }\n }\n if(j < n - 7){\n var cur = \"\"\n for(k in 0 until 7){\n cur += arr[i][j + k]\n }\n if(cur == \"theseus\"){\n ok = true\n }\n }\n if(i < n - 7 && j < n - 7){\n var cur = \"\"\n for(k in 0 until 7){\n cur += arr[i + k][j + k]\n }\n if(cur == \"theseus\"){\n ok = true\n }\n }\n }\n }\n if(ok){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "43f90cb438ba362b62b1c5dcbbddcd43", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Kotlin 1.5", "source_code": "private fun readLn() = readLine()!! // string line\r\nprivate fun readInt() = readLn().toInt() // single int\r\nprivate fun readLong() = readLn().toLong() // single long\r\nprivate fun readDouble() = readLn().toDouble() // single double\r\nprivate fun readStrings() = readLn().split(\" \") // list of strings\r\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\r\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of longs\r\nprivate fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles\r\nprivate fun readLis() = readInts().toMutableList()\r\n\r\n//println(res.joinToString(\" \")) - > focus ( \" \" )\r\n//var a1 = readLongs().toMutableList()\r\n//val st = mutableSetOf() -> var find = st.elementAt(i)\r\n//var ar1 = LongArray(3) {100000}\r\n//f2.sortDescending() sort IntArray\r\n//var c = 'a' + i ( from 'a' --> 'z' )\r\n\r\n\r\nfun solve() {\r\n var n = readInt()\r\n var s = readLine()!!.toString()\r\n if (n == 1) {\r\n println(\"0\")\r\n return\r\n }\r\n var ans = 0\r\n var st = -1\r\n for (i in 0 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n break\r\n }\r\n }\r\n if (st == -1) {\r\n println(\"0\")\r\n return\r\n }\r\n var one = 0\r\n while (true) {\r\n var end = 0\r\n var ok = 0\r\n for (i in st + 1 until n) {\r\n if (s[i] == '0') {\r\n st = i\r\n if (one >= 2) {\r\n one = 0\r\n } else {\r\n ans += 2 - one\r\n one = 0\r\n }\r\n ok = 1\r\n break\r\n } else {\r\n one++\r\n }\r\n }\r\n if (st >= n - 1 || ok == 0) {\r\n break\r\n }\r\n }\r\n\r\n println(ans)\r\n}\r\n\r\nfun main() {\r\n val n = readInt()\r\n val arr = Array(n){CharArray(n)}\r\n for(i in 0 until n){\r\n val s = readLine()!!.toString()\r\n for(j in 0 until n){\r\n arr[i][j] = s[j]\r\n }\r\n }\r\n var ok = false\r\n for(i in 0 until n){\r\n for(j in 0 until n){\r\n if(i < n - 7){\r\n var cur = \"\"\r\n for(k in 0 until 7){\r\n cur += arr[i + k][j]\r\n }\r\n if(cur == \"theseus\"){\r\n ok = true\r\n }\r\n }\r\n if(j < n - 7){\r\n var cur = \"\"\r\n for(k in 0 until 7){\r\n cur += arr[i][j + k]\r\n }\r\n if(cur == \"theseus\"){\r\n ok = true\r\n }\r\n }\r\n if(i < n - 7 && j < n - 7){\r\n var cur = \"\"\r\n for(k in 0 until 7){\r\n cur += arr[i + k][j + k]\r\n }\r\n if(cur == \"theseus\"){\r\n ok = true\r\n }\r\n }\r\n }\r\n }\r\n if(ok){\r\n println(\"YES\")\r\n }else{\r\n println(\"NO\")\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c589023d96af1eec5383f1c0f6c0932a", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.FileInputStream\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.Scanner\nimport java.util.StringTokenizer\n\nobject Main {\n internal class Reader {\n private val BUFFER_SIZE = 1 shl 16\n private var din: DataInputStream\n private var buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n constructor() {\n din = DataInputStream(System.`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(IOException::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n\n @Throws(IOException::class)\n fun close() {\n if (din == null)\n return\n din.close()\n }\n\n @Throws(IOException::class)\n constructor(file_name: String) {\n din = DataInputStream(FileInputStream(file_name))\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(IOException::class)\n fun readLine(): String {\n val buf = ByteArray(64) // line length\n var cnt = 0\n var c: Int = read().toInt()\n while (c != -1) {\n if (c == '\\n'.toInt())\n break\n buf[cnt++] = c.toByte()\n c = read().toInt()\n }\n return String(buf, 0, cnt)\n }\n\n @Throws(IOException::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while ( c >= '0'.toByte() && c <= '9'.toByte())\n\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n fun nextDouble(): Double {\n var ret = 0.0\n var div = 1.0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n\n do {\n ret = ret * 10 + c - '0'.toDouble()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n\n if (c == '.'.toByte()) {\n c = read()\n while (c >= '0'.toByte() && c <= '9'.toByte()) {\n div *= 10.0\n ret += (c - '0'.toByte()) / (div)\n c = read()\n }\n }\n\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n private fun fillBuffer() {\n var bufferPointer = 0\n bytesRead = din.read(buffer, bufferPointer, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n }\n\n @Throws(IOException::class)\n @JvmStatic\n fun main(args: Array) {\n val s = Reader()\n var n = s.nextInt()\n var c : Int = 0\n var bi : Int = 0\n var b : Int = 0\n for(i in 0..n-1){\n var tmp = s.nextInt()\n if(i%3 ==0) c+=tmp\n else if(i%3 == 1) bi+=tmp\n else b+=tmp\n }\n var res = if(c> bi && c>b)\n \"chest\"\n else if(bi>c && bi>b)\n \"biceps\"\n else \"back\"\n println(res)\n }\n} ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "844152aac957f1381231eb96b994c7e9", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.DataInputStream\nimport java.io.FileInputStream\nimport java.io.IOException\n\nobject Main {\n internal class Reader {\n private val BUFFER_SIZE = 1 shl 16\n private var din: DataInputStream?\n private var buffer: ByteArray\n private var bufferPointer: Int = 0\n private var bytesRead: Int = 0\n\n constructor() {\n din = DataInputStream(System.`in`)\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(IOException::class)\n private fun read(): Byte {\n if (bufferPointer == bytesRead)\n fillBuffer()\n return buffer[bufferPointer++]\n }\n\n @Throws(IOException::class)\n fun close() {\n if (din == null)\n return\n din!!.close()\n }\n\n @Throws(IOException::class)\n constructor(file_name: String) {\n din = DataInputStream(FileInputStream(file_name))\n buffer = ByteArray(BUFFER_SIZE)\n bytesRead = 0\n bufferPointer = bytesRead\n }\n\n @Throws(IOException::class)\n fun readLine(): String {\n val buf = ByteArray(64) // line length\n var cnt = 0\n var c: Int = read().toInt()\n while (c != -1) {\n if (c == '\\n'.toInt())\n break\n buf[cnt++] = c.toByte()\n c = read().toInt()\n }\n return String(buf, 0, cnt)\n }\n\n @Throws(IOException::class)\n fun nextInt(): Int {\n var ret = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toInt()\n c = read()\n } while ( c >= '0'.toByte() && c <= '9'.toByte())\n\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n fun nextLong(): Long {\n var ret: Long = 0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n do {\n ret = ret * 10 + c - '0'.toLong()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n fun nextDouble(): Double {\n var ret = 0.0\n var div = 1.0\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n val neg = c == '-'.toByte()\n if (neg)\n c = read()\n\n do {\n ret = ret * 10 + c - '0'.toDouble()\n c = read()\n } while (c >= '0'.toByte() && c <= '9'.toByte())\n\n if (c == '.'.toByte()) {\n c = read()\n while (c >= '0'.toByte() && c <= '9'.toByte()) {\n div *= 10.0\n ret += (c - '0'.toByte()) / (div)\n c = read()\n }\n }\n\n return if (neg) -ret else ret\n }\n\n @Throws(IOException::class)\n private fun fillBuffer() {\n var bufferPointer = 0\n bytesRead = din!!.read(buffer, bufferPointer, BUFFER_SIZE)\n if (bytesRead == -1)\n buffer[0] = -1\n }\n }\n\n @Throws(IOException::class)\n @JvmStatic\n fun main(args: Array) {\n val s = Reader()\n var n = s.nextInt()\n var c : Int = 0\n var bi : Int = 0\n var b : Int = 0\n for(i in 0..n-1){\n var tmp = s.nextInt()\n if(i%3 ==0) c+=tmp\n else if(i%3 == 1) bi+=tmp\n else b+=tmp\n }\n var res = if(c> bi && c>b)\n \"chest\"\n else if(bi>c && bi>b)\n \"biceps\"\n else \"back\"\n println(res)\n }\n} ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "23026568995afd4fe50c28898dc3d72d", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n val N = readLine()!!.toInt()\n var mashq = IntArray(N)\n var types = IntArray(3)\n for (index: Int in 0..(N - 1)) {\n mashq[index] = readLine()!!.trim().toInt()\n types[index % 3] += mashq[index]\n }\n val maxIndex = types.indices.maxBy { types[it] }\n if (maxIndex == 0) println(\"chest\")\n else if (maxIndex == 1) println(\"biceps\")\n else if (maxIndex == 2) println(\"back\")\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e9f9c1763accd12721a0cf7789c3d7cf", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main (args: Array) {\n val exercises = arrayOf(\"chest\",\"biceps\",\"back\")\n val reader = Scanner(System.`in`)\n val n = reader.nextInt()\n val h = mutableMapOf(0 to 0, 1 to 0, 2 to 0)\n var a = 0\n for (i in 1..n) {\n h[a] = h[a]!! + reader.nextInt()\n a= (a+1)%3 \n }\n val maxa = h.maxBy{it.value}!!.key\n println(exercises[maxa])\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d344adb7b1d5a6c1772cc6a5fdd01723", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val repeats = intArrayOf(0, 0, 0)\n readLine()\n for ((pos, exercise) in readInts().withIndex())\n repeats[pos % 3] += exercise\n print(\n when {\n repeats[0] > repeats[1] && repeats[0] > repeats[2] -> \"chest\"\n repeats[1] > repeats[0] && repeats[1] > repeats[2] -> \"biceps\"\n else -> \"back\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "42acc06f68c0435d00d488b5b4366c57", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) = with(java.util.Scanner(System.`in`)){\n var n = nextInt()\n var c : Int = 0\n var bi : Int = 0\n var b : Int = 0\n for(i in 0..n-1){\n var tmp = nextInt()\n if(i%3 ==0) c+=tmp\n else if(i%3 == 1) bi+=tmp\n else b+=tmp\n }\n var res = if(c> bi && c>b)\n \"chest\"\n else if(bi>c && bi>b)\n \"biceps\"\n else \"back\"\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "baf808f003a967b30e3fb31800464237", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val x = readLine()?.split(' ')?.map { it.toInt() } ?: return\n val y = readLine()?.split(' ')?.map { it.toInt() } ?: return\n var count = 0\n\n for (i in 0 until n) {\n val xor = x[i] xor y[i]\n if (xor == x[i] || xor == y[i])\n count++\n }\n\n val result = if (count % 2 == 0) \"Karen\" else \"Koyomi\"\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "78a2837877523b05e2981471f783843d", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n println(\"Karen\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ec66700913beb47229dc0e13e84ab274", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(\" \").map { it.toInt() }\n val ys = readLine()!!.split(\" \").map { it.toInt() }\n val all = mutableSetOf()\n all.addAll(xs)\n all.addAll(ys)\n var sol = 0\n xs.forEach { x -> ys.forEach { y -> if ((x xor y) in all) sol++ } }\n if (sol % 2 == 0) print(\"Karen\") else print(\"Koyomi\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c09c8713b03ac078d4e2963f9ed21e73", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n println(\"Karen\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f4902a8aa03bb3404e16f3d0324081a", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n scanner.nextLine()\n val a = scanner.nextLine().split(\" \").map { it.toInt() }.toIntArray()\n val b = scanner.nextLine().split(\" \").map { it.toInt() }.toIntArray()\n\n println(findWinner(a, b, n))\n}\n\nfun findWinner(x: IntArray, y: IntArray, n: Int): String {\n var count = 0L\n\n val map = mutableMapOf()\n x.forEach { map.put(it, true) }\n y.forEach { map.put(it, true) }\n\n for(i in 0 until n) {\n for (j in 0 until n) {\n val temp = (x[i].xor(y[j]))\n if (map.containsKey(temp)) {\n count++\n }\n }\n }\n\n return if (count % 2L == 0L) {\n \"Karen\"\n } else {\n \"Koyomi\"\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b5f92f206ee8c48b186ddecb9988a5f", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val n = sc.nextInt()\n val x = mutableSetOf()\n val y = mutableSetOf()\n\n (1..n).forEach { x.add(sc.nextInt()) }\n (1..n).forEach { y.add(sc.nextInt()) }\n\n var sum = 0\n for(xi in x){\n for(yj in y){\n val t = xi xor yj\n if(x.contains(t) || y.contains(t)) sum += 1\n }\n }\n\n if(sum % 2 == 0) print(\"Karen\")\n else print(\"Koyomi\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "43ebd6dfbb6da157253c939189a80ca7", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n scanner.nextLine()\n val a = scanner.nextLine().split(\" \").map { it.toInt() }.toIntArray()\n val b = scanner.nextLine().split(\" \").map { it.toInt() }.toIntArray()\n\n println(findWinner(a, b, n))\n}\n\nfun findWinner(x: IntArray, y: IntArray, n: Int): String {\n var count = 0L\n\n for(i in 0 until n) {\n for (j in 0 until n) {\n val temp = (x[i].xor(y[j]))\n if (i !=j && (x.contains(temp) || y.contains(temp))) {\n count++\n }\n }\n }\n\n return if (count % 2L == 0L) {\n \"Karen\"\n } else {\n \"Koyomi\"\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "01bfb6cdd3eccc7f1f0f8e1edfcc53a0", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (w, h, k) = readLine()!!.split(' ').map(String::toInt)\n var sum = 0\n\n for (i in 1..k)\n {\n sum += 2*w + 2*h - 4\n w -= 4\n h -= 4\n }\n\n print(sum)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "648dda1b8cd3667ad8fb22d085b66e4d", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "var r = 0\nfun main(){\n var q = readLine()!!.split(' ').map { it.toInt() }\n var h = q[0]\n var w = q[1]\n var k = q[2]\n while(k > 0){\n r += (h + w) * 2 - 4\n h -= 4\n w -= 4\n k -= 1\n }\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "34ec2c4453bf15e5c2ca61f42fa593e1", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "/* https://codeforces.com/problemset/problem/1031/A */\n\nfun main() {\n val (w, h, k) = readLine()!!.split(\" \").map { it.toInt() }\n var numOfCells = 0\n for (i in 1..k) {\n val ringWidth = w - 4 * (i - 1)\n val ringHeight = h - 4 * (i - 1)\n val perimeter = 2 * (ringWidth + ringHeight) - 4\n numOfCells += perimeter\n }\n println(numOfCells)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2dcbf20af37b95a6c7f75f8571aed5b1", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\n\tval Xarr = readLine()!!.split(' ').map { it.toInt() }\nvar answer = 0\n\tfor(i in 1 until Xarr[2]+1){\n\t\tanswer += ((Xarr[0]/i-1)+(Xarr[1]/i-1))*2\n\t}\n\tif(Xarr[2]>1) answer += Xarr[2]\n\tprintln(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "665ea6f5ad40b939d0c8278f132b4cc7", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array){\n val s = Scanner(System.`in`)\n val m = s.nextInt()\n val n = s.nextInt()-2\n val k = s.nextInt()-1\n val mn = 2*m+2*n\n var c = 0\n for (i in 0..k) c+=mn-(4*(i))\n print(c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "759c5f21f323c96b80928294af1a6b26", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val hands = IntArray(3)\n val stringToNum = mapOf(\"rock\" to 1, \"paper\" to 2, \"scissors\" to 4)\n val posToWinner = \"FMS\"\n for (pos in 0..2) hands[pos] = stringToNum[readLine()!!]!!\n for (pos in 0..2)\n if (hands[pos] == hands[(pos + 1) % 7] + hands[(pos + 2) % 7]) return print(posToWinner[pos])\n print('?')\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3ebea15c6e0f4e3cf334d4f9f13eceba", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val hands = IntArray(3)\n val stringToNum = mapOf(\"rock\" to 1, \"paper\" to 2, \"scissors\" to 4)\n val posToWinner = \"FMS\"\n for (pos in 0..2) hands[pos] = stringToNum[readLine()!!]!!\n for (pos in 0..2)\n if (hands[pos] == (hands[(pos + 1) % 3] + hands[(pos + 2) % 3]) % 7) return print(posToWinner[pos])\n print('?')\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c4ca1cf7a776c2c7b07188b0c52c981", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()\nfun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()\nfun readInt() = readLine()!!.toInt()\n\nfun main(args: Array) {\n val f = readLine()!!\n val m = readLine()!!\n val s = readLine()!!\n\n\n if (isGreaterThan(f, m) && isGreaterThan(f, s)) {\n println(\"F\")\n } else if (isGreaterThan(m, f) && isGreaterThan(m, s)) {\n println(\"M\")\n }else if (isGreaterThan(s, m) && isGreaterThan(s, f)) {\n println(\"S\")\n }else {\n println(\"?\")\n }\n\n}\n\nfun isGreaterThan(str1: String, str2: String): Boolean {\n return (str1 == \"scissors\" && str2 == \"paper\") || (str1 == \"paper\" && str2 == \"rock\") || (str1 == \"rock\" && str2 == \"scissors\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1257dbe4289e3b625af216ca73f2e4c4", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLn()\n\n var e = ModInt(1)\n var ans = ModInt(0)\n for(c in x.reversed()) {\n ans *= 2\n if(c == '1') ans += e\n e *= 4\n }\n\n println(ans)\n}\n\ninline fun Array.numSortBy(crossinline f: (T) -> Any?) = groupingBy(f).eachCount().values\n .fold(ModInt(1)) { acc, i -> acc * i.factorial() }\n\nval _factorialMemo = mutableListOf(ModInt(1))\n\nfun Int.factorial() = run {\n while(this > _factorialMemo.lastIndex) {\n _factorialMemo.add(_factorialMemo.last() * _factorialMemo.size)\n }\n\n _factorialMemo[this]\n}\n\ninfix fun Int.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Long) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod).toInt()\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\n/** modint inline class, requires hardcoded mod base **/\nconst val MODBASE = 1000000007\n\ninline fun Int.toModInt() = ModInt(this umod MODBASE)\ninline fun Long.toModInt() = ModInt((this umod MODBASE).toInt())\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n inline operator fun plus(other: ModInt) = plus(other.int) // MODBASE < 2^30\n inline operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n inline operator fun inc() = plus(1)\n\n inline operator fun minus(other: ModInt) = minus(other.int)\n inline operator fun minus(other: Int) = (int - other).toModInt()\n inline operator fun dec() = minus(1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODBASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODBASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) exponent umod MODBASE - 1 else exponent // assumes MODBASE is prime\n return ModInt(int.powMod(e, MODBASE))\n }\n\n inline fun inv() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODBASE - 2) // assumes MODBASE is prime\n }\n fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inv())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override val size: Int get() = intArray.size\n\n override fun contains(element: ModInt): Boolean = any { it == element }\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun Iterable.sum() = fold(ModInt(0), ModInt::plus)\nfun Sequence.sum() = fold(ModInt(0), ModInt::plus)\nfun Iterable.product() = fold(1L) { acc, it -> acc * it.int % MODBASE }.toModInt()\nfun Sequence.product() = fold(1L) { acc, it -> acc * it.int % MODBASE }.toModInt()\n\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\n\nclass Output {\n val outputSb = StringBuilder()\n fun print(o: Any?) { outputSb.append(o) }\n fun println() { outputSb.append('\\n') }\n fun println(o: Any?) { outputSb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(outputSb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e6b145666577a49711bf4d0acf58a25e", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLn()\n\n var e = ModInt(1)\n var ans = ModInt(0)\n for(c in x.reversed()) {\n ans *= 2\n if(c == '1') ans += e\n e *= 4\n }\n\n println(ans)\n}\n\ninfix fun Int.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Long) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod).toInt()\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\n/** modint inline class, requires hardcoded mod base **/\nconst val MODBASE = 1000000007\n\ninline fun Int.toModInt() = ModInt(this umod MODBASE)\ninline fun Long.toModInt() = ModInt((this umod MODBASE).toInt())\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n inline operator fun plus(other: ModInt) = plus(other.int) // MODBASE < 2^30\n inline operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n inline operator fun inc() = plus(1)\n\n inline operator fun minus(other: ModInt) = minus(other.int)\n inline operator fun minus(other: Int) = (int - other).toModInt()\n inline operator fun dec() = minus(1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODBASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODBASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) exponent umod MODBASE - 1 else exponent // assumes MODBASE is prime\n return ModInt(int.powMod(e, MODBASE))\n }\n\n inline fun inv() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODBASE - 2) // assumes MODBASE is prime\n }\n fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inv())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override val size: Int get() = intArray.size\n\n override fun contains(element: ModInt): Boolean = any { it == element }\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\nfun Iterable.sum() = fold(ModInt(0), ModInt::plus)\nfun Sequence.sum() = fold(ModInt(0), ModInt::plus)\nfun Iterable.product() = fold(1L) { acc, it -> acc * it.int % MODBASE }.toModInt()\nfun Sequence.product() = fold(1L) { acc, it -> acc * it.int % MODBASE }.toModInt()\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readStringSeq() = readLn().splitToSequence(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readIntSeq() = readStringSeq().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readDoubleSeq() = readStringSeq().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\nfun readLongSeq() = readStringSeq().map { it.toLong() }\n\nclass Output {\n val outputSb = StringBuilder()\n fun print(o: Any?) { outputSb.append(o) }\n fun println() { outputSb.append('\\n') }\n fun println(o: Any?) { outputSb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(outputSb) }\n}\ninline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "452c1dc32fd3e196185e05a48ec7b2c6", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*;\nimport java.io.*\nimport java.math.*\n\nobject ReadUtils {\n var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n var st: StringTokenizer? = null\n\n\n fun next(): String {\n while (ReadUtils.st == null || !ReadUtils.st!!.hasMoreElements()) {\n ReadUtils.st = StringTokenizer(readLine())\n }\n\n return st!!.nextToken()\n }\n}\n\nfun nextToken(): String {\n return ReadUtils.next()\n}\n\nfun nextInt(): Int {\n return nextToken().toInt()\n}\n\nfun nextLong(): Long {\n return nextToken().toLong()\n}\n\nfun readField(n: Int): Array {\n return Array(n, {_ -> nextToken()})\n}\n\nfun main(args: Array) {\n val n = nextInt()\n val a = readField(n)\n val b = readField(n)\n for (i in 0..1)\n for (j in 0..1)\n for (k in 0..3) {\n val cur = a.copyOf()\n if (i == 1) {\n for (l in cur.indices)\n cur[l] = cur[l].reversed()\n }\n\n if (j == 1) {\n cur.reverse()\n }\n\n for (l in 1..k) {\n val ncur = Array(n, {_ -> StringBuilder(cur[0])})\n for (x in 0 until n)\n for (y in 0 until n)\n ncur[n - y - 1][x] = cur[x][y]\n\n for (x in 0 until n)\n cur[x] = ncur[x].toString()\n }\n\n if (Arrays.equals(cur , b)) {\n return println(\"Yes\")\n }\n }\n\n println(\"No\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a5308f6fc7b2dfb6c7b6a02630bfc3c9", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.abs\nimport kotlin.math.min\nimport kotlin.math.sqrt\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, k) = br.readLine().split(\" \").map { it.toLong() }\n if (n == 1L) {\n println(0)\n } else {\n val total = k*(k - 1)/2 + 1\n if (total < n){\n println(-1)\n } else {\n if (total == n){\n println(k - 1)\n } else {\n val surplus = ((1 + sqrt(1 + 8*(total - n - 1.0)))/2)\n val ans = (k - surplus).toLong()\n val poss0 = abs(n - ans*(ans - 1)/2 + 1)\n val poss1 = abs(n - (ans - 1)*(ans - 2)/2 + 1)\n val poss2 = abs(n - (ans + 1)*ans/2 + 1)\n val minPoss = min(poss0, min(poss1, poss2))\n println(\n if (minPoss == poss0) ans\n else if (minPoss == poss1) ans - 1\n else ans + 1\n )\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f8baf2b52ea6c2eb0d2bc2555dba0e86", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.sqrt\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, k) = br.readLine().split(\" \").map { it.toLong() }\n if (n == 1L) {\n println(0)\n } else {\n val total = k*(k - 1)/2 + 1\n if (total < n){\n println(-1)\n } else {\n if (total == n){\n println(k - 1)\n } else {\n val surplus = ((1 + sqrt(1 + 8*(total - n - 1.0)))/2)\n val ans = k - surplus\n val extra = (surplus*(surplus - 1)/2 + 1).toLong()\n println(if (total - extra == n) ans.toLong() else ans.toLong() + 1)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9c2437889f6c9a8ba4df20a7a5d74d28", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, k) = br.readLine().split(\" \").map { it.toLong() }\n val maxBound = k*(k - 1)/ 2 + 1\n if (maxBound < n) {\n println(-1)\n } else if (n == 1L) {\n println(0)\n } else {\n var l = 1L\n var r = k\n while (l < r) {\n val m = (l + r)/2\n val x = (m*(2*k - m - 1))/2 + 1\n if (x >= n) {\n r = m\n } else {\n l = m + 1\n }\n }\n println(l)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "68505b1820a80c33073d0ce483900651", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (n, k) = br.readLine().split(\" \").map { it.toLong() }\n val maxBound = k*(k - 1)/ 2 + 1\n if (maxBound < n) {\n println(-1)\n } else {\n var sum = 0L\n var ans = 0L\n for (i in k downTo 1) {\n if (sum + i >= n) {\n ans = k - i + 1\n break\n }\n sum += i\n }\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "32abb84cf8eb39f17ddf535bacbea922", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\ndata class Entry(val tpe: String, val i: Int)\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val M = ni()\n val E = Array(M){Entry(ns(), ni() - 1)}\n\n val prev = mutableListOf()\n val appear = BooleanArray(N)\n for (e in E) {\n when(e.tpe) {\n \"+\" -> {\n appear[e.i] = true\n }\n \"-\" -> {\n if (!appear[e.i]) prev += e.i\n appear[e.i] = true\n }\n }\n }\n\n val flag = BooleanArray(N)\n for (i in 0 until N) {\n if (!appear[i]) flag[i] = true\n }\n\n val j = if (prev.isEmpty()) {\n E.find { it.tpe == \"+\" }!!.i\n } else {\n prev.last()\n }\n var ok = true\n val set = mutableSetOf()\n set.addAll(prev)\n for (e in E) {\n when(e.tpe) {\n \"+\" -> set += e.i\n else -> set -= e.i\n }\n if (set.isNotEmpty()) {\n ok = ok && set.contains(j)\n }\n }\n\n if (ok) flag[j] = true\n\n val ans = mutableListOf()\n for (i in 0 until N) {\n if (flag[i]) ans += i + 1\n }\n out.println(ans.size)\n out.println(ans.joinToString(\" \"))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f72f6e2a7b7d2f4350a070028d41ffe", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (n, m) = readInts()\n val array = Array(n) { CharArray(m) }\n for (row in 0 until n)\n array[row] = readLine()!!.toCharArray()\n val sol = Array(n) { CharArray(m) { '.' } }\n for (row in 0 until n - 2)\n for (col in 0 until m - 2)\n if (array[row][col] == '#' && array[row][col + 1] == '#' && array[row][col + 2] == '#' &&\n array[row + 1][col] == '#' && array[row + 1][col + 2] == '#' &&\n array[row + 2][col] == '#' && array[row + 2][col + 1] == '#' && array[row + 2][col + 2] == '#'\n ) {\n sol[row][col] = '#'\n sol[row][col + 1] = '#'\n sol[row][col + 2] = '#'\n sol[row + 1][col] = '#'\n sol[row + 1][col + 2] = '#'\n sol[row + 2][col] = '#'\n sol[row + 2][col + 1] = '#'\n sol[row + 2][col + 2] = '#'\n }\n for (row in 0 until n)\n for (col in 0 until m)\n if (array[row][col] != sol[row][col]) return print(\"NO\")\n print(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d38278f6a00e4a2f4b7f01f7d1a21f43", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "var matrix: Array = arrayOf()\nvar bit: Array = arrayOf()\nvar n = 0\nvar m = 0\nval circle = arrayOf(\n Pair(0, 0),\n Pair(0, 1),\n Pair(0, 2),\n Pair(1, 2),\n Pair(2, 2),\n Pair(2, 1),\n Pair(2, 0),\n Pair(1, 0)\n)\n\n\nfun check(i: Int, j: Int, k: Int): Boolean {\n val x = circle[k].first\n val y = circle[k].second\n for (l in 0..7) {\n val new_x = i + circle[l].first - x\n val new_y = j + circle[l].second - y\n if (new_x in 0 until n && new_y in 0 until m && matrix[new_x][new_y] == '#') {\n } else return false\n }\n return true\n}\n\nfun find(): Boolean {\n val twoInt = readLine()!!.split(\" \").map { it.toInt() }\n n = twoInt[0]\n m = twoInt[1]\n bit = Array(n) { _ -> BooleanArray(m) { false } }\n for (i in 0 until n) {\n matrix += readLine()!!.toCharArray()\n }\n for (i in 0 until n) {\n for (j in 0 until m) {\n if (matrix[i][j] == '#' && !bit[i][j]) {\n var flag = false\n for (k in 0..7) {\n if (check(i, j, k)) {\n bit[i][j] = true\n flag = true\n break\n }\n }\n if (!flag) return false\n }\n }\n }\n return true\n}\n\nfun main(args: Array) {\n println(if (find()) \"YES\" else \"NO\")\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7928e1e772a82698d6a114253d862870", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.lang.Exception\n\nclass TaskB(val signature: Array) {\n val counterfit: Array\n\n init {\n counterfit = Array(signature.size) { BooleanArray(signature[0].size) { false } }\n }\n\n var result = false\n\n fun run() {\n for (i in 0..signature.size - 3)\n for (j in 0..signature[i].size - 3) {\n if (shouldDraw(i, j)) draw(i, j)\n }\n result = isIdentical()\n }\n\n fun shouldDraw(ii: Int, jj: Int): Boolean {\n for (i in 0..2) {\n for (j in 0..2) {\n if (i == 1 && j == 1) continue\n if (!signature[i + ii][j + jj]) return false\n }\n }\n return true\n }\n\n fun draw(ii: Int, jj: Int): Unit {\n for (i in 0..2) {\n for (j in 0..2) {\n if (i == 1 && j == 1) continue\n counterfit[ii + i][jj + j] = true\n }\n }\n }\n\n fun isIdentical(): Boolean {\n for (i in signature.indices)\n for (j in signature[i].indices)\n if (signature[i][j] != counterfit[i][j]) return false\n return true\n }\n\n fun print() {\n if (result)\n println(\"YES\")\n else\n println(\"NO\")\n }\n}\n\nfun cfb() = with(System.`in`) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val signature = Array(n) {\n val t = BooleanArray(m) {\n val c = read().toChar()\n when (c) {\n '#' -> true\n '.' -> false\n else -> throw Exception(\"You should learn how to parse.\")\n }\n }\n readLine()\n t\n }\n with(TaskB(signature)) {\n run()\n print()\n }\n}\n\nfun main(args: Array) {\n cfb()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94ae35db99a9097afe3e3c6e7acc0392", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.lang.Exception\n\nclass TaskB(val signature: Array) {\n val counterfit: Array\n\n init {\n counterfit = Array(signature.size) { BooleanArray(signature[0].size) { false } }\n }\n\n var result = false\n\n fun run() {\n for (i in 0..signature.size - 3)\n for (j in 0..signature[i].size - 3) {\n if (shouldDraw(i, j)) draw(i, j)\n }\n result = isIdentical()\n }\n\n fun shouldDraw(ii: Int, jj: Int): Boolean {\n for (i in 0..2) {\n for (j in 0..2) {\n if (i == 1 && j == 1) continue\n if (!signature[i + ii][j + jj]) return false\n }\n }\n return true\n }\n\n fun draw(ii: Int, jj: Int): Unit {\n for (i in 0..2) {\n for (j in 0..2) {\n if (i == 1 && j == 1) continue\n counterfit[ii + i][jj + j] = true\n }\n }\n }\n\n fun isIdentical(): Boolean {\n for (i in signature.indices)\n for (j in signature[i].indices)\n if (signature[i][j] != counterfit[i][j]) return false\n return true\n }\n\n fun print() = println(result)\n}\n\nfun cfb() = with(System.`in`) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val signature = Array(n) {\n val t = BooleanArray(m) {\n val c = read().toChar()\n when (c) {\n '#' -> true\n '.' -> false\n else -> throw Exception(\"You should learn how to parse.\")\n }\n }\n readLine()\n t\n }\n with(TaskB(signature)) {\n run()\n print()\n }\n}\n\nfun main(args: Array) {\n cfb()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "69ecaa148995b9db907f80c592806e9a", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "var matrix: Array = arrayOf()\nvar bit: Array = arrayOf()\nvar n = 0\nvar m = 0\nval circle = arrayOf(\n Pair(0, 0),\n Pair(0, 1),\n Pair(0, 2),\n Pair(1, 2),\n Pair(2, 2),\n Pair(2, 1),\n Pair(2, 0),\n Pair(1, 0)\n)\n\n\nfun check(i: Int, j: Int, k: Int): Boolean {\n val x = circle[k].first\n val y = circle[k].second\n for (l in 0..7) {\n val new_x = i + circle[l].first - x\n val new_y = j + circle[l].second - y\n if (new_x in 0 until n && new_y in 0 until m && matrix[new_x][new_y] == '#') {\n bit[new_x][new_y] = true\n } else return false\n }\n return true\n}\n\nfun find(): Boolean {\n val twoInt = readLine()!!.split(\" \").map { it.toInt() }\n n = twoInt[0]\n m = twoInt[1]\n bit = Array(n) { _ -> BooleanArray(m) { false } }\n for (i in 0 until n) {\n matrix += readLine()!!.toCharArray()\n }\n for (i in 0 until n) {\n for (j in 0 until m) {\n if (matrix[i][j] == '#' && !bit[i][j]) {\n var flag = false\n for (k in 0..7) {\n if (check(i, j, k)) {\n bit[i][j] = true\n flag = true\n break\n }\n }\n if (!flag) return false\n }\n }\n }\n return true\n}\n\nfun main(args: Array) {\n println(if (find()) \"YES\" else \"NO\")\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fd18d4ec20988a03f7f969274ce41940", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val k = readInt()\n val l = readInt()\n val D = readIntArray(n)\n\n MOD = k + k\n\n val ans = run ans@ {\n var a = ModInt(0)\n var b = ModInt(MOD-1)\n\n for(d in D) {\n when {\n d > l -> return@ans false\n d + k <= l -> {\n a = ModInt(0)\n b = ModInt(MOD-1)\n }\n else -> {\n a++\n b++\n\n val b1 = ModInt(l - d)\n val a1 = -b1\n\n val bp = b - a\n val a1p = a1 - a\n val b1p = b1 - a\n when {\n a1p <= bp -> {\n a = a1\n b = b1\n }\n b1p <= bp || a1p > b1p -> {\n b = b1\n }\n else -> return@ans false\n }\n }\n }\n }\n\n true\n }\n\n println(if(ans) \"Yes\" else \"No\")\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\noperator fun ModInt.compareTo(other: ModInt) = int.compareTo(other.int)\n\nvar MOD = 998244353\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt = ModInt(int.powMod(exponent, MOD))\n\n fun pow(exponent: Long) = ModInt(int.powMod(exponent, MOD))\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int): ModIntArray {\n val res = ModIntArray(n+1)\n res[0] = ModInt(1)\n for(i in 1..n) res[i] = res[i-1] * this\n return res\n}\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d1dc8845a0a00ffb4d98081bd695a950", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport kotlin.math.abs\nimport kotlin.math.min\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val out = StringBuilder()\n for (c in 1..jin.readLine().toInt()) {\n val (n, k, l) = jin.readLine().split(\" \").map { it.toInt() }\n val depths = jin.readLine().split(\" \").map { it.toInt() }\n var curr = k\n var answer = true\n for (d in depths) {\n if (d > l) {\n answer = false\n break\n }\n if (d + k <= l) {\n curr = k\n } else if (curr > 0) {\n curr = min(curr - 1, l - d)\n } else {\n if (abs(curr) + 1 + d > l) {\n answer = false\n break\n }\n curr--\n }\n }\n out.appendln(if (answer) \"yEs\" else \"nO\")\n }\n print(out)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0fb50fd59cb988132916d2e5961c59a3", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedOutputStream\nimport java.io.PrintWriter\nimport java.util.*\n\ndata class Position(\n val nextPriliv: Boolean,\n val value: Long\n) {\n fun next(k: Long): Position {\n val nextValue = if (nextPriliv) value + 1 else value - 1\n return when (nextValue) {\n 0L -> Position(true, 0)\n k -> Position(false, k)\n else -> Position(nextPriliv, nextValue)\n }\n }\n}\n\nfun main() {\n val reader = Scanner(System.`in`)\n val out = PrintWriter(BufferedOutputStream(System.`out`))\n\n val t = reader.nextInt()\n repeat(t) {\n val n = reader.nextInt() // Distance\n val k = reader.nextLong() // Priliv time\n val l = reader.nextLong() // Max depth\n val depths = LongArray(n) { reader.nextLong() }\n\n val possibilities = Array(n + 1) { mutableSetOf() }\n for (i in 0L until k) {\n possibilities[0].add(Position(true, i))\n }\n for (i in k downTo 1L) {\n possibilities[0].add(Position(false, i))\n }\n\n for (i in 0 until n) {\n possibilities[i].forEach { position ->\n var nextPosition = position.next(k)\n while (depths[i] + nextPosition.value <= l) {\n possibilities[i + 1].add(nextPosition)\n if (position == nextPosition) {\n break\n }\n nextPosition = nextPosition.next(k)\n }\n }\n }\n if (possibilities[n].isNotEmpty()) {\n out.println(\"Yes\")\n } else {\n out.println(\"No\")\n }\n }\n\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "adeed7f5ef8e6cf453040c8f780fa3c5", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val k = readInt()\n val l = readInt()\n val D = readIntArray(n)\n\n MOD = k + k\n\n val ans = run ans@ {\n var a = ModInt(0)\n var b = ModInt(MOD-1)\n\n for(d in D) {\n when {\n d > l -> return@ans false\n d + k <= l -> {\n a = ModInt(0)\n b = ModInt(MOD-1)\n }\n else -> {\n a++\n b++\n\n val b1 = ModInt(l - d)\n val a1 = -b1\n\n val bp = b - a\n val a1p = a1 - a\n val b1p = b1 - a\n when {\n a1p <= bp -> {\n a = a1\n b = b1\n }\n a1p > b1p -> {\n b = b1\n }\n else -> return@ans false\n }\n }\n }\n }\n\n true\n }\n\n println(if(ans) \"Yes\" else \"No\")\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\noperator fun ModInt.compareTo(other: ModInt) = int.compareTo(other.int)\n\nvar MOD = 998244353\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod\n\nfun Int.powMod(exponent: Long, mod: Int): Int {\n if(exponent < 0) error(\"Inverse not implemented\")\n var res = 1L\n var e = exponent\n var b = modulo(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1L) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\nfun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)\n\ninline fun Int.toModInt() = ModInt(this modulo MOD)\ninline fun Long.toModInt() = ModInt(this modulo MOD)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n\n // normalizes an integer that's within range [-MOD, MOD) without branching\n private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)\n\n operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30\n inline operator fun plus(other: Int) = plus(other.toModInt())\n operator fun inc() = normalize(int + (1 - MOD))\n\n operator fun minus(other: ModInt) = normalize(int - other.int)\n inline operator fun minus(other: Int) = minus(other.toModInt())\n operator fun dec() = normalize(int - 1)\n operator fun unaryMinus() = normalize(-int)\n\n operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))\n\n fun pow(exponent: Int): ModInt = ModInt(int.powMod(exponent, MOD))\n\n fun pow(exponent: Long) = ModInt(int.powMod(exponent, MOD))\n\n override inline fun toString() = int.toString()\n}\n\ninline operator fun Int.plus(modInt: ModInt) = modInt + this\ninline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt\ninline operator fun Int.times(modInt: ModInt) = modInt * this\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override inline val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n inline val indices get() = intArray.indices\n\n override inline fun contains(element: ModInt): Boolean = element.int in intArray\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override inline fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n\n fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))\n fun copyOf() = copyOf(size)\n}\nfun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =\n ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))\ninline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))\ninline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })\n\nfun ModInt.powArray(n: Int): ModIntArray {\n val res = ModIntArray(n+1)\n res[0] = ModInt(1)\n for(i in 1..n) res[i] = res[i-1] * this\n return res\n}\n\ninline fun ModIntArray.first() = get(0)\ninline fun ModIntArray.last() = get(lastIndex)\ninline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)\ninline fun ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }\ninline fun ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }\nfun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)\nfun ModIntArray.product() = fold(ModInt(1), ModInt::times)\n\ninline fun Iterable.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Iterable.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Sequence.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Sequence.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\ninline fun Array.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }\ninline fun Array.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }\nfun Iterable.sum() = sumByModInt { it }\nfun Sequence.sum() = sumByModInt { it }\nfun Iterable.product() = productByModInt { it }\nfun Sequence.product() = productByModInt { it }\nfun Collection.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }\n\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "91566636782f29cc036d41b58237750a", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "val read = { readLine()!!.trim().split(\" \") }\nval readInt = { readLine()!!.split(\" \").mapNotNull { it.toIntOrNull() } }\nval readLong = { readLine()!!.split(\" \").mapNotNull { it.toLongOrNull() } }\nval readDouble = { readLine()!!.split(\" \").mapNotNull { it.toDoubleOrNull() } }\nfun main() {\n val t = readLine()!!.trim().toInt()\n repeat(t) {\n val (n, k, l) = readInt()\n val p = (0..k).toList() + (k-1 downTo 1).toList()\n val d = listOf(-100) + readInt() + listOf(-100)\n var prev = MutableList(n+2) { false }\n prev[0] = true\n for(time in 1..10000) {\n val cur = MutableList(n+2) { false }\n cur[0] = prev[0]\n cur[cur.lastIndex] = prev[prev.lastIndex]\n for(i in 0..n) {\n if(prev[i]) {\n if(d[i] + p[time%p.size] <= l)\n cur[i] = true\n if(d[i+1] + p[time%p.size] <= l)\n cur[i+1] = true\n }\n }\n prev = cur\n }\n println(if(prev.last()) \"Yes\" else \"No\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c22fa32a23b7799c1fd37117101d3487", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "val debug = false\n\nfun readInt() = readLine()!!.toInt()\nfun readInts() = readLine()!!.split(' ').map { it.toInt() }\n\nfun main() {\n val t = readInt()\n for (i in 1..t) {\n val (_, k, l) = readInts()\n val ds = readInts()\n println(if (solve(k, l, ds)) \"Yes\" else \"No\")\n }\n}\n\nfun tDepth(depth: Int, i: Int, k: Int): Int = if (i <= k) depth + i else depth - (i - k)\n\nfun solve(k: Int, l: Int, ds: List): Boolean {\n val n = ds.size\n val w = 2*k\n var s = Array(w) { true }\n\n for (p in n-1 downTo 0) {\n val depth = ds[p]\n\n var ns = Array(w) { true }\n for (i in 0 until w) {\n ns[i] = tDepth(depth, i, k) <= l && (s[(i + 1) % w])\n }\n for (i in w-1 downTo 0) {\n ns[i] = ns[i] || (tDepth(depth, i, k) <= l && ns[(i + 1) % w])\n }\n\n s = ns\n if (debug) println(\"p=$p, s=${s.contentToString()}, depth=$depth\")\n }\n\n return s.any { it }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2c5162c097967847b025eb8ee30d02da", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "val debug = false\n\nfun readInt() = readLine()!!.toInt()\nfun readInts() = readLine()!!.split(' ').map { it.toInt() }\n\nfun main() {\n val t = readInt()\n for (i in 1..t) {\n val (_, k, l) = readInts()\n val ds = readInts()\n println(if (solve(k, l, ds)) \"Yes\" else \"No\")\n }\n}\n\nfun tDepth(depth: Int, i: Int, k: Int): Int = if (i <= k) depth + i else depth + (i - k)\n\nfun solve(k: Int, l: Int, ds: List): Boolean {\n val n = ds.size\n val w = 2*k\n var s = Array(w) { true }\n\n for (p in n-1 downTo 0) {\n val depth = ds[p]\n\n var ns = Array(w) { true }\n for (i in 0 until w) {\n ns[i] = tDepth(depth, i, k) <= l && (s[(i + 1) % w])\n }\n for (i in w-1 downTo 0) {\n ns[i] = ns[i] || (tDepth(depth, i, k) <= l && ns[(i + 1) % w])\n }\n\n s = ns\n if (debug) println(\"p=$p, s=${s.contentToString()}, depth=$depth\")\n }\n\n return s.any { it }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d14b002e39da84cf0a2099432e019311", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.File\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val onlineJudge = System.getProperty(\"ONLINE_JUDGE\") == \"true\"\n val input = if (onlineJudge) System.`in`.bufferedReader() else File(\"input.txt\").bufferedReader()\n val output = if (onlineJudge) PrintWriter(System.out.writer(), true) else PrintWriter(File(\"output.txt\"))\n\n solve(input, output)\n\n output.flush()\n output.close()\n}\n\nprivate fun String.words() = split(\" \")\n\nprivate fun String.toInts() = split(\" \").map { it.toInt() }\nprivate fun String.toLongs() = split(\" \").map { it.toLong() }\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val p = input.readLine()\n val c = p.last()\n val n = p.dropLast(1).toLong()\n\n var time = 0L\n val byFourRowsBefore = (n - 1) / 4\n time += byFourRowsBefore * 16\n val even = n % 2\n if (even == 0L)\n time += 7\n time += when (c) {\n 'f' -> 1\n 'e' -> 2\n 'd' -> 3\n 'a' -> 4\n 'b' -> 5\n 'c' -> 6\n else -> throw IllegalArgumentException()\n }\n output.println(time)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "656cec5c2f907cdd34477646bbf2b8f9", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"b.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextPair() = nextInt() to nextInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val s = next()\n val n = s.substring(0..s.length-2).toLong() - 1\n val q = (n % 4).toInt()\n val p = n / 4\n val num = arrayOf(4,5,6, 3,2,1)\n val numNum = arrayOf(0,1,0,1)\n val add = num[s.last() - 'a']\n fout.print(p * 16 + numNum[q] * 7 + add)\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ab4057f0e82011e26209340366bbc451", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{\n var pos: String = \"fedabc\"\n val size: Int = 5\n var s: Long = 0\n\n var read = readLine()!!\n var c = read.last()\n var n = read.dropLast(1).toLong()\n\n for(i in 0..size)\n if (c == pos[i]) s = i.toLong() + 1\n\n if (n % 2L == 0L)\n print(((n - 1) / 4) * 16 + s + 7)\n else\n print(((n - 1) / 4) * 16 + s)\n}\n\nfun String.toInts() = split(' ').map { it.toInt() }\nfun String.toLongs() = split(' ').map { it.toLong() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b1d2ba1199c0d58d924eddec3d0c4763", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{\n var pos: String = \"fedabc\"\n val size: Int = 5\n var s: Int = 0\n\n var read = readLine()!!\n var c = read.last()\n var n = read.dropLast(1).toInt()\n\n for(i in 0..size)\n if (c == pos[i]) s = i + 1\n\n if (n % 2 == 0)\n print(((n - 1) / 4) * 16 + s + 7)\n else\n print(((n - 1) / 4) * 16 + s)\n}\n\nfun String.toInts() = split(' ').map { it.toInt() }\nfun String.toLongs() = split(' ').map { it.toLong() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c9a8940fb5c7ea672fd6a76a8526ccb8", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nclass B{\n fun start(scan: Scanner){\n val num = scan.nextInt()\n\n var step = 1\n\n var result = 0\n for (i in 1..num) {\n result += step\n\n if(i % 2 == 0)\n step++\n }\n println(result)\n }\n}\n\nfun main(args: Array) {\n B().start(Scanner(System.`in`))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "040534b84f426e362b8f760c50b9229a", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n var p:List = \"3 3 1 2 3\".split(\" \").map {x -> x.toInt()}\n var n = p[0]\n var a = p[1]\n var b = p[2]\n var c = p[3]\n var d = p[4]\n var A = 0\n var B = a - d\n var C = (B + b) - (c)\n var D = (d + C) - (a)\n var mn = listOf(A, B, C, D).min()!!.toInt()\n if(mn < 1) {\n mn -= 1\n A -= mn\n B -= mn\n C -= mn\n D -= mn\n }\n var mx = listOf(A, B, C, D).max()!!.toInt()\n var res = (n - mx + 1)*(n)\n if(res <= 0) {\n res = 0\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8d57166d48ed1196184f8a12b8bbaf3b", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n var p:List = readLine()!!.split(\" \").map {x -> x.toInt()}\n var n = p[0]\n var a = p[1]\n var b = p[2]\n var c = p[3]\n var d = p[4]\n var A = 0\n var B = a - d\n var C = (B + b) - (c)\n var D = (d + C) - (a)\n var mn = listOf(A, B, C, D).min()!!.toInt()\n if(mn < 1) {\n mn -= 1\n A -= mn\n B -= mn\n C -= mn\n D -= mn\n }\n var mx = listOf(A, B, C, D).max()!!.toInt()\n var res = (n - mx + 1)*(n)\n if(res <= 0) {\n res = 0\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5930416eeef6cbda8324c05930973b4f", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n var p:List = readLine()!!.split(\" \").map {x -> x.toInt()}\n var n = p[0]\n var a = p[1]\n var b = p[2]\n var c = p[3]\n var d = p[4]\n var A = 0\n var B = a - d\n var C = (B + b) - (c)\n var D = (d + C) - (a)\n var mn = listOf(A, B, C, D).min()!!.toInt()\n if(mn < 1) {\n mn -= 1\n A -= mn\n B -= mn\n C -= mn\n D -= mn\n }\n var mx = listOf(A, B, C, D).max()!!.toInt()\n var res = (n - mx + 1)*(n)\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4ddff914d4c21247397036b7b3306b29", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n var p:List = readLine().split(\" \").map {x -> x.toInt()}\n var n = p[0]\n var a = p[1]\n var b = p[2]\n var c = p[3]\n var d = p[4]\n var A = 0\n var B = a - d\n var C = (B + b) - (c)\n var D = (d + C) - (a)\n var mn = listOf(A, B, C, D).min()!!.toInt()\n if(mn < 1) {\n mn -= 1\n A -= mn\n B -= mn\n C -= mn\n D -= mn\n }\n var mx = listOf(A, B, C, D).max()!!.toInt()\n var res = (n - mx + 1)*(n)\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "486910af6fcf409fa4f3ce15225df929", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n var p:List = readLine()!!.split(\" \").map {x -> x.toLong()}\n var n :Long = p[0]\n var a :Long = p[1]\n var b :Long = p[2]\n var c :Long = p[3]\n var d :Long = p[4]\n var A :Long = 0\n var B :Long = a - d\n var C :Long = (B + b) - (c)\n var D :Long = (d + C) - (a)\n var mn :Long = listOf(A, B, C, D).min()!!.toLong()\n if(mn < 1) {\n mn -= 1\n A -= mn\n B -= mn\n C -= mn\n D -= mn\n }\n var mx :Long = listOf(A, B, C, D).max()!!.toLong()\n var res :Long = (n - mx + 1)*(n)\n if(res <= 0) {\n res = 0\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0b90aaad898fc2edc3e0d82dda7a93b5", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "enum class House { RABBIT, OWL, EEYORE }\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n\n val numVisits = readInt()\n val rabbitToOwl = readInt()\n val rabbitToEeyore = readInt()\n val owlToEeyore = readInt()\n var sol = 0\n var state = House.RABBIT\n\n repeat(numVisits - 1) {\n when (state) {\n House.RABBIT -> if (rabbitToOwl <= rabbitToEeyore) {\n state = House.OWL\n sol += rabbitToOwl\n } else {\n state = House.EEYORE\n sol += rabbitToEeyore\n }\n House.OWL -> if (rabbitToOwl <= owlToEeyore) {\n state = House.RABBIT\n sol += rabbitToOwl\n } else {\n state = House.EEYORE\n sol += owlToEeyore\n }\n House.EEYORE -> if (rabbitToEeyore <= owlToEeyore) {\n state = House.RABBIT\n sol += rabbitToEeyore\n } else {\n state = House.OWL\n sol += owlToEeyore\n }\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d86c7afbbddcdf0cf9a661c365f78898", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n var sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var a = sc.nextInt()\n var b = sc.nextInt()\n var c = sc.nextInt()\nval min = mins(a,b,c)\n var res = 0\n if (n == 1) res=0\n else if ( n == 2 ) res = Math.min(a,b)\n else res = min * (n-2) + Math.min(a,b)\n\nprintln(res)\n}\nfun mins ( a : Int , b: Int , c :Int): Int {\n var min = Math.min(a,b)\n return Math.min(min,c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c697bfd78e511990f514e960d82da0be", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val numVisits = readInt()\n val rabbitToOwl = readInt()\n val rabbitToEeyore = readInt()\n val owlToEeyore = readInt()\n var sol = 0\n var house = 0\n val moves = arrayOf(\n intArrayOf(Int.MAX_VALUE, rabbitToOwl, rabbitToEeyore),\n intArrayOf(rabbitToOwl, Int.MAX_VALUE, owlToEeyore),\n intArrayOf(rabbitToEeyore, owlToEeyore, Int.MAX_VALUE)\n )\n\n for (times in 1 until numVisits)\n sol += moves[house].min()!!.also { house = moves[house].indexOf(it) }\n print(sol)\n}\n\n//enum class House { RABBIT, OWL, EEYORE }\n//\n//fun main() {\n// fun readInt() = readLine()!!.toInt()\n//\n// val numVisits = readInt()\n// val rabbitToOwl = readInt()\n// val rabbitToEeyore = readInt()\n// val owlToEeyore = readInt()\n// var sol = 0\n// var state = House.RABBIT\n//\n// repeat(numVisits - 1) {\n// when (state) {\n// House.RABBIT -> if (rabbitToOwl <= rabbitToEeyore) {\n// state = House.OWL\n// sol += rabbitToOwl\n// } else {\n// state = House.EEYORE\n// sol += rabbitToEeyore\n// }\n// House.OWL -> if (rabbitToOwl <= owlToEeyore) {\n// state = House.RABBIT\n// sol += rabbitToOwl\n// } else {\n// state = House.EEYORE\n// sol += owlToEeyore\n// }\n// House.EEYORE -> if (rabbitToEeyore <= owlToEeyore) {\n// state = House.RABBIT\n// sol += rabbitToEeyore\n// } else {\n// state = House.OWL\n// sol += owlToEeyore\n// }\n// }\n// }\n// print(sol)\n//}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6566d00d0eb8774cc72c74950936f256", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n\n println(count(n, a, b, c))\n}\n\nfun count(n: Int, a: Int, b: Int, c: Int): Int {\n val m = Math.min(a,b)\n val allM = Math.min(m, c)\n\n if(n == 1) return 0\n if( n == 2) return m\n if( n > 2) return m + allM *(n - 2)\n\n return 0\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c0b20614e8378f05329925a19acae5d8", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n var sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var a = sc.nextInt()\n var b = sc.nextInt()\n var c = sc.nextInt()\nval min = mins(a,b,c)\n var res = 0\n if (n == 0) res=0\n else if ( n == 1 ) res = Math.min(a,b)\n else res = min * (n-2) + Math.min(a,b)\n\nprintln(res)\n}\nfun mins ( a : Int , b: Int , c :Int): Int {\n var min = Math.min(a,b)\n return Math.min(min,c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e88438b6c53e70d4fe25fc15309d472f", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\nfun main(args: Array) = input.run {\n val p = nextInt()\n var x = nextInt()\n val y = nextInt()\n var ans = 0\n while (x < y) {\n x += 100\n ans++\n }\n while (true) {\n if (ok(x, p) || ans > 0 && ok(x - 50, p)) {\n println(ans)\n return\n }\n x += 100\n ans++\n }\n}\n\nfun ok(s: Int, p: Int): Boolean {\n var i = (s / 50) % 475\n repeat(25) {\n i = (i * 96 + 42) % 475\n if (26 + i == p) {\n return true\n }\n }\n return false\n}\n\nclass Person(val a: Int, val b: Int)\n\nval input = FastScanner()\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = nextString()?.toDouble() ?: 0.0\n fun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO\n fun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO\n\n fun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n fun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\n fun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\n fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\n fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "490be5644ead023774f966b9e764c102", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\nfun main(args: Array) = input.run {\n val p = nextInt()\n var x = nextInt()\n val y = nextInt()\n var z = x\n while (z >= y) {\n if (ok(z, p)) {\n println(0)\n return\n }\n z -= 50\n }\n\n var ans = 1\n x += 100\n while (true) {\n if (ok(x, p) || x - 50 >= y && ok(x - 50, p)) {\n println(ans)\n return\n }\n x += 100\n ans++\n }\n}\n\nfun ok(s: Int, p: Int): Boolean {\n var i = (s / 50) % 475\n repeat(25) {\n i = (i * 96 + 42) % 475\n if (26 + i == p) {\n return true\n }\n }\n return false\n}\n\nval input = FastScanner()\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextString(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = nextString()?.toDouble() ?: 0.0\n fun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO\n fun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO\n\n fun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n fun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\n fun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\n fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\n fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "faac686848f31b94dcdc2f00aee69017", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n val input: InputReader\n val output: PrintWriter\n if (true) {\n input = InputReader(FileInputStream(\"input.txt\"))\n output = PrintWriter(FileOutputStream(\"output.txt\"))\n } else {\n input = InputReader(System.`in`)\n output = PrintWriter(System.out)\n }\n solve(input, output)\n input.close()\n output.close()\n}\n\nfun winPlaces(s: Int): List {\n val places = arrayListOf()\n var i = (s / 50) % 475\n for (j in 1..25) {\n i = (i * 96 + 42) % 475\n places.add(26 + i)\n }\n require(places.size == 25)\n return places\n}\n\nfun solve(input: InputReader, output: PrintWriter) {\n val p = input.nextInt()\n val x = input.nextInt()\n val y = input.nextInt()\n\n var losed = x\n while (losed >= y) {\n if (winPlaces(losed).contains(p)) {\n output.print(0)\n return\n }\n losed -= 50\n }\n\n\n var successfulBreaks = 1\n while (true) {\n val noFails = x + successfulBreaks * 100\n val oneFail = x + successfulBreaks * 100 - 50\n if (winPlaces(noFails).contains(p) || winPlaces(oneFail).contains(p)) {\n output.print(successfulBreaks)\n return\n }\n successfulBreaks += 1\n }\n}\n\nclass InputReader(val stream: InputStream) : Closeable {\n\n var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n\n var tokenizer: StringTokenizer? = null\n\n override fun close() {\n stream.close()\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int = Integer.parseInt(next())\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "af9d24861522bf58bf36499aff5c287f", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import org.w3c.dom.html.HTMLScriptElement\nimport java.io.*\nimport java.util.*\nimport kotlin.collections.*\nimport java.util.TreeMap as Map\nimport java.util.TreeSet as Set\nimport java.util.HashMap as HMap\nimport java.util.HashSet as HSet\nimport java.util.ArrayList as List\nimport java.util.ArrayDeque as Deque\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val pw = PrintWriter(System.out)\n val n = sc.nextInt()\n val l = sc.nextLong()\n val r = sc.nextLong()\n val mod = longArrayOf(r / 3 - (l - 1) / 3, (r + 1) / 3 - l / 3, (r + 2) / 3 - (l + 1) / 3)\n val dp = Array(n) { LongArray(3) }\n dp[0] = mod\n for (i in 1 until n) {\n for (m1 in 0 until 3)\n for (m2 in 0 until 3) {\n dp[i][(m1 + m2) % 3] += dp[i - 1][m1] * mod[m2]\n dp[i][(m1 + m2) % 3] %= 1_000_000_007L\n }\n }\n println(dp[n-1][0])\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6318ad8a799764bee5a46e66476ac57b", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.File\nimport java.lang.Exception\nimport java.util.*\n\nprivate const val MODULO = 1000000007L\n\nfun main() {\n// val scanner = Scanner(File(\"input.txt\"))\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val l = scanner.nextInt()\n val r = scanner.nextInt()\n\n// val optionCount = when {\n// r - l >= 2 -> calculateAllPossible(n, l, r)\n// r - l == 1 -> calculateTwoNumbers(n, l, r)\n// r - l == 0 -> calculateOneNumber(n, l)\n// else -> throw Exception(\"Impossible\")\n// }\n println(calculateAllPossible(n, l, r))\n// println(optionCount)\n}\n\nprivate fun calculateAllPossible(n: Int, l: Int, r: Int): Int {\n val zeroOptions: Long = (r / 3 - (l - 1) / 3).toLong()\n val oneOptions = ((r + 2) / 3 + 1 - (l + 1) / 3 - 1).toLong()\n val twoOptions = ((r + 1) / 3 + 1 - (l) / 3 - 1).toLong()\n\n var zeroTotal: Long = 1L\n var oneTotal: Long = 0L\n var twoTotal: Long = 0L\n\n for (i in (0 until n)) {\n val nextOneTotal = zeroTotal * oneOptions + twoTotal * twoOptions + oneTotal * zeroOptions\n val nextTwoTotal = oneTotal * oneOptions + twoTotal * zeroOptions + zeroTotal * twoOptions\n val nextZeroTotal = oneTotal * twoOptions + twoTotal * oneOptions + zeroTotal * zeroOptions\n\n oneTotal = nextOneTotal\n twoTotal = nextTwoTotal\n zeroTotal = nextZeroTotal\n\n oneTotal %= MODULO\n twoTotal %= MODULO\n zeroTotal %= MODULO\n }\n// val numbers = r - l + 1\n// return ((pow(numbers, n - 1).toLong() * countThreeDividers(l, r).toLong()) % MODULO).toInt()\n return zeroTotal.toInt()\n}\n\nprivate fun calculateTwoNumbers(n: Int, l: Int, r: Int): Int {\n return when {\n n == 1 -> if (r % 3 == 0 || l % 3 == 0) 1 else 0\n n > 1 -> pow(2, n - 2)\n else -> throw Exception(\"Impossible\")\n }\n}\n\nprivate fun calculateOneNumber(n: Int, l: Int): Int {\n return when {\n l % 3 == 0 -> 1\n n % 3 == 0 -> 1\n else -> 0\n }\n}\n\nprivate fun countThreeDividers(l: Int, r: Int): Int {\n val size = r - l + 1\n return when (size % 3) {\n 0 -> size / 3\n 1 -> size / 3 + (if (r % 3 == 0) 1 else 0)\n 2 -> size / 3 + (if (l % 3 == 0) 1 else 0) + (if ((r - 1) % 3 == 0) 1 else 0)\n else -> throw Exception(\"Impossible\")\n }\n}\n\nprivate fun pow(value: Int, power: Int): Int {\n var result = 1L\n for (i in (0L until power.toLong())) {\n result = (result * value) % MODULO\n }\n return result.toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d8ac2571d2904962e4a088ee1cb82458", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.lang.ArithmeticException\n\nfun main() {\n val (n, l, r) = readInts()\n\n // number of possible elements for each modulo 3\n val ele = run {\n val sz = r - l + 1\n val quot = sz / 3\n val rem = sz - quot * 3\n IntArray(3) {\n quot + if((it - l) umod 3 < rem) 1 else 0\n }\n }\n\n\n var d = List(3) { ele[it].toModInt() }\n\n repeat(n-1) {\n val nd = List(3) { i ->\n d[i] * ele[0] +\n d[(i+1)%3] * ele[2] +\n d[(i+2)%3] * ele[1]\n }\n d = nd\n }\n\n println(d[0])\n}\n\ninfix fun Int.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Long) =\n (this % base).let { if(it >= 0) it else it + base }\n\ninfix fun Long.umod(base: Int) =\n (this % base).let { if(it >= 0) it else it + base }\n\nfun Int.modInv(base: Int): Int {\n var s = 0\n var os = 1\n var r = base\n var or = this\n\n while(r != 0) {\n val q = or / r\n or = r.also { r = or - q * r }\n os = s.also { s = os - q * s }\n }\n\n return if(or != 1) throw ArithmeticException(\"$this has no modulo inverse in base $base\")\n else os.let { if(it >= 0) it else it + base }\n}\n\n/** modint inline class, requires hardcoded mod base **/\nconst val MODBASE = 1_000_000_007\n\n@Suppress(\"DEPRECATION\")\ninline fun Int.toModInt() = ModInt(this umod MODBASE)\n@Suppress(\"DEPRECATION\")\ninline fun Long.toModInt() = ModInt((this umod MODBASE).toInt())\n\ninline class ModInt\n@Deprecated(\"use toModInt instead\") constructor(val int: Int) {\n operator fun plus(other: ModInt) = plus(other.int) // MODBASE < 2^30\n operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n operator fun inc() = plus(1)\n\n operator fun minus(other: ModInt) = minus(other.int)\n operator fun minus(other: Int) = (int - other).toModInt()\n operator fun dec() = minus(1)\n\n operator fun times(other: ModInt) = times(other.int)\n operator fun times(other: Int) = (int.toLong() * other).toModInt()\n\n @Suppress(\"DEPRECATION\")\n fun inv() = ModInt(int.modInv(MODBASE))\n\n operator fun div(other: ModInt) = div(other.int)\n operator fun div(other: Int) = times(other.modInv(MODBASE))\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray) {\n @Suppress(\"DEPRECATION\")\n operator fun get(i: Int) = ModInt(intArray[i])\n operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) = ModIntArray(capacity).apply {\n repeat(capacity) { this[it] = init(it) }\n}\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readDouble() = readLn().toDouble()\nfun readLong() = readLn().toLong()\nfun readStrings() = readLn().split(' ')\nfun readInts() = readStrings().map { it.toInt() }\nfun readDoubles() = readStrings().map { it.toDouble() }\nfun readLongs() = readStrings().map { it.toLong() }\n\nclass Output {\n private val sb = StringBuilder()\n fun print(o: Any?) { sb.append(o) }\n fun println() { sb.append('\\n') }\n fun println(o: Any?) { sb.append(o).append('\\n') }\n @JvmName(\"_print\") fun Any?.print() = print(this)\n @JvmName(\"_println\") fun Any?.println() = println(this)\n fun nowPrint() { kotlin.io.print(sb) }\n}\ninline fun output(block: Output.()->Unit)\n { Output().apply(block).nowPrint() }\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f56113936a9dbde9ede0dbeb404c9d69", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun main() {\n val (Hy, Ay, Dy) = readInts()\n val (Hm, Am, Dm) = readInts()\n val (H, A, D) = readLongs()\n\n var ans = 1e18.toLong()\n for (d in 0..max(0, Am - Dy)) {\n for (a in 0..200) { // \u8a08\u7b97\u305f\u3044\u3078\u3093\n val rateM = max(0, Ay + a - Dm)\n val rateY = max(0, Am - Dy - d)\n if (rateM > 0 && rateY == 0) { // \u30c0\u30e1\u30fc\u30b8\u3092\u53d7\u3051\u306a\u3044\n ans = min(ans, A * a + D * d)\n } else if (rateM > 0 && rateY > 0) {\n val turn = (Hm + rateM - 1) / rateM\n val healthNeeded = turn * rateY + 1\n val h = max(0, healthNeeded - Hy)\n ans = min(ans, H * h + A * a + D * d)\n }\n }\n }\n println(ans)\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprivate val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n} catch (t: Throwable) {\n false\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }.toIntArray()\nprivate fun readLongs() = readStrings().map { it.toLong() }.toLongArray()\nprivate inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n}\nprivate fun debug(a: LongArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: IntArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: BooleanArray) {\n debug{a.map{if(it) 1 else 0}.joinToString(\"\")}\n}\nprivate fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cf50fa2539bb2717a76b1194fc0e3d7a", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n val validPrimes = mutableListOf()\n val notPrimes = mutableListOf()\n for (candidate in 2..n / 2) {\n if (candidate !in notPrimes) {\n if (n % candidate == 0)\n validPrimes.add(candidate)\n for (multiplied in candidate + candidate until n / 2 step candidate)\n notPrimes.add(multiplied)\n }\n }\n var sol = mutableSetOf(1, n)\n for (validPrime in validPrimes) {\n val divisors = mutableSetOf(1, n)\n var multiplied = validPrime\n while (multiplied < n) {\n if (n % multiplied == 0)\n divisors.add(multiplied)\n multiplied += validPrime\n }\n if (divisors.size > sol.size) sol = divisors\n }\n print(sol.sortedDescending().joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "54b97ea4b00b55e48e99ea74f98f1f7c", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n fun sieve(limit: Int): List {\n val notPrimes = mutableSetOf()\n val primes = ArrayList()\n for (num in 2..limit) {\n if (num !in notPrimes) {\n primes.add(num)\n var notPrime = num + num\n while (notPrime <= limit) {\n notPrimes.add(notPrime)\n notPrime += num\n }\n }\n }\n return primes\n }\n\n var n = readInt()\n val primes = sieve(n)\n val sol = mutableListOf()\n sol.add(n)\n while (n != 1) {\n for (prime in primes) {\n if (n % prime == 0) {\n sol.add(n / prime)\n n /= prime\n break\n }\n }\n }\n print(sol.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5fa2865ec442d03cb3a151590aa8a4d8", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "//1.1 | RexTester.Com & 1.2 | CodeForces.Com\nfun main(args: Array)\n{\n val(input1, input2) = readLine()!!.split(' ')\n\n val grown_ups = input1.toInt()\n val children = input2.toInt()\n\n if (grown_ups < 1 && children > 0) {\n print(\"Impossible\")\n return\n }\n\n print(\"${Math.max(grown_ups, children)} ${if (children > 0) grown_ups + children - 1 else grown_ups}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9d09a5eaade53b425dbf3a7262d01c63", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "//http://rextester.com Kotlin 1.1\nfun main(args:Array){\n val(a,b)=readLine()!!.split(' ');val c=a.toInt();val d=b.toInt()\n if(c<1&&d>0){print(\"Impossible\");return}\n var e=c+d-1\n if(d==0)e=c\n print(\"${Math.max(c,d)} $e\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "becf099c76784620c2133fef968a95c8", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args:Array){val(x,y)=readLine()!!.split(' ');val a=x.toInt();val b=y.toInt();if(a<1&&b>0){print(\"Impossible\");return};print(\"${Math.max(a,b)} ${if(b>0)a+b-1 else a}\")}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d232fbe45742b78d498fcd5793b8eaa6", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "//rextester.com:1.1--codeforces.com:1.0.5-2\nfun main(args:Array){\n val(z,y)=readLine()!!.split(' ');val a=z.toInt();val b=y.toInt()\n if(a<1&&b>0){print(\"Impossible\");return}\n print(\"${Math.max(a,b)} ${if(b>0)a+b-1 else a}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d95b583beb0d016c58e8c8884d3bb5df", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n if (args.size > 0) System.setIn(FileInputStream(args[0]))\n val br = BufferedReader(InputStreamReader(System.`in`))\n val bw = BufferedWriter(OutputStreamWriter(System.out))\n\n var st = StringTokenizer(br.readLine())\n val n = st.nextToken().toInt()\n val m = st.nextToken().toInt()\n if (n == 0 && m != 0) {\n bw.write(\"Impossible\")\n } else if (m == 0) {\n bw.write(\"${n} ${n}\")\n } else if (n >= m) {\n bw.write(\"${n} ${n + m - 1}\")\n } else {\n bw.write(\"${m} ${n + m - 1}\")\n }\n bw.newLine()\n bw.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c93df0230375ccd6b4534525f74a0224", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "//http://rextester.com Kotlin 1.1\nfun main(args:Array){\n val(a,b)=readLine()!!.split(' ');val c=a.toInt();val d=b.toInt()\n if(c<1&&d>0){print(\"Impossible\");return}\n var e=c+d-1\n if(d==0)e=c\n print(\"${maxOf(c,d)} $e\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5641203f11bd17debfca8275214667cc", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "//http://rextester.com Kotlin 1.1\nimport java.io.*\nimport java.util.*\nfun main(args:Array){\n val(a,b)=readLine()!!.split(' ');val c=a.toInt();val d=b.toInt()\n if(c<1&&d>0){print(\"Impossible\");return}\n var e=c+d-1\n if(d==0)e=c\n print(\"${maxOf(c,d)} $e\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf801be794dc8e6ab2c6d00c27c3299b", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n if (args.size > 0) System.setIn(FileInputStream(args[0]))\n val br = BufferedReader(InputStreamReader(System.`in`))\n val bw = BufferedWriter(OutputStreamWriter(System.out))\n\n var st = StringTokenizer(br.readLine())\n val n = st.nextToken().toInt()\n val m = st.nextToken().toInt()\n if (n == 0) {\n bw.write(\"Impossible\")\n } else if (m == 0) {\n bw.write(\"${n} ${n}\")\n } else if (n >= m) {\n bw.write(\"${n} ${n + m - 1}\")\n } else {\n bw.write(\"${m} ${n + m - 1}\")\n }\n bw.newLine()\n bw.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "968255e4002ef691bbf243c51c4ffd04", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val numDays = readLine()!!.toInt()\n val temps = readLine()!!.split(\" \").map(String::toInt)\n val diff = temps[0] - temps[1]\n for (pos in 0 until numDays - 1)\n if (temps[pos] - temps[pos+ 1] != diff) return print(temps.last())\n print(temps.last() - diff)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6f54d34941010b48c42a712dfb040aa6", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var s = readLine()!!.split(\" \");\n var d = s[1].toInt() - s[0].toInt();\n if (n > 2)\n for (i in 2 until s.count()) {\n if (s[i].toInt() - s[i - 1].toInt() != d) {\n print(s[s.lastIndex]);\n return;\n }\n }\n print(s.last().toInt() + d);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "87a5f3db4cbdb649849cfbb5a9a313c3", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var s = readLine()!!.split(\" \");\n var n_3 = s[n - 1].toInt();\n var n_2 = s[n - 2].toInt();\n var d = (n_3 - n_2);\n if (n == 2) {\n print(n_3 + d);\n }\n else {\n var n_1 = s[n - 3].toInt();\n if (n_2 - n_1 == d)\n print((n_3 + d));\n else\n print(n_3);\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f69557597e0716ff174c891ad04f630", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var s = readLine()!!.split(\" \");\n var a = s[n - 1].toInt() - s[n - 2].toInt();\n print(s[n - 1].toInt() + a);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9fcc9abd877f08ae6d7304fa0d395d3a", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n var a: Int = reader.nextInt()\n var b: Int = reader.nextInt()\n var c: Int = reader.nextInt()\n\n var p = 0\n\n for(i in 0..a step 2){\n for(j in 0..b){\n for(k in 0..c){\n if((i*0.5+j*1+k*2).toInt()==n){\n p++\n }\n }\n }\n }\n println(p)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b476efe0b05cf2fce1bf18d4892463bc", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var n: Int = reader.nextInt()\n var a: Int = reader.nextInt()\n var b: Int = reader.nextInt()\n var c: Int = reader.nextInt()\n var p =0\n for(i in 0..b){\n for(j in 0..c) {\n var cnt = n - i - 2 * j\n if (cnt >= 0 && 2 * cnt <= a) {\n p++\n }\n }\n }\n println(p)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "11313e888b37ca5f2c1819f74c47d5c0", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nval scanner = Scanner(System.`in`)\n\nfun readLong(): Long = scanner.nextLong()\n\nval luckyNumbers = arrayOf(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777, 4444, 4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777, 44444, 44447, 44474, 44477, 44744, 44747, 44774, 44777, 47444, 47447, 47474, 47477, 47744, 47747, 47774, 47777, 74444, 74447, 74474, 74477, 74744, 74747, 74774, 74777, 77444, 77447, 77474, 77477, 77744, 77747, 77774, 77777, 444444, 444447, 444474, 444477, 444744, 444747, 444774, 444777, 447444, 447447, 447474, 447477, 447744, 447747, 447774, 447777, 474444, 474447, 474474, 474477, 474744, 474747, 474774, 474777, 477444, 477447, 477474, 477477, 477744, 477747, 477774, 477777, 744444, 744447, 744474, 744477, 744744, 744747, 744774, 744777, 747444, 747447, 747474, 747477, 747744, 747747, 747774, 747777, 774444, 774447, 774474, 774477, 774744, 774747, 774774, 774777, 777444, 777447, 777474, 777477, 777744, 777747, 777774, 777777, 4444444, 4444447, 4444474, 4444477, 4444744, 4444747, 4444774, 4444777, 4447444, 4447447, 4447474, 4447477, 4447744, 4447747, 4447774, 4447777, 4474444, 4474447, 4474474, 4474477, 4474744, 4474747, 4474774, 4474777, 4477444, 4477447, 4477474, 4477477, 4477744, 4477747, 4477774, 4477777, 4744444, 4744447, 4744474, 4744477, 4744744, 4744747, 4744774, 4744777, 4747444, 4747447, 4747474, 4747477, 4747744, 4747747, 4747774, 4747777, 4774444, 4774447, 4774474, 4774477, 4774744, 4774747, 4774774, 4774777, 4777444, 4777447, 4777474, 4777477, 4777744, 4777747, 4777774, 4777777, 7444444, 7444447, 7444474, 7444477, 7444744, 7444747, 7444774, 7444777, 7447444, 7447447, 7447474, 7447477, 7447744, 7447747, 7447774, 7447777, 7474444, 7474447, 7474474, 7474477, 7474744, 7474747, 7474774, 7474777, 7477444, 7477447, 7477474, 7477477, 7477744, 7477747, 7477774, 7477777, 7744444, 7744447, 7744474, 7744477, 7744744, 7744747, 7744774, 7744777, 7747444, 7747447, 7747474, 7747477, 7747744, 7747747, 7747774, 7747777, 7774444, 7774447, 7774474, 7774477, 7774744, 7774747, 7774774, 7774777, 7777444, 7777447, 7777474, 7777477, 7777744, 7777747, 7777774, 7777777, 44444444, 44444447, 44444474, 44444477, 44444744, 44444747, 44444774, 44444777, 44447444, 44447447, 44447474, 44447477, 44447744, 44447747, 44447774, 44447777, 44474444, 44474447, 44474474, 44474477, 44474744, 44474747, 44474774, 44474777, 44477444, 44477447, 44477474, 44477477, 44477744, 44477747, 44477774, 44477777, 44744444, 44744447, 44744474, 44744477, 44744744, 44744747, 44744774, 44744777, 44747444, 44747447, 44747474, 44747477, 44747744, 44747747, 44747774, 44747777, 44774444, 44774447, 44774474, 44774477, 44774744, 44774747, 44774774, 44774777, 44777444, 44777447, 44777474, 44777477, 44777744, 44777747, 44777774, 44777777, 47444444, 47444447, 47444474, 47444477, 47444744, 47444747, 47444774, 47444777, 47447444, 47447447, 47447474, 47447477, 47447744, 47447747, 47447774, 47447777, 47474444, 47474447, 47474474, 47474477, 47474744, 47474747, 47474774, 47474777, 47477444, 47477447, 47477474, 47477477, 47477744, 47477747, 47477774, 47477777, 47744444, 47744447, 47744474, 47744477, 47744744, 47744747, 47744774, 47744777, 47747444, 47747447, 47747474, 47747477, 47747744, 47747747, 47747774, 47747777, 47774444, 47774447, 47774474, 47774477, 47774744, 47774747, 47774774, 47774777, 47777444, 47777447, 47777474, 47777477, 47777744, 47777747, 47777774, 47777777, 74444444, 74444447, 74444474, 74444477, 74444744, 74444747, 74444774, 74444777, 74447444, 74447447, 74447474, 74447477, 74447744, 74447747, 74447774, 74447777, 74474444, 74474447, 74474474, 74474477, 74474744, 74474747, 74474774, 74474777, 74477444, 74477447, 74477474, 74477477, 74477744, 74477747, 74477774, 74477777, 74744444, 74744447, 74744474, 74744477, 74744744, 74744747, 74744774, 74744777, 74747444, 74747447, 74747474, 74747477, 74747744, 74747747, 74747774, 74747777, 74774444, 74774447, 74774474, 74774477, 74774744, 74774747, 74774774, 74774777, 74777444, 74777447, 74777474, 74777477, 74777744, 74777747, 74777774, 74777777, 77444444, 77444447, 77444474, 77444477, 77444744, 77444747, 77444774, 77444777, 77447444, 77447447, 77447474, 77447477, 77447744, 77447747, 77447774, 77447777, 77474444, 77474447, 77474474, 77474477, 77474744, 77474747, 77474774, 77474777, 77477444, 77477447, 77477474, 77477477, 77477744, 77477747, 77477774, 77477777, 77744444, 77744447, 77744474, 77744477, 77744744, 77744747, 77744774, 77744777, 77747444, 77747447, 77747474, 77747477, 77747744, 77747747, 77747774, 77747777, 77774444, 77774447, 77774474, 77774477, 77774744, 77774747, 77774774, 77774777, 77777444, 77777447, 77777474, 77777477, 77777744, 77777747, 77777774, 77777777, 444444444, 444444447, 444444474, 444444477, 444444744, 444444747, 444444774, 444444777, 444447444, 444447447, 444447474, 444447477, 444447744, 444447747, 444447774, 444447777, 444474444, 444474447, 444474474, 444474477, 444474744, 444474747, 444474774, 444474777, 444477444, 444477447, 444477474, 444477477, 444477744, 444477747, 444477774, 444477777, 444744444, 444744447, 444744474, 444744477, 444744744, 444744747, 444744774, 444744777, 444747444, 444747447, 444747474, 444747477, 444747744, 444747747, 444747774, 444747777, 444774444, 444774447, 444774474, 444774477, 444774744, 444774747, 444774774, 444774777, 444777444, 444777447, 444777474, 444777477, 444777744, 444777747, 444777774, 444777777, 447444444, 447444447, 447444474, 447444477, 447444744, 447444747, 447444774, 447444777, 447447444, 447447447, 447447474, 447447477, 447447744, 447447747, 447447774, 447447777, 447474444, 447474447, 447474474, 447474477, 447474744, 447474747, 447474774, 447474777, 447477444, 447477447, 447477474, 447477477, 447477744, 447477747, 447477774, 447477777, 447744444, 447744447, 447744474, 447744477, 447744744, 447744747, 447744774, 447744777, 447747444, 447747447, 447747474, 447747477, 447747744, 447747747, 447747774, 447747777, 447774444, 447774447, 447774474, 447774477, 447774744, 447774747, 447774774, 447774777, 447777444, 447777447, 447777474, 447777477, 447777744, 447777747, 447777774, 447777777, 474444444, 474444447, 474444474, 474444477, 474444744, 474444747, 474444774, 474444777, 474447444, 474447447, 474447474, 474447477, 474447744, 474447747, 474447774, 474447777, 474474444, 474474447, 474474474, 474474477, 474474744, 474474747, 474474774, 474474777, 474477444, 474477447, 474477474, 474477477, 474477744, 474477747, 474477774, 474477777, 474744444, 474744447, 474744474, 474744477, 474744744, 474744747, 474744774, 474744777, 474747444, 474747447, 474747474, 474747477, 474747744, 474747747, 474747774, 474747777, 474774444, 474774447, 474774474, 474774477, 474774744, 474774747, 474774774, 474774777, 474777444, 474777447, 474777474, 474777477, 474777744, 474777747, 474777774, 474777777, 477444444, 477444447, 477444474, 477444477, 477444744, 477444747, 477444774, 477444777, 477447444, 477447447, 477447474, 477447477, 477447744, 477447747, 477447774, 477447777, 477474444, 477474447, 477474474, 477474477, 477474744, 477474747, 477474774, 477474777, 477477444, 477477447, 477477474, 477477477, 477477744, 477477747, 477477774, 477477777, 477744444, 477744447, 477744474, 477744477, 477744744, 477744747, 477744774, 477744777, 477747444, 477747447, 477747474, 477747477, 477747744, 477747747, 477747774, 477747777, 477774444, 477774447, 477774474, 477774477, 477774744, 477774747, 477774774, 477774777, 477777444, 477777447, 477777474, 477777477, 477777744, 477777747, 477777774, 477777777, 744444444, 744444447, 744444474, 744444477, 744444744, 744444747, 744444774, 744444777, 744447444, 744447447, 744447474, 744447477, 744447744, 744447747, 744447774, 744447777, 744474444, 744474447, 744474474, 744474477, 744474744, 744474747, 744474774, 744474777, 744477444, 744477447, 744477474, 744477477, 744477744, 744477747, 744477774, 744477777, 744744444, 744744447, 744744474, 744744477, 744744744, 744744747, 744744774, 744744777, 744747444, 744747447, 744747474, 744747477, 744747744, 744747747, 744747774, 744747777, 744774444, 744774447, 744774474, 744774477, 744774744, 744774747, 744774774, 744774777, 744777444, 744777447, 744777474, 744777477, 744777744, 744777747, 744777774, 744777777, 747444444, 747444447, 747444474, 747444477, 747444744, 747444747, 747444774, 747444777, 747447444, 747447447, 747447474, 747447477, 747447744, 747447747, 747447774, 747447777, 747474444, 747474447, 747474474, 747474477, 747474744, 747474747, 747474774, 747474777, 747477444, 747477447, 747477474, 747477477, 747477744, 747477747, 747477774, 747477777, 747744444, 747744447, 747744474, 747744477, 747744744, 747744747, 747744774, 747744777, 747747444, 747747447, 747747474, 747747477, 747747744, 747747747, 747747774, 747747777, 747774444, 747774447, 747774474, 747774477, 747774744, 747774747, 747774774, 747774777, 747777444, 747777447, 747777474, 747777477, 747777744, 747777747, 747777774, 747777777, 774444444, 774444447, 774444474, 774444477, 774444744, 774444747, 774444774, 774444777, 774447444, 774447447, 774447474, 774447477, 774447744, 774447747, 774447774, 774447777, 774474444, 774474447, 774474474, 774474477, 774474744, 774474747, 774474774, 774474777, 774477444, 774477447, 774477474, 774477477, 774477744, 774477747, 774477774, 774477777, 774744444, 774744447, 774744474, 774744477, 774744744, 774744747, 774744774, 774744777, 774747444, 774747447, 774747474, 774747477, 774747744, 774747747, 774747774, 774747777, 774774444, 774774447, 774774474, 774774477, 774774744, 774774747, 774774774, 774774777, 774777444, 774777447, 774777474, 774777477, 774777744, 774777747, 774777774, 774777777, 777444444, 777444447, 777444474, 777444477, 777444744, 777444747, 777444774, 777444777, 777447444, 777447447, 777447474, 777447477, 777447744, 777447747, 777447774, 777447777, 777474444, 777474447, 777474474, 777474477, 777474744, 777474747, 777474774, 777474777, 777477444, 777477447, 777477474, 777477477, 777477744, 777477747, 777477774, 777477777, 777744444, 777744447, 777744474, 777744477, 777744744, 777744747, 777744774, 777744777, 777747444, 777747447, 777747474, 777747477, 777747744, 777747747, 777747774, 777747777, 777774444, 777774447, 777774474, 777774477, 777774744, 777774747, 777774774, 777774777, 777777444, 777777447, 777777474, 777777477, 777777744, 777777747, 777777774, 777777777, 4444444444)\n\nfun main() = (readLong()..readLong())\n .let { range ->\n var sum = 0L\n for (i in range) sum += luckyNumbers.first { luckyNumber -> luckyNumber >= i }\n sum\n }\n .run(::println)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e5022077c0207e48980b790b54e959e1", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val k : Int = ir.nextInt()\n var a : Int = ir.nextInt()\n var b : Int = ir.nextInt()\n val v : Int = ir.nextInt()\n var result = 0\n\n while (a > 0) {\n result++\n val min = Math.min(b, k - 1)\n b -= min\n a -= (min + 1) * v\n }\n\n pw.print(result)\n\n /*val T : Int = ir.nextInt()\n\n for (t in 0 until T) {\n val n : Int = ir.nextInt()\n val a = ir.next().toCharArray()\n var start = 0\n var end = 0\n var count = 0\n\n for (i in 0 until n)\n if (a[i] == 's')\n start = i\n else if (a[i] == 'e')\n end = i\n\n if (end > start) {\n for (i in start..end) {\n if (a[i] == '#')\n break\n else if (a[i] == 'o') {\n var next = true\n for (k in (i + 1)..end)\n if (a[k] == '#') {\n next = false\n break\n }\n if (next)\n break\n }\n }\n } else {\n\n }*/\n\n\n }\n\n\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "47e51c24ad1c6aa7c6f2d9ae9dee8732", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n var (maxSections, numNuts, numDivisors, maxNuts) = readInts()\n var numNutsGroups = numNuts / maxNuts + if (numNuts % maxNuts == 0) 0 else 1\n var sol = 0\n while (numNutsGroups > 0 && numDivisors > 0) {\n sol++\n val groupsToPack = min(maxSections, numDivisors + 1)\n numNutsGroups -= groupsToPack\n numDivisors -= (groupsToPack - 1)\n }\n if (numNutsGroups > 0) sol += numNutsGroups\n print(sol)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "db7604e1501dee09ffba2f3cf12025d2", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (hour, minutes) = readLine()!!.split(\":\").map(String::toInt)\n do {\n minutes++\n if (minutes == 60) {\n minutes = 0\n hour++\n if (hour == 24) hour = 0\n }\n } while (String.format(\"%02d\", hour) != String.format(\"%02d\", minutes).reversed())\n print(\"${String.format(\"%02d\", hour)}:${String.format(\"%02d\", minutes)}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6d49c51bb5dd1cb36411b3ca19cfcff1", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val n = r.readLine()!!.toInt()\n var (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n var i = 0\n while (m > 0) {\n if (m >= (i + 1)) {\n m -= (i + 1)\n if (m==0) println(0)\n i = (i + 1) % n\n } else{\n println(m)\n m -= m\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "391c0e20f77f4e196b96c2eedac89c50", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\nfun main(args: Array) {\n var sc = Scanner(System.`in`)\n\n var n = sc.nextInt()\n var m = sc.nextInt()\n var i = 0\n while (m >= 0) {\n var index = (i % n) + 1\n if (m < index) break\n m -= index\n i++\n }\n print(m)\n \n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c749e8ca6147c1dd4255fb94ced4a7d", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val n : Long\n var b : Long\n var h : Long\n var k : Long = 0\n val scan = Scanner(System.`in`)\n n = scan.nextLong()\n b = scan.nextLong()\n h = b\n while (b > 0){\n k++\n h -= k\n if (k == n) k = 0\n b-= k +1\n }\n println(h)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3e61a932a9a44513f949e37449a2bc24", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val n : Long\n var b : Long\n var h : Long\n var k : Long = 0\n val scan = Scanner(System.`in`)\n n = scan.nextLong()\n b = scan.nextLong()\n h = b\n while (b > 0){\n println(k)\n k++\n h -= k\n if (k == n) k = 0\n b-= k +1;\n }\n println(h)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "83a996ddbff5c4a6e04ea936c5216472", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numMonth, dayYearStarts) = readInts()\n val daysPerMonth = listOf(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)\n val dayMonthStarts = (dayYearStarts - 1 + daysPerMonth.subList(0, numMonth).sum()) % 7\n val end = dayMonthStarts + daysPerMonth[numMonth]\n print(end / 7 + if (end % 7 == 0) 0 else 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5310d2fb962ea7f7a179f391e2fbaf47", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n var (numMonth, dayMonthStarts) = readInts()\n dayMonthStarts--\n val daysPerMonth = listOf(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)\n val end = dayMonthStarts + daysPerMonth[numMonth]\n print(end / 7 + if (end % 7 == 0) 0 else 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "03b96ed7a718dab00a709723d79ff5e6", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.min\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val s = reader.next()\n\n var ans = n\n\n for (l in (0 until n / 2).reversed()) {\n val pref = s.slice(0..l)\n val r = 2 * l + 1\n val nexts = s.slice(l + 1..r)\n\n if (pref == nexts) {\n val t = pref.length + 1 + (n - 2 * pref.length)\n ans = min(ans, t)\n }\n }\n writer.println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n val reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "26a1c30d87b05bdabd67bf64ebcfa9fb", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.*\n\nfun check(s: String, start: Int): Boolean {\n for (i in 0 until start) {\n if (start + i >= s.length || s[i] != s[start + i])\n return false\n }\n return true\n}\n\nfun main(args: Array) {\n Scanner(System.`in`.buffered()).use {\n val n = it.nextInt()\n val s = it.next()\n\n var ans = n\n for (i in 1 .. n / 2) {\n if (check(s, i))\n ans = min(ans, i + 1 + n - 2 * i)\n }\n\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "396c2efd61860babc1d073f27dfe3296", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.Comparator\n\n//import kotlin.math.abs\n\nfun main(args: Array) {\n\n var str = readLine()!!\n\n var old: Char = ' '\n var ans = \"\"\n for(elem in str){\n if(elem != '/' || (old != '/')){\n ans += elem;\n }\n old = elem;\n }\n\n if (ans.endsWith(\"/\")){\n ans = ans.substring(0 , ans.length - 1)\n }\n\n print(ans)\n\n}\n\nclass Pair(x: Long, y: Long) {\n var x: Long = x;\n var y: Long = y;\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b343e1e352f931b49cf14425221bff42", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.StringTokenizer\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n println(readLn().replace(Regex(\"\"\"//+\"\"\"), \"/\"))\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a05124e3d7d3aa070a5237ff2d557bec", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nprivate val MOD = 1e9.toInt() + 7\n\nprivate val input = FastScanner()\n\nfun main(args: Array) = input.run {\n withMod(MOD) {\n val t = nextInt()\n val l = nextInt()\n val r = nextInt()\n val f = IntArray(r + 1) { (it * (it - 1L) / 2).mod() }\n\n val p = PrimeSieve(r)\n\n f[1] = 0\n\n (2..r).forEach { n ->\n val x = p.getMinDivisor(n)\n val m = n / x\n f[n] = (n * (x - 1).toLong() / 2).mod() madd f[m]\n }\n\n var ans = 0\n var tt = 1\n (l..r).forEach {\n ans = ans madd (tt mmul f[it])\n tt = tt mmul t\n }\n\n println(ans)\n }\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n\n/**\n * @param mod prime number\n */\nclass Mod(val mod: Int) {\n init {\n assert(mod > 1)\n }\n\n inline fun Long.mod() = (this % mod).toInt().let { if (it < 0) it + mod else it }\n inline fun Long.unsafeMod() = (this % mod).toInt()\n infix inline fun Int.madd(other: Int) = plus(other.toLong()).unsafeMod()\n infix inline fun Int.mmul(other: Int) = times(other.toLong()).unsafeMod()\n\n}\n\ninline fun withMod(mod: Int, action: Mod.() -> T): T = Mod(mod).action()\n\nclass PrimeSieve(maxN: Int) {\n private val minDivisor = IntArray(maxN + 1) { it }\n\n init {\n var n = 2\n while (n * n <= maxN) {\n if (n == minDivisor[n]) {\n (n * n..maxN step n).forEach {\n minDivisor[it] = minDivisor[it].coerceAtMost(n)\n }\n }\n n++\n }\n }\n\n fun getMinDivisor(n: Int) = minDivisor[n]\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6ba761ba540af5a97e1c9b48e78045f6", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val ax = sc.nextLong()\n val ay = sc.nextLong()\n val bx = sc.nextLong()\n val by = sc.nextLong()\n val cx = sc.nextLong()\n val cy = sc.nextLong()\n\n val d1 = (bx - ax) * (bx - ax) + (by - ay) * (by - ay)\n val d2 = (cx - bx) * (cx - bx) + (cy - by) * (cy - by)\n\n when {\n Math.abs((bx - ax) * (cy - ay)) == Math.abs((by - ay) * (cx - ax)) -> println(\"No\")\n d1 != d2 -> println(\"No\")\n else -> println(\"Yes\")\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "74bcbce4b05bbfeab7b4372f182c721b", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val x = sc.nextLong()\n val y = sc.nextLong()\n\n println(solve(x, y))\n}\n\nval mod = (1e9 + 7).toLong()\n\nprivate fun solve(x: Long, y: Long): Long {\n if (y % x != 0L) return 0L\n if( y < x) return 0L\n\n val t = y / x\n\n var sum = 2L pow (t - 1)\n\n if (x != y) sum = (sum - 1 + mod) % mod\n\n var i = 2L\n while (i * i <= t) {\n if (t % i == 0L) sum = (sum - solve(i, t) + mod) % mod\n i += 1\n }\n\n return sum\n}\n\n\n\nprivate infix fun Long.pow(n: Long): Long {\n var a = this\n var n = n % (mod - 1)\n var res = 1L\n while (n > 0) {\n if (n % 2 == 1L) res = res * a % mod\n a = a * a % mod\n n /= 2\n }\n return res\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eed2674c21fc323204f6101056c52313", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val x = sc.nextLong()\n val y = sc.nextLong()\n\n println(solve(x, y))\n}\n\nval mod = (1e9 + 7).toLong()\n\nval res = mutableMapOf()\n\ndata class par(val x: Long, val y: Long)\n\nprivate fun solve(x: Long, y: Long): Long {\n if (res.containsKey(par(x, y))) return res[par(x, y)] ?: throw Exception()\n if (y % x != 0L) return 0L\n if (y < x) return 0L\n\n val t = y / x\n\n var sum = 2L pow (t - 1)\n\n if (x != y) sum = (sum - 1 + mod) % mod\n\n var i = 2L\n while (i * i <= t) {\n if (t % i == 0L) {\n sum = (sum - solve(i, t) + mod) % mod\n\n if (t / i != i) {\n sum = (sum - solve(t / i, t) + mod) % mod\n }\n }\n i += 1\n }\n\n res[par(x, y)] = sum\n return sum\n}\n\n\nprivate infix fun Long.pow(n: Long): Long {\n var a = this\n var n = n % (mod - 1)\n var res = 1L\n while (n > 0) {\n if (n % 2 == 1L) res = res * a % mod\n a = a * a % mod\n n /= 2\n }\n return res\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9f70ed690a08f489110c0b837146aa48", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val x = sc.nextLong()\n val y = sc.nextLong()\n\n println(solve(x, y))\n}\n\nval mod = (1e9 + 7).toLong()\n\nprivate fun solve(x: Long, y: Long): Long {\n if (y % x != 0L) return 0L\n if (y < x) return 0L\n\n val t = y / x\n\n var sum = 2L pow (t - 1)\n\n if (x != y) sum = (sum - 1 + mod) % mod\n\n var i = 2L\n while (i * i <= t) {\n if (t % i == 0L) {\n sum = (sum - solve(i, t) + mod) % mod\n\n if (t / i != i) {\n sum = (sum - solve(t / i, t) + mod) % mod\n }\n }\n i += 1\n }\n\n return sum\n}\n\n\nprivate infix fun Long.pow(n: Long): Long {\n var a = this\n var n = n % (mod - 1)\n var res = 1L\n while (n > 0) {\n if (n % 2 == 1L) res = res * a % mod\n a = a * a % mod\n n /= 2\n }\n return res\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c25bd6827ade8f3a7cfbb9b80eb4316", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val x = sc.nextLong()\n val y = sc.nextLong()\n\n println(solve(x, y))\n}\n\nval mod = (1e9 + 7).toLong()\n\nval res = mutableMapOf()\n\ndata class par(val t: Long)\n\nprivate fun solve(x: Long, y: Long): Long {\n if (y % x != 0L) return 0L\n if (y < x) return 0L\n\n val t = y / x\n if (res.containsKey(par(t))) return res[par(t)] ?: throw Exception()\n\n var sum = 2L pow (t - 1)\n\n if (x != y) sum = (sum - 1 + mod) % mod\n\n var i = 2L\n while (i * i <= t) {\n if (t % i == 0L) {\n sum = (sum - solve(i, t) + mod) % mod\n\n if (t / i != i) {\n sum = (sum - solve(t / i, t) + mod) % mod\n }\n }\n i += 1\n }\n\n res[par(t)] = sum\n return sum\n}\n\n\nprivate infix fun Long.pow(n: Long): Long {\n var a = this\n var n = n % (mod - 1)\n var res = 1L\n while (n > 0) {\n if (n % 2 == 1L) res = res * a % mod\n a = a * a % mod\n n /= 2\n }\n return res\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "174689ee707fdc0eee91498aebdb08e4", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "fun findRow(k: Int, m: Int) = if ((k / 2) % m == 0) (k / 2) / m else (k / 2) / m + 1\n\nfun findDesk(k: Int, m: Int) = if ((k / 2) % m == 0) m else (k / 2) % m\n\nfun main(args: Array) {\n val (n, m, k) = readLine()!!.split(\" \").map(String::toInt)\n var side = 'R'\n var row: Int\n var desk: Int\n if (k % 2 == 0) {\n row = findRow(k, m)\n desk = findDesk(k, m)\n } else {\n row = findRow(k+1, m)\n desk = findDesk(k+1, m)\n side = 'L'\n }\n println(\"$row $desk $side\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1924c1b726116e52370f65aea9b43152", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, desksPerLane, santaPlace) = readInts()\n val lane = santaPlace / (2 * desksPerLane) + if (santaPlace % (2 * desksPerLane) == 0) 0 else 1\n val deskInLane = santaPlace - (lane - 1) * 2 * desksPerLane\n val numRow = (deskInLane + 1) / 2\n print(\"$lane $numRow ${if (santaPlace % 2 == 0) 'R' else 'L'}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1597e844ecd3e8cafa542cfeab3c8ca3", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, m, k) = readLine()!!.split(\" \").map(String::toInt)\n val lane = ((k-1) / (2 * m)) + 1\n val desk = (((k-1)/2) % m) + 1\n val side = if(k%2 == 1) \"L\" else \"R\"\n println(\"$lane $desk $side\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "926814a5ff83d6fab4193eb8dd7a78a4", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, k) = readLine()!!.split(\" \").map(String::toInt)\n\n println(\n if (n == k && n == 1) 0 else readLine()!!.toCharArray()\n .mapIndexed { index, c ->\n if (index == 0 && c > '1' && k > 0) { k--; '1' }\n else if (index > 0 && c > '0' && k > 0) { k--; '0' }\n else { c }\n }.joinToString(separator = \"\")\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c6799d6ba103d841a8fc85f556edd131", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.*\n\nfun main() {\n output {\n val n = readInt()\n var k = readInt()\n val S = readLn().toCharArray()\n\n for(i in 0 until n) {\n if(k == 0) break\n\n val t = if(i == 0 && n > 1) '1' else '0'\n if(S[i] != t) {\n S[i] = t\n k--\n }\n }\n\n println(String(S))\n }\n}\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\nfun iprintln(o: Any?) { println(o) } // immediate println for interactive, bypasses output{} blocks", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "51c4b762e41be5aab71edb5f7c43cd5b", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val k = readLong()\n val b = readLong()\n val n = readLong()\n val t = readLong()\n\n val ans = if(k == 1L) {\n val z = n*b + 1\n max(0, (z - t) divCeil b)\n } else {\n var num = k - 1 + b\n val den = t * (k - 1) + b\n\n var r = n\n while (r > 0 && num < den) {\n num *= k\n if (num <= den) r--\n }\n r\n }\n\n println(ans)\n }\n}\n\ninfix fun Long.divCeil(other: Long) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "414cb7ec27795320f072d84cc8292550", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.util.*\n\nobject program {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n sc.nextLine()\n val all = sc.nextLine()\n var eights = all.filter { it == '8' }.count()\n var others = all.length - eights\n var numbers = 0\n while (eights > 0) {\n eights--\n IntRange(1, 10).forEach {\n if (others > 0)\n others--\n else\n eights--\n }\n if (numbers < 0 || eights < 0)\n break\n numbers++\n }\n println(numbers)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "85a54028010f5b76089407069b7b3d4f", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.util.*\n\nobject A {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n val n = Integer.parseInt(sc.nextLine())\n val all = sc.nextLine()\n var eights = all.filter { it == '8' }.count()\n var others = all.length - eights\n var numbers = 0\n while (eights > 0) {\n eights--\n IntRange(1, 10).forEach {\n if (others > 0)\n others--\n else\n eights--\n }\n if (numbers < 0 || eights < 0)\n break\n numbers++\n }\n println(numbers)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9b40bfd78aab11d6f3473bfa340778f4", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.util.*\n\nobject programkt {\n @JvmStatic fun main(args: Array) {\n if (args.size == 1)\n System.setIn(FileInputStream(args[0]))\n val sc = Scanner(System.`in`)\n sc.nextLine()\n val all = sc.nextLine()\n var eights = all.filter { it == '8' }.count()\n var others = all.length - eights\n var numbers = 0\n while (eights > 0) {\n eights--\n IntRange(1, 10).forEach {\n if (others > 0)\n others--\n else\n eights--\n }\n if (numbers < 0 || eights < 0)\n break\n numbers++\n }\n println(numbers)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e6f187e8a19084b99f6927032d343851", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n readLine()\n val s = readLine()!!\n print(min(s.count { it == '8' }, s.length / 11))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2b73d1e61e28c9ddcd81d5178f90619c", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var digits = readLine()!!.count {it == '8'}\n println(minOf(n / 11, digits))\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d55aeb8772105fbf8399aa643d1ea29b", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n var digits = readLine()!!.count {it == '8'}\n println(minOf(n / 8, digits))\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "74e5c954a8708c383c9c9e5ed1a851fd", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, m, k) = readLine()!!.split(\" \").map { it.toInt() }\n var p = m - n\n var f = 1\n var i = 1\n var j = 1\n\n while(p > 0) {\n f++\n\n if(i != n) {\n if(j < k) {\n i += 2\n j++\n } else {\n i++\n }\n }\n\n p -= i\n }\n\n println(f)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "988125409e9e413fa7a8b2b819147201", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "/**\n * Description: Kotlin tips for dummies\n * Source: own\n */\n\n/* sorting\n * 1 (ok)\n val a = nextLongs().sorted() // a is mutable list\n * 2 (ok)\n val a = arrayListOf() // or ArrayList()\n a.addAll(nextLongs())\n a.sort()\n *.3 (ok)\n val A = nextLongs()\n val a = Array(n,{0})\n for (i in 0..n-1) a[i] = A[i]\n a.sort()\n * 4 (ok)\n val a = ArrayList(nextLongs())\n a.sort()\n * 5 (NOT ok)\n val a = LongArray(N) // or nextLongs().toLongArray()\n Arrays.sort(a)\n */\n/* 2D array\n * val ori = Array(n, {IntArray(n)})\n * val ori = arrayOf(\n intArrayOf(8, 9, 1, 13),\n intArrayOf(3, 12, 7, 5),\n intArrayOf(0, 2, 4, 11),\n intArrayOf(6, 10, 15, 14)\n )\n */\n/* printing variables:\n * println(\"${l+1} and $r\")\n * print d to 8 decimal places: String.format(\"%.8g%n\", d)\n * try to print one stringbuilder instead of multiple prints\n */\n/* comparing pairs\n val pq = PriorityQueue>({x,y -> x.first.compareTo(y.first)})\n val pq = PriorityQueue>(compareBy {it.first})\n val A = arrayListOf(Pair(1,3),Pair(3,2),Pair(2,3))\n val B = A.sortedWith(Comparator>{x,y -> x.first.compareTo(y.first)})\n sortBy\n */\n/* hashmap\n val h = HashMap()\n for (i in 0..n-2) {\n val w = s.substring(i,i+2)\n val c = h.getOrElse(w){0}\n h.put(w,c+1)\n }\n */\n/* basically switch, can be used as expression\n when (x) {\n 0,1 -> print(\"x <= 1\")\n 2 -> print(\"x == 2\")\n else -> { // Note the block\n print(\"x is neither 1 nor 2\")\n }\n }\n*/\n// swap : a = b.also { b = a }\n// arraylist remove element at index: removeAt, not remove ...\n// lower bound: use .binarySearch()\n\nimport java.util.*\n// import kotlin.math.*\n\nval MOD = 1000000007\nval SZ = 1 shl 18\nval INF = (1e18).toLong()\n\nfun add(a: Int, b: Int) = (a+b) % MOD // from tourist :o\nfun sub(a: Int, b: Int) = (a-b+MOD) % MOD\nfun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()\nfun po(a: Int, b: Int): Int {\n if (b == 0) return 1\n var res: Int = po(mul(a,a),b/2)\n if ((b and 1) == 1) res = mul(res,a)\n return res\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\n\nval out = StringBuilder()\nfun YN(b: Boolean):String { return if (b) \"YES\" else \"NO\" }\n\nfun gcd(a: Int, b: Int): Int {\n return if (a == 0) b else gcd(b%a,a)\n}\n\nfun bad() {\n println(-1)\n System.exit(0)\n}\n\nfun ari(a: Int, b: Int): Long {\n return (a+b).toLong()*(b-a+1)/2\n}\n\nfun get(n: Int, k: Int, mid: Int) : Long {\n var res: Long = mid.toLong()\n // println(\"HA ${cur}\")\n // cur-(k-1) to cur-1\n res += ari(maxOf(mid-(k-1),1),mid-1)\n res += ari(maxOf(mid-(n-k),1),mid-1)\n return res\n}\n\nfun solve() {\n val (n,m,k) = nextInts()\n var (lo, hi) = arrayOf(1,m)\n // println(get(n,k,5))\n while (lo < hi) {\n val mid = (lo+hi+1)/2\n if (get(n,k,mid) <= m) lo = mid\n else hi = mid-1\n }\n println(lo)\n}\n\nfun main(args: Array) {\n solve()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d3a3d5a22752902658ec27bf49ee39ab", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "/**\n * Description: Kotlin tips for dummies\n * Source: own\n */\n\n/* sorting\n * 1 (ok)\n val a = nextLongs().sorted() // a is mutable list\n * 2 (ok)\n val a = arrayListOf() // or ArrayList()\n a.addAll(nextLongs())\n a.sort()\n *.3 (ok)\n val A = nextLongs()\n val a = Array(n,{0})\n for (i in 0..n-1) a[i] = A[i]\n a.sort()\n * 4 (ok)\n val a = ArrayList(nextLongs())\n a.sort()\n * 5 (NOT ok)\n val a = LongArray(N) // or nextLongs().toLongArray()\n Arrays.sort(a)\n */\n/* 2D array\n * val ori = Array(n, {IntArray(n)})\n * val ori = arrayOf(\n intArrayOf(8, 9, 1, 13),\n intArrayOf(3, 12, 7, 5),\n intArrayOf(0, 2, 4, 11),\n intArrayOf(6, 10, 15, 14)\n )\n */\n/* printing variables:\n * println(\"${l+1} and $r\")\n * print d to 8 decimal places: String.format(\"%.8g%n\", d)\n * try to print one stringbuilder instead of multiple prints\n */\n/* comparing pairs\n val pq = PriorityQueue>({x,y -> x.first.compareTo(y.first)})\n val pq = PriorityQueue>(compareBy {it.first})\n val A = arrayListOf(Pair(1,3),Pair(3,2),Pair(2,3))\n val B = A.sortedWith(Comparator>{x,y -> x.first.compareTo(y.first)})\n sortBy\n */\n/* hashmap\n val h = HashMap()\n for (i in 0..n-2) {\n val w = s.substring(i,i+2)\n val c = h.getOrElse(w){0}\n h.put(w,c+1)\n }\n */\n/* basically switch, can be used as expression\n when (x) {\n 0,1 -> print(\"x <= 1\")\n 2 -> print(\"x == 2\")\n else -> { // Note the block\n print(\"x is neither 1 nor 2\")\n }\n }\n*/\n// swap : a = b.also { b = a }\n// arraylist remove element at index: removeAt, not remove ...\n// lower bound: use .binarySearch()\n\nimport java.util.*\n// import kotlin.math.*\n\nval MOD = 1000000007\nval SZ = 1 shl 18\nval INF = (1e18).toLong()\n\nfun add(a: Int, b: Int) = (a+b) % MOD // from tourist :o\nfun sub(a: Int, b: Int) = (a-b+MOD) % MOD\nfun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()\nfun po(a: Int, b: Int): Int {\n if (b == 0) return 1\n var res: Int = po(mul(a,a),b/2)\n if ((b and 1) == 1) res = mul(res,a)\n return res\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\n\nval out = StringBuilder()\nfun YN(b: Boolean):String { return if (b) \"YES\" else \"NO\" }\n\nfun gcd(a: Int, b: Int): Int {\n return if (a == 0) b else gcd(b%a,a)\n}\n\nfun bad() {\n println(-1)\n System.exit(0)\n}\n\nfun ari(a: Int, b: Int): Long {\n return (a+b).toLong()*(b-a+1)/2\n}\n\nfun get(a: Int, b: Int): Long {\n if (a <= 0) return 1-a+ari(1,b)\n return ari(a,b)\n}\nfun get(n: Int, k: Int, mid: Int) : Long {\n var res: Long = mid.toLong()\n // println(\"HA ${cur}\")\n // cur-(k-1) to cur-1\n res += get(mid-(k-1),mid-1)\n res += get(mid-(n-k),mid-1)\n return res\n}\n\nfun solve() {\n val (n,m,k) = nextInts()\n var (lo, hi) = arrayOf(1,m)\n // println(get(n,k,5))\n while (lo < hi) {\n val mid = (lo+hi+1)/2\n if (get(n,k,mid) <= m) lo = mid\n else hi = mid-1\n }\n println(lo)\n}\n\nfun main(args: Array) {\n solve()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6448cdc31a8ecee9884313b34fea075d", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n, m, k) = readLine()!!.split(\" \").map { it.toInt() }\n var p = m - n\n var f = 1\n var i = 1\n var j = 1\n\n if(k > n / 2) {\n k = n - k + 1\n }\n\n while(p > 0) {\n f++\n\n if(i != n) {\n if(j < k) {\n i += 2\n j++\n } else {\n i++\n }\n }\n\n p -= i\n }\n\n println(f)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5a1e3c83de0be2ef91d7f196fe67ef50", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "/**\n * Description: Kotlin tips for dummies\n * Source: own\n */\n\n/* sorting\n * 1 (ok)\n val a = nextLongs().sorted() // a is mutable list\n * 2 (ok)\n val a = arrayListOf() // or ArrayList()\n a.addAll(nextLongs())\n a.sort()\n *.3 (ok)\n val A = nextLongs()\n val a = Array(n,{0})\n for (i in 0..n-1) a[i] = A[i]\n a.sort()\n * 4 (ok)\n val a = ArrayList(nextLongs())\n a.sort()\n * 5 (NOT ok)\n val a = LongArray(N) // or nextLongs().toLongArray()\n Arrays.sort(a)\n */\n/* 2D array\n * val ori = Array(n, {IntArray(n)})\n * val ori = arrayOf(\n intArrayOf(8, 9, 1, 13),\n intArrayOf(3, 12, 7, 5),\n intArrayOf(0, 2, 4, 11),\n intArrayOf(6, 10, 15, 14)\n )\n */\n/* printing variables:\n * println(\"${l+1} and $r\")\n * print d to 8 decimal places: String.format(\"%.8g%n\", d)\n * try to print one stringbuilder instead of multiple prints\n */\n/* comparing pairs\n val pq = PriorityQueue>({x,y -> x.first.compareTo(y.first)})\n val pq = PriorityQueue>(compareBy {it.first})\n val A = arrayListOf(Pair(1,3),Pair(3,2),Pair(2,3))\n val B = A.sortedWith(Comparator>{x,y -> x.first.compareTo(y.first)})\n sortBy\n */\n/* hashmap\n val h = HashMap()\n for (i in 0..n-2) {\n val w = s.substring(i,i+2)\n val c = h.getOrElse(w){0}\n h.put(w,c+1)\n }\n */\n/* basically switch, can be used as expression\n when (x) {\n 0,1 -> print(\"x <= 1\")\n 2 -> print(\"x == 2\")\n else -> { // Note the block\n print(\"x is neither 1 nor 2\")\n }\n }\n*/\n// swap : a = b.also { b = a }\n// arraylist remove element at index: removeAt, not remove ...\n// lower bound: use .binarySearch()\n\nimport java.util.*\n// import kotlin.math.*\n\nval MOD = 1000000007\nval SZ = 1 shl 18\nval INF = (1e18).toLong()\n\nfun add(a: Int, b: Int) = (a+b) % MOD // from tourist :o\nfun sub(a: Int, b: Int) = (a-b+MOD) % MOD\nfun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()\nfun po(a: Int, b: Int): Int {\n if (b == 0) return 1\n var res: Int = po(mul(a,a),b/2)\n if ((b and 1) == 1) res = mul(res,a)\n return res\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextInts() = next().split(\" \").map { it.toInt() }\nfun nextLongs() = next().split(\" \").map { it.toLong() }\n\nval out = StringBuilder()\nfun YN(b: Boolean):String { return if (b) \"YES\" else \"NO\" }\n\nfun gcd(a: Int, b: Int): Int {\n return if (a == 0) b else gcd(b%a,a)\n}\n\nfun bad() {\n println(-1)\n System.exit(0)\n}\n\nfun get(n: Int, k: Int, mid: Int) : Long {\n var res: Long = mid.toLong()\n var cur = mid\n // println(\"HA ${cur}\")\n for (i in k-1 downTo 1) {\n cur = maxOf(cur-1,1)\n res += cur\n // println(\"?? ${cur} ${res}\")\n }\n cur = mid\n // println(\"HA ${cur}\")\n for (i in k+1..n) {\n cur = maxOf(cur-1,1)\n res += cur\n // println(\"?? ${cur} ${res}\")\n }\n return res\n}\n\nfun solve() {\n val (n,m,k) = nextInts()\n var (lo, hi) = arrayOf(1,m)\n // println(get(n,k,5))\n while (lo < hi) {\n val mid = (lo+hi+1)/2\n if (get(n,k,mid) <= m) lo = mid\n else hi = mid-1\n }\n println(lo)\n}\n\nfun main(args: Array) {\n solve()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b9242bfb0377babc6718fd964db67380", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun binExp(a: Long, n: Long): Long{\n tailrec fun go(a: Long, n: Long, a1: Long): Long{\n if (n == 0.toLong()) return 1\n if (n == 1.toLong()) return a * a1\n\n if (n % 2 == 0.toLong()) return go(a * a, n/2, a1)\n else return go(a * a, (n - 1)/2, a * a1)\n }\n return go(a, n, 1)\n}\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val n = br.readLine().toInt()\n val x1 = 4*3* binExp(4, (n - 3).toLong())*2\n val x2 = if (n > 3) 4*3*3* binExp(4, (n - 4).toLong())*(n - 3) else 0\n println(x1 + x2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f3e00dc94be6fcdc99c5a1475bae5439", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun binExp(a: Int, n: Int): Int{\n tailrec fun go(a: Int, n: Int, a1: Int): Int{\n if (n == 0) return 1\n if (n == 1) return a * a1\n\n if (n % 2 == 0) return go(a * a, n/2, a1)\n else return go(a * a, (n - 1)/2, a * a1)\n }\n return go(a, n, 1)\n}\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val n = br.readLine().toInt()\n val x1 = 4*3* binExp(4, n - 3)*2\n val x2 = if (n > 3) 4*3*3* binExp(4, n - 4)*(n - 3) else 0\n println(x1 + x2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "313863d3f323168c1436ce4de00cfda8", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var x: Int = reader.nextInt()\n var y: Int = reader.nextInt()\n\n var a = x.toDouble()\n var b = y.toDouble()\n var r = sqrt(a*a+b*b)\n\n if((x>=0 && y>=0) || (x<=0 && y<=0) ){\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 1) {\n println(\"black\")\n } else if (ceil(r).toInt() % 2 == 0) {\n println(\"white\")\n }\n }\n else{\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 1) {\n println(\"white\")\n } else if (ceil(r).toInt() % 2 == 0) {\n println(\"black\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "da71ab9e2a03109de7cb97789d916799", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var x: Int = reader.nextInt()\n var y: Int = reader.nextInt()\n\n var a = x.toDouble()\n var b = y.toDouble()\n var r = sqrt(a*a+b*b)\n\n if((x>=0 && y>=0) || (x<=0 && y<=0) ){\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 1) {\n println(\"black\")\n } else if (ceil(r).toInt() % 2 == 0) {\n println(\"while\")\n }\n }\n else{\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 1) {\n println(\"white\")\n } else if (ceil(r).toInt() % 2 == 0) {\n println(\"black\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "27d80b888eba109dd57f696ef0ece108", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport kotlin.math.ceil\nimport kotlin.math.sqrt\n\nfun main(args : Array) {\n\n val reader = Scanner(System.`in`)\n var x: Int = reader.nextInt()\n var y: Int = reader.nextInt()\n\n var a = x.toDouble()\n var b = y.toDouble()\n var r = sqrt(a*a+b*b)\n\n\n if((x>=0 && y>=0) || (x<=0 && y<=0) ){\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 1) {\n println(\"black\")\n } else if (ceil(r).toInt() % 2 == 0) {\n println(\"white\")\n }\n }\n else{\n if (ceil(r).toInt() == r.toInt() || ceil(r).toInt() % 2 == 0 ) {\n println(\"black\")\n } else if (ceil(r).toInt() % 2 == 1) {\n println(\"white\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8325b0f3544cc8d647621b11276a8b6d", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val visited = mutableMapOf, Int>().withDefault { 0 }\n visited[0 to 0] = 1\n val instructionToMovement = mapOf('U' to (0 to 1), 'D' to (0 to -1), 'L' to (-1 to 0), 'R' to (1 to 0))\n readLine()\n var sol = 0\n var pos = 0 to 0\n for (c in readLine()!!) {\n val movement = instructionToMovement[c]!!\n pos = pos.first + movement.first to pos.second + movement.second\n sol += visited.getValue(pos)\n visited[pos] = visited.getValue(pos) + 1\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e7ccc2a4a3a6dcdd2b0c46759b7bd148", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toLong()\n var sol = n\n while (n > 1) {\n if (n % 2 == 0L) {\n n /= 2\n sol += n\n } else\n for (candidate in 3..n step 2)\n if (n % candidate == 0L) {\n n /= candidate\n sol += n\n break\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f44f6a0616d8447b6faac454920d7ed0", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val scanner = Scanner(System.`in`)\n val input = scanner.next()\n\n if (input.isEmpty()) {\n println(0)\n return\n }\n\n val maxCarry = 5\n var currentCarry = 1\n var firstChar = input[0]\n var result = 1\n\n for (i in 1 until input.length) {\n val nextChar = input[i]\n currentCarry++\n\n if (firstChar != nextChar) {\n firstChar = nextChar\n currentCarry = 1\n }\n\n if (currentCarry == 1) {\n result++\n }\n\n if (currentCarry == maxCarry) {\n currentCarry = 0\n }\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "83546cda542d62aeaf50c3be7bf7bfb0", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val s = readLine()!!\n var current = 'a'\n var count = 0\n var sol = 0\n for (c in s) {\n if (c == current && count < 5) count++\n else {\n sol++\n current = c\n count = 1\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "34861cdfb91b29af572a04eb4799d3b1", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main () {\n val scanner = Scanner(System.`in`)\n val input = scanner.next()\n\n if (input.isEmpty()) {\n println(0)\n return\n }\n\n val maxCarry = 5\n var currentCarry = 1\n var firstChar = input[0]\n var result = 1\n var isFirst = true\n\n for (i in 1 until input.length) {\n val nextChar = input[i]\n\n if (firstChar != nextChar) {\n result++\n firstChar = nextChar\n currentCarry = 1\n } else {\n currentCarry++\n if (currentCarry == maxCarry) {\n if (isFirst) {\n isFirst = false\n } else {\n result++\n }\n currentCarry = 0\n } else if (i == input.length - 1) {\n if (!isFirst) {\n result++\n }\n }\n }\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d21431d699a1abd6504420a05dc4894c", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main () {\n val scanner = Scanner(System.`in`)\n val input = scanner.next()\n\n if (input.isEmpty()) {\n println(0)\n return\n }\n\n val maxCarry = 5\n var currentCarry = 1\n var firstChar = input[0]\n var result = 1\n var isFirst = true\n\n for (i in 1 until input.length) {\n val nextChar = input[i]\n\n if (firstChar != nextChar) {\n result++\n firstChar = nextChar\n currentCarry = 1\n } else {\n currentCarry++\n if (currentCarry == maxCarry) {\n if (isFirst) {\n isFirst = false\n } else {\n result++\n }\n currentCarry = 0\n } else if (i == input.length - 1) {\n if (!isFirst) {\n result++\n }\n }\n }\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "490cf2106a02a95fb9bc0784d26de24e", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n val r = readLine()!!.toInt()\n\n var x = 1\n while (true){\n val y = (r-x*x-x-1)\n if (y%(2*x)==0){\n println(\"$x ${y/(2*x)}\")\n break\n }\n if (y<0){\n println(\"NO\")\n break\n }\n x++\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d3618b1f5647ce0db846f6138e492e1e", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(){\n val r = readLine()!!.toInt()\n\n var x = 1\n while (true){\n val y = (r-x*x-x-1)\n if (y<=0){\n println(\"NO\")\n break\n }\n if (y%(2*x)==0){\n println(\"$x ${y/(2*x)}\")\n break\n }\n\n x++\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ce38ca9c2b32cdf391649cac9439ad78", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!\n var one = 0\n var toCheck = Integer.parseInt(n)\n if (n.length < 2) {\n when (toCheck) {\n 1 -> println(\"one\")\n 2 -> println(\"two\")\n 3 -> println(\"three\")\n 4 -> println(\"four\")\n 5 -> println(\"five\")\n 6 -> println(\"six\")\n 7 -> println(\"seven\")\n 8 -> println(\"eight\")\n 9 -> println(\"nine\")\n }\n } else {\n when (Integer.parseInt(n[0].toString())) {\n 1 -> {\n when (Integer.parseInt(n[1].toString())) {\n 0-> println(\"ten\")\n 1 -> println(\"eleven\")\n 2 -> println(\"twelve\")\n 3 -> println(\"thirteen\")\n 4 -> println(\"fourteen\")\n 5 -> println(\"fifteen\")\n 6 -> println(\"sixteen\")\n 7 -> println(\"seventeen\")\n 8 -> println(\"eighteen\")\n 9 -> println(\"nineteen\")\n }\n }\n 2 -> {\n print(\"twenty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 3 -> {\n print(\"thirty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 4 -> {\n print(\"forty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 5 -> {\n print(\"fifty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 6 -> {\n print(\"sixty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 7 -> {\n print(\"seventy\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 8 -> {\n print(\"eighty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 9 -> {\n print(\"ninety\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n }\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e1b2d3a7835bf08e0c68df94d50bf7a8", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\n\nfun main() {\n var n = readLine()!!\n var one = 0\n var toCheck = Integer.parseInt(n)\n if (toCheck == 11) {\n println(\"eleven\")\n return\n } else if (toCheck == 10) {\n println(\"ten\")\n } else if (toCheck == 12) {\n println(\"twelve\")\n return\n } else if (toCheck == 13) {\n println(\"thirteen\")\n return\n } else if (toCheck == 14) {\n println(\"fourteen\")\n return\n } else if (toCheck == 15) {\n println(\"fifteen\")\n return\n } else if (toCheck == 16) {\n println(\"sixteen\")\n return\n } else if (toCheck == 17) {\n println(\"seventeen\")\n return\n } else if (toCheck == 18) {\n println(\"eighteen\")\n return\n } else if (toCheck == 19) {\n println(\"nineteen\")\n return\n }\n when(toCheck){\n 1 -> print(\"one\")\n 2 -> print(\"two\")\n 3 -> print(\"three\")\n 4 -> print(\"four\")\n 5 -> print(\"five\")\n 6 -> print(\"six\")\n 7 -> print(\"seven\")\n 8 -> print(\"eight\")\n 9 -> print(\"nine\")\n }\n\n\n if (n.length > 1) {\n\n when (Integer.parseInt(n[0].toString())) {\n 2 -> print(\"twenty-\")\n 3 -> print(\"thirty-\")\n 4 -> print(\"forty-\")\n 5 -> print(\"fifty-\")\n 6 -> print(\"sixty-\")\n 7 -> print(\"seventy-\")\n 8 -> print(\"eighty-\")\n 9 -> print(\"ninety-\")\n }\n when (Integer.parseInt(n[1].toString())) {\n 1 -> print(\"one\")\n 2 -> print(\"two\")\n 3 -> print(\"three\")\n 4 -> print(\"four\")\n 5 -> print(\"five\")\n 6 -> print(\"six\")\n 7 -> print(\"seven\")\n 8 -> print(\"eight\")\n 9 -> print(\"nine\")\n }\n\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8dd3049a773dd12c7b87852067a6875e", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!\n var one = 0\n var toCheck = Integer.parseInt(n)\n if (n.length < 2) {\n when (toCheck) {\n 1 -> println(\"one\")\n 2 -> println(\"two\")\n 3 -> println(\"three\")\n 4 -> println(\"four\")\n 5 -> println(\"five\")\n 6 -> println(\"six\")\n 7 -> println(\"seven\")\n 8 -> println(\"eight\")\n 9 -> println(\"nine\")\n }\n } else {\n when (Integer.parseInt(n[0].toString())) {\n 1 -> {\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"ten\")\n 2 -> println(\"twelve\")\n 3 -> println(\"thirteen\")\n 4 -> println(\"fourteen\")\n 5 -> println(\"fifteen\")\n 6 -> println(\"sixteen\")\n 7 -> println(\"seventeen\")\n 8 -> println(\"eighteen\")\n 9 -> println(\"nineteen\")\n }\n }\n 2 -> {\n print(\"twenty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 3 -> {\n print(\"thirty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 4 -> {\n print(\"forty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 5 -> {\n print(\"fifty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 6 -> {\n print(\"sixty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 7 -> {\n print(\"seventy\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 8 -> {\n print(\"eighty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 9 -> {\n print(\"ninety\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n }\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f1826192524ae9c82989d63514d692a5", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n val numToText = listOf(\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\",\n \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fivteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\")\n val tens = listOf(\"\", \"\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\")\n print(\n when {\n n < 20 -> numToText[n]\n n % 10 == 0 -> tens[n / 10]\n else -> tens[n / 10] + '-' + numToText[n % 10]\n }\n )\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "afd1a6eed50674e1464d60b59750e983", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!\n var one = 0\n var toCheck = Integer.parseInt(n)\n if (n.length < 2) {\n when (toCheck) {\n 0-> println(\"zero\")\n 1 -> println(\"one\")\n 2 -> println(\"two\")\n 3 -> println(\"three\")\n 4 -> println(\"four\")\n 5 -> println(\"five\")\n 6 -> println(\"six\")\n 7 -> println(\"seven\")\n 8 -> println(\"eight\")\n 9 -> println(\"nine\")\n }\n } else {\n when (Integer.parseInt(n[0].toString())) {\n 1 -> {\n when (Integer.parseInt(n[1].toString())) {\n 0-> println(\"ten\")\n 1 -> println(\"eleven\")\n 2 -> println(\"twelve\")\n 3 -> println(\"thirteen\")\n 4 -> println(\"fourteen\")\n 5 -> println(\"fifteen\")\n 6 -> println(\"sixteen\")\n 7 -> println(\"seventeen\")\n 8 -> println(\"eighteen\")\n 9 -> println(\"nineteen\")\n }\n }\n 2 -> {\n print(\"twenty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 3 -> {\n print(\"thirty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 4 -> {\n print(\"forty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 5 -> {\n print(\"fifty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 6 -> {\n print(\"sixty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 7 -> {\n print(\"seventy\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 8 -> {\n print(\"eighty\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n 9 -> {\n print(\"ninety\")\n when (Integer.parseInt(n[1].toString())) {\n 1 -> println(\"-one\")\n 2 -> println(\"-two\")\n 3 -> println(\"-three\")\n 4 -> println(\"-four\")\n 5 -> println(\"-five\")\n 6 -> println(\"-six\")\n 7 -> println(\"-seven\")\n 8 -> println(\"-eight\")\n 9 -> println(\"-nine\")\n }\n }\n }\n }\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0801e522e47d561709b1db88db93c6f6", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numRows, numCols, numViolas, minimumViolas) = readInts()\n val grid = Array(numRows) { BooleanArray(numCols) }\n repeat(numViolas) {\n val (row, col) = readInts()\n grid[row - 1][col - 1] = true\n }\n var sol = 0\n for (rowStart in 0 until numRows)\n for (rowEnd in 0 until numRows)\n for (colStart in 0 until numCols)\n for (colEnd in 0 until numCols) {\n var sum = 0\n for (row in rowStart..rowEnd)\n for (col in colStart..colEnd)\n if (grid[row][col]) sum++\n if (sum >= minimumViolas) sol++\n }\n print(sol)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0eebd0ec56c07738ad6e9621a25d1846", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val r: Int = ir.nextInt()\n val c: Int = ir.nextInt()\n val n: Int = ir.nextInt()\n val k: Int = ir.nextInt()\n val x = IntArray(n)\n val y = IntArray(n)\n\n for (i in 0 until n) {\n x[i] = ir.nextInt()\n y[i] = ir.nextInt()\n }\n\n var answer = 0\n\n for (i in 1..r) {\n for (j in 1..c) {\n for (ii in i..r) {\n for (jj in j..c) {\n var count = 0\n for (l in 0 until n) {\n if (x[l] >= i && x[l] <= ii && y[l] >= j && y[l] <= jj) {\n count++\n }\n }\n if (count >= k) {\n answer++\n }\n }\n }\n }\n }\n pw.println(answer)\n\n}\n\n\n\nprivate fun sort(array: IntArray, barray: IntArray, low: Int, high: Int) {\n\n var i = low\n var j = high\n val x = array[low + (high - low) / 2]\n\n do {\n while (array[i] < x) ++i\n while (array[j] > x) --j\n if (i <= j) {\n val tmp = array[i]\n array[i] = array[j]\n array[j] = tmp\n\n val pmt = barray[i]\n barray[i] = barray[j]\n barray[j] = pmt\n\n i++\n j--\n }\n } while (i <= j)\n\n if (low < j) sort(array, barray, low, j)\n if (i < high) sort(array, barray, i, high)\n\n}\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "84a7caf6c756fd2e07d0335ca37dd212", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Kotlin 1.4", "source_code": "// 2022.06.28 at 23:59:56 HKT\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.system.measureTimeMillis\r\nimport java.util.TreeMap\r\nimport java.util.TreeSet\r\nimport kotlin.random.Random\r\nimport kotlin.random.nextInt\r\n\r\n// 1. Modded\r\nconst val p = 1000000007L\r\nconst val pI = p.toInt()\r\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\r\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\r\ninfix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\nfun intPow(x:Int,e:Int,m:Int):Int{\r\n var X = x ; var E =e ; var Y = 1\r\n while(E > 0){\r\n if(E and 1 == 0){\r\n X = ((1L * X * X) % m).toInt()\r\n E = E shr 1\r\n }else{\r\n Y = ((1L * X * Y) % m).toInt()\r\n E -= 1\r\n }\r\n }\r\n return Y\r\n}\r\n// 2. DP initial values\r\nconst val plarge = 1_000_000_727\r\nconst val nlarge = -plarge\r\nconst val phuge = 2_727_000_000_000_000_000L\r\nconst val nhuge = -phuge\r\n// 3. conveniecen conversions\r\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\r\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\r\n//3. hard to write stuff\r\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\r\nval mint:MutableList get() = mutableListOf()\r\nval mong:MutableList get() = mutableListOf()\r\n//4. more outputs\r\nfun List.conca():String = this.joinToString(\"\")\r\nval CharArray.conca :String get() = this.joinToString(\"\")\r\nval IntArray.conca :String get() = this.joinToString(\" \")\r\n@JvmName(\"concaInt\")\r\nfun List.conca():String = this.joinToString(\" \")\r\nval LongArray.conca:String get() = this.joinToString(\" \")\r\n@JvmName(\"concaLong\")\r\nfun List.conca():String = this.joinToString(\" \")\r\n//5. Pair of ints\r\nconst val longmask = (1L shl 32) - 1\r\nfun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly\r\nval Long.first get() = (this ushr 32).toInt()\r\nval Long.second get() = this.toInt()\r\n//6. strings\r\nval String.size get() = this.length\r\nconst val randCount = 100\r\n//7. bits\r\nfun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)\r\nfun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)\r\n//8 TIME\r\ninline fun TIME(f:()->Unit){\r\n val t = measureTimeMillis(){\r\n f()\r\n }\r\n println(\"$t ms\")\r\n}\r\nobject Reader{\r\n private const val BS = 1 shl 16\r\n private const val NC = 0.toChar()\r\n private val buf = ByteArray(BS)\r\n private var bId = 0\r\n private var size = 0\r\n private var c = NC\r\n\r\n var warningActive = true\r\n var fakein = StringBuilder()\r\n\r\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\r\n val OUT: PrintWriter = PrintWriter(System.out)\r\n\r\n private val char: Char\r\n get() {\r\n while (bId == size) {\r\n size = IN.read(buf) // no need for checked exceptions\r\n if (size == -1) return NC\r\n bId = 0\r\n }\r\n return buf[bId++].toChar()\r\n }\r\n\r\n fun nextInt(): Int {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextLong(): Long {\r\n var neg = false\r\n if (c == NC) c = char\r\n while (c < '0' || c > '9') {\r\n if (c == '-') neg = true\r\n c = char\r\n }\r\n var res = 0L\r\n while (c in '0'..'9') {\r\n res = (res shl 3) + (res shl 1) + (c - '0')\r\n c = char\r\n }\r\n return if (neg) -res else res\r\n }\r\n fun nextString():String{\r\n val ret = StringBuilder()\r\n while (true){\r\n c = char\r\n if(!isWhitespace(c)){ break}\r\n }\r\n ret.append(c)\r\n while (true){\r\n c = char\r\n if(isWhitespace(c)){ break}\r\n ret.append(c)\r\n }\r\n return ret.toString()\r\n }\r\n fun isWhitespace(c:Char):Boolean{\r\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\r\n }\r\n fun rerouteInput(){\r\n if(warningActive){\r\n put(\"Custom test enabled\")\r\n println(\"Custom test enabled\")\r\n warningActive = false\r\n }\r\n val S = fakein.toString()\r\n println(\"New Case \")\r\n println(S.take(80))\r\n println(\"...\")\r\n fakein.clear()\r\n IN = BufferedInputStream(S.byteInputStream(),BS)\r\n }\r\n fun takeFile(name:String){\r\n IN = BufferedInputStream(File(name).inputStream(),BS)\r\n }\r\n}\r\nfun put(aa:Any){ Reader.OUT.println(aa)}\r\nfun done(){ Reader.OUT.close() }\r\nfun share(aa:Any){\r\n if(aa is IntArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is LongArray){Reader.fakein.append(aa.joinToString(\" \"))}\r\n else if(aa is List<*>){Reader.fakein.append(aa.toString())}\r\n else{Reader.fakein.append(aa.toString())}\r\n Reader.fakein.append(\"\\n\")\r\n}\r\n\r\nval getintfast:Int get() = Reader.nextInt()\r\nval getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }\r\nval getlong:Long get() = Reader.nextLong()\r\nval getstr:String get() = Reader.nextString()\r\nfun getline(n:Int):IntArray{\r\n return IntArray(n){getint}\r\n}\r\nfun getlineL(n:Int):LongArray{\r\n return LongArray(n){getlong}\r\n}\r\nvar dmark = -1\r\ninfix fun Any.dei(a:Any){\r\n dmark++\r\n var str = \"<${dmark}> \"\r\n debug()\r\n if(this is String){ str += this\r\n }else if(this is Int){ str += this.toString()\r\n }else if(this is Long){ str += this.toString()\r\n }else{ str += this.toString()}\r\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\r\n }else if(a is BooleanArray){ println(\"$str :${a.map{if(it)'1' else '0'}.joinToString(\" \")}\")\r\n }else if(a is Array<*>){\r\n println(\"$str : \")\r\n for(c in a){if(c is IntArray){println(c.joinToString(\" \"))}\r\n else if(c is LongArray){println(c.joinToString(\" \"))}\r\n else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(\"\"))\r\n }\r\n }\r\n println()\r\n }else{ println(\"$str : $a\")\r\n }\r\n}\r\nval just = \" \"\r\nfun crash(){\r\n throw Exception(\"Bad programme\")}\r\nfun assert(a:Boolean){\r\n if(!a){\r\n throw Exception(\"Failed Assertion\")\r\n }}\r\nenum class solveMode {\r\n real, rand, tc\r\n}\r\nobject solve{\r\n var mode:solveMode = solveMode.real\r\n var tcNum:Int = 0\r\n var rand:()->Unit = {}\r\n var TC:MutableMapUnit> = mutableMapOf()\r\n var tn:Long = 0\r\n fun cases(onecase:()->Unit){\r\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\r\n if(pI != 998_244_353 && pI != 1_000_000_007){\r\n throw Exception(\"Not usual primes!\")\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n tn = System.currentTimeMillis()\r\n }\r\n repeat(t){\r\n if(mode == solveMode.tc){\r\n TC[tcNum]?.let { it() }\r\n Reader.rerouteInput()\r\n }else if(mode == solveMode.rand){\r\n rand()\r\n Reader.rerouteInput()\r\n }\r\n onecase()\r\n }\r\n if(t == 1 && mode != solveMode.real){\r\n val dt = System.currentTimeMillis() - tn\r\n println(\"Time $dt ms \")\r\n }\r\n }\r\n inline fun singleCase(a:solve.()->Unit){\r\n val t = if(mode != solveMode.rand){1} else randCount\r\n repeat(t) { a() }\r\n }\r\n fun rand(a:()->Unit){\r\n this.rand = a\r\n }\r\n fun tc(id:Int = 0,a:()->Unit){\r\n TC[id] = a\r\n }\r\n fun usetc(a:Int = 0 ){\r\n this.tcNum = a\r\n this.mode = solveMode.tc\r\n }\r\n fun userand(){\r\n this.mode = solveMode.rand\r\n }\r\n}\r\nfun debug(){}\r\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n var s = getstr\r\n if(s.all { it == '0' }) {\r\n put(-1)\r\n return@cases\r\n }\r\n var start = 0\r\n while(s.first() == '0'){\r\n start++\r\n s= s.drop(1)\r\n }\r\n while(s.last() == '0'){\r\n s = s.dropLast(1)\r\n }\r\n val n = s.size\r\n if(n ==1){\r\n put(\"${1 + start} ${2 + start}\")\r\n return@cases\r\n }\r\n var forwardmask = 0L\r\n for(i in 1 until n){\r\n if(s[i] == '1'){\r\n forwardmask = forwardmask xor ( 1L shl (i-1))\r\n }\r\n }\r\n fun next(x:Long):Long {\r\n var new = x shr 1\r\n if(x and 1L == 1L){\r\n new = new xor forwardmask\r\n }\r\n return new\r\n }\r\n fun previous(x:Long):Long{\r\n var new:Long\r\n if(x and (1L shl (n-2)) != 0L){\r\n new = (((x xor forwardmask) shl 1) and ((1L shl (n-1)) - 1 )) or 1L\r\n }else{\r\n new = (x shl 1) and ((1L shl (n-1)) - 1 )\r\n }\r\n return new\r\n }\r\n fun Long.binary():String{\r\n val ret = CharArray(n-1){if((this and (1L shl it)) != 0L)'1' else '0' }\r\n return ret.conca\r\n }\r\n fun getinverse(k:Int):LongArray{\r\n var now = 1L\r\n val last = mong\r\n last.add(now)\r\n repeat(k + (n-2)){\r\n last.add(previous(last.last()))\r\n }\r\n return last.takeLast(n-1).toLongArray()\r\n }\r\n fun calculate(M:LongArray,start:Long):Long{\r\n var ret = 0L\r\n for(i in 0 until n-1){\r\n if(start.has(i)){\r\n ret = ret xor M[i]\r\n }\r\n }\r\n return ret\r\n }\r\n\r\n fun solve():Long{\r\n val cut = 1 shl 18\r\n val new = LongArray(cut)\r\n new[0]= 1L\r\n for(i in 1 until cut){\r\n new[i] = next(new[i-1])\r\n if(new[i] == 1L){\r\n return i.toLong()\r\n }\r\n }\r\n val invert1 = getinverse(cut)\r\n val map = mutableMapOf()\r\n for((i,v) in new.withIndex()){\r\n map[v] = i\r\n }\r\n var now = 1L\r\n var res = 0L\r\n repeat(1 shl 18){\r\n now = calculate(invert1,now)\r\n res += cut\r\n if(map[now] != null){\r\n return map[now]!! + res\r\n }\r\n }\r\n crash()\r\n return 0L\r\n }\r\n val ans = solve()\r\n put(start+ 1)\r\n put(start + 1 + ans)\r\n// just dei now.binary()\r\n// repeat(100){it ->\r\n// val new = next(now)\r\n// val old = previous(new)\r\n// assert(old == now)\r\n// now = new\r\n//\r\n// val M = getinverse(it + 1 )\r\n// assert(calculate(M,new) == 1L )\r\n//\r\n// just dei now.binary()\r\n// }\r\n\r\n\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n/*\r\n1011\r\n100111\r\n1000101\r\n10000001\r\n\r\n */\r\n\r\n\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "243c346eef0a1cca1c58299853a4c49d", "src_uid": "6bf798edef30db7d0ce2130e40084e6b", "difficulty": 2900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n print(if (n < 3) -1 else (n downTo 1).joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "20a817b136985a2cb2fcf04e2c05e4b9", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.File\nimport java.io.PrintWriter\n\nfun main(args: Array) {\n val onlineJudge = System.getProperty(\"ONLINE_JUDGE\") == \"true\"\n val input = if (onlineJudge) System.`in`.bufferedReader() else File(\"input.txt\").bufferedReader()\n val output = if (onlineJudge) PrintWriter(System.out.writer(), true) else PrintWriter(File(\"output.txt\"))\n\n solve(input, output)\n\n output.flush()\n output.close()\n}\n\nprivate fun String.words() = split(\" \")\n\nprivate fun String.toInts() = split(\" \").map { it.toInt() }\nprivate fun String.toLongs() = split(\" \").map { it.toLong() }\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val n = input.readLine()\n val l = input.readLine()\n val r = \"ogo(go)*\".toRegex()\n val o = r.replace(l, \"***\")\n output.println(o)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5ec2e4f46701128804f01560cbfe8dd5", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintStream\n\nval Number.i: Int get() = this.toInt()\nval Number.l: Long get() = this.toLong()\nval Number.f: Float get() = this.toFloat()\nval Number.d: Double get() = this.toDouble()\nval String.i: Int get() = this.toInt()\nval String.l: Long get() = this.toLong()\nval String.f: Float get() = this.toFloat()\nval String.d: Double get() = this.toDouble()\nval Boolean.i: Int get() = if (this) 1 else 0\n\noperator fun List.component6() = this[5]\n\nfun main() = BufferedReader(InputStreamReader(System.`in`)).use { solve(it, System.out) }\n\nfun solve(input: BufferedReader, output: PrintStream) {\n val (x0, y0, x1, y1, x2, y2) = input.readLine().split(' ').map { it.i }\n output.println(\n when {\n isGoodStraight(x0, y0, x1, y1, x2, y2) -> \"RIGHT\"\n isAlmost(x0, y0, x1, y1, x2, y2) -> \"ALMOST\"\n else -> \"NEITHER\"\n }\n )\n}\n\nfun isStraight(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) = (x0 == x1 && y0 == y2) || (x0 == x2 && y0 == y1)\nfun isAlmost(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) = (false ||\n isGoodStraight(x0 - 1, y0, x1, y1, x2, y2) ||\n isGoodStraight(x0 + 1, y0, x1, y1, x2, y2) ||\n isGoodStraight(x0, y0 - 1, x1, y1, x2, y2) ||\n isGoodStraight(x0, y0 + 1, x1, y1, x2, y2) ||\n\n isGoodStraight(x0, y0, x1 - 1, y1, x2, y2) ||\n isGoodStraight(x0, y0, x1 + 1, y1, x2, y2) ||\n isGoodStraight(x0, y0, x1, y1 - 1, x2, y2) ||\n isGoodStraight(x0, y0, x1, y1 + 1, x2, y2) ||\n\n isGoodStraight(x0, y0, x1, y1, x2 - 1, y2) ||\n isGoodStraight(x0, y0, x1, y1, x2 + 1, y2) ||\n isGoodStraight(x0, y0, x1, y1, x2, y2 - 1) ||\n isGoodStraight(x0, y0, x1, y1, x2, y2 + 1)\n )\n\nfun isGoodStraight(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) =\n (true &&\n !(x0 == x1 && y0 == y1) &&\n !(x0 == x2 && y0 == y2) &&\n !(x2 == x1 && y2 == y1)\n ) && (0 +\n isStraight(x0, y0, x1, y1, x2, y2).i +\n isStraight(x1, y1, x0, y0, x2, y2).i +\n isStraight(x2, y2, x0, y0, x1, y1).i) == 1", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "66f36ac824c58254f7aa6517c5d679b6", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintStream\n\nval Number.i: Int get() = this.toInt()\nval Number.l: Long get() = this.toLong()\nval Number.f: Float get() = this.toFloat()\nval Number.d: Double get() = this.toDouble()\nval String.i: Int get() = this.toInt()\nval String.l: Long get() = this.toLong()\nval String.f: Float get() = this.toFloat()\nval String.d: Double get() = this.toDouble()\nval Boolean.i: Int get() = if (this) 1 else 0\n\noperator fun List.component6() = this[5]\n\nfun main() = BufferedReader(InputStreamReader(System.`in`)).use { solve(it, System.out) }\n\nfun solve(input: BufferedReader, output: PrintStream) {\n val (x0, y0, x1, y1, x2, y2) = input.readLine().split(' ').map { it.i }\n if (isGoodStraight(x0, y0, x1, y1, x2, y2))\n output.println(\"RIGHT\")\n else if (isAlmost(x0, y0, x1, y1, x2, y2))\n output.println(\"ALMOST\")\n else\n output.println(\"NEITHER\")\n}\n\nfun isStraight(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) = (x0 == x1 && y0 == y2) || (x0 == x2 && y0 == y1)\nfun isAlmost(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) = (false ||\n isGoodStraight(x0 - 1, y0, x1, y1, x2, y2) ||\n isGoodStraight(x0 + 1, y0, x1, y1, x2, y2) ||\n isGoodStraight(x0, y0 - 1, x1, y1, x2, y2) ||\n isGoodStraight(x0, y0 + 1, x1, y1, x2, y2) ||\n\n isGoodStraight(x0, y0, x1 - 1, y1, x2, y2) ||\n isGoodStraight(x0, y0, x1 + 1, y1, x2, y2) ||\n isGoodStraight(x0, y0, x1, y1 - 1, x2, y2) ||\n isGoodStraight(x0, y0, x1, y1 + 1, x2, y2) ||\n\n isGoodStraight(x0, y0, x1, y1, x2 - 1, y2) ||\n isGoodStraight(x0, y0, x1, y1, x2 + 1, y2) ||\n isGoodStraight(x0, y0, x1, y1, x2, y2 - 1) ||\n isGoodStraight(x0, y0, x1, y1, x2, y2 + 1)\n )\n\nfun isGoodStraight(x0: Int, y0: Int, x1: Int, y1: Int, x2: Int, y2: Int) =\n (isStraight(x0, y0, x1, y1, x2, y2).i +\n isStraight(x1, y1, x0, y0, x2, y2).i +\n isStraight(x2, y2, x0, y0, x1, y1).i) == 1", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a1db9c1287bd97d34ae7e7148292cada", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintStream\n\nval Number.i: Int get() = this.toInt()\nval Number.l: Long get() = this.toLong()\nval Number.f: Float get() = this.toFloat()\nval Number.d: Double get() = this.toDouble()\nval String.i: Int get() = this.toInt()\nval String.l: Long get() = this.toLong()\nval String.f: Float get() = this.toFloat()\nval String.d: Double get() = this.toDouble()\nval Boolean.i: Int get() = if (this) 1 else 0\n\noperator fun List.component6() = this[5]\n\nfun main() = BufferedReader(InputStreamReader(System.`in`)).use { solve(it, System.out) }\n\nfun solve(input: BufferedReader, output: PrintStream) {\n val (x0, y0, x1, y1, x2, y2) = input.readLine().split(' ').map { it.l }\n\n output.println(\n if (isGood(x0, y0, x1, y1, x2, y2)) \"RIGHT\"\n else if (\n isGood(x0 - 1, y0, x1, y1, x2, y2) ||\n isGood(x0 + 1, y0, x1, y1, x2, y2) ||\n isGood(x0, y0 - 1, x1, y1, x2, y2) ||\n isGood(x0, y0 + 1, x1, y1, x2, y2) ||\n\n isGood(x0, y0, x1 - 1, y1, x2, y2) ||\n isGood(x0, y0, x1 + 1, y1, x2, y2) ||\n isGood(x0, y0, x1, y1 - 1, x2, y2) ||\n isGood(x0, y0, x1, y1 + 1, x2, y2) ||\n\n isGood(x0, y0, x1, y1, x2 - 1, y2) ||\n isGood(x0, y0, x1, y1, x2 + 1, y2) ||\n isGood(x0, y0, x1, y1, x2, y2 - 1) ||\n isGood(x0, y0, x1, y1, x2, y2 + 1)\n ) \"ALMOST\"\n else \"NEITHER\"\n )\n}\n\nfun l(x0: Long, y0: Long, x1: Long, y1: Long) = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)\nfun isGood(x0: Long, y0: Long, x1: Long, y1: Long, x2: Long, y2: Long) = isGood(l(x0, y0, x1, y1), l(x0, y0, x2, y2), l(x1, y1, x2, y2))\nfun isGood(a: Long, b: Long, c: Long) =\n if (a == 0L || b == 0L || c == 0L)\n false\n else if (a > b && a > c)\n a - b - c == 0L\n else if (b > a && b > c)\n b - a - c == 0L\n else\n c - a - b == 0L\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c9a1cb2bbbea58de5010169882ad629", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport kotlin.system.measureTimeMillis\n\nfun solve(input: BufferedReader, out: BufferedWriter) {\n val s = input.readLine()\n var result: String? = null\n for (match in Regex(\"at\").findAll(s, 1)) {\n val r = match.groups[0]!!.range\n if (r.endInclusive + 1 < s.length) {\n val s1 = s.substring(1, r.start)\n val s2 = s.substring(r.endInclusive + 1, s.length - 1)\n val t = s.first() + s1.replace(\"dot\", \".\") + \"@\" + s2.replace(\"dot\", \".\") + s.last()\n result = result?.let { listOf(it, t).minBy {x -> x.length } } ?: t\n }\n }\n println(result)\n}\n\nfun main(args: Array) {\n// val i = File(\"input.txt\").bufferedReader()\n// val o = File(\"output.txt\").bufferedWriter()\n val i = System.`in`.bufferedReader()\n val o = System.`out`.bufferedWriter()\n System.err.println(\"time = ${measureTimeMillis {\n solve(i, o)\n }}ms\")\n o.close()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "568c0a6eee10534cd27f94c61411146d", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val P = ns().filterNot { it == '.' }.toInt()\n val T = ni()\n val dp = Array(T + 1){DoubleArray(T + 1)}\n dp[0][0] = 1.0\n for (n in 1..T) {\n for (k in 0 .. n) {\n if (n - 1 >= k) dp[n][k] += dp[n - 1][k]\n if (k - 1 >= 0) dp[n][k] += dp[n - 1][k - 1]\n }\n }\n\n val ps = DoubleArray(T + 1)\n ps[0] = 1.0\n val qs = DoubleArray(T + 1)\n qs[0] = 1.0\n val pow = DoubleArray(T + 1)\n pow[0] = 1.0\n for (i in 0 until T) {\n ps[i + 1] = ps[i] * P\n qs[i + 1] = qs[i] * (100 - P)\n pow[i + 1] = pow[i] / 100\n }\n\n var ans = 0.0\n for (k in 1..min(N, T)) {\n if (k == N) {\n for (n in k - 1 until T) {\n ans += k * dp[n][k - 1] * ps[k - 1] * qs[n - (k - 1)] * pow[n] * P / 100\n }\n } else {\n ans += k * dp[T][k] * ps[k] * qs[T - k] * pow[T]\n }\n }\n out.println(\"%.10f\".format(ans))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "598e897b0b8856045ee41cb3802101a0", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val P = ns().toDouble()\n val T = ni()\n val dp = Array(T + 1){DoubleArray(T + 1)}\n dp[0][0] = 1.0\n for (n in 1..T) {\n for (k in 0 .. n) {\n if (n - 1 >= k) dp[n][k] += dp[n - 1][k]\n if (k - 1 >= 0) dp[n][k] += dp[n - 1][k - 1]\n }\n }\n\n val ps = DoubleArray(T + 1)\n ps[0] = 1.0\n val qs = DoubleArray(T + 1)\n qs[0] = 1.0\n for (i in 0 until T) {\n ps[i + 1] = ps[i] * P\n qs[i + 1] = qs[i] * (1 - P)\n }\n\n var ans = 0.0\n for (k in 1..min(N, T)) {\n if (k == N) {\n for (n in k - 1 until T) {\n ans += k * dp[n][k - 1] * ps[k - 1] * qs[n - (k - 1)] * P\n }\n } else {\n ans += k * ps[k] * qs[T - k] * dp[T][k]\n }\n }\n out.println(\"%.10f\".format(ans))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9f3a0d77811e0bda3f78ceb6046d6265", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.*\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val P = ns().toDouble()\n val T = ni()\n val dp = Array(T + 1){DoubleArray(N + 1)}\n for (i in T - 1 downTo 0) {\n for (j in 0 .. N) {\n if (j + 1 <= N) dp[i][j] += (dp[i + 1][j + 1] + 1) * P\n dp[i][j] += dp[i + 1][j] * (1 - P)\n }\n }\n debug{dp.joinToString(\"\\n\"){it.joinToString(\" \")} }\n out.println(\"%.10f\".format(dp[0][0]))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a2d7a6e7bd042dcd2eb00eb10328d0d8", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n var list = readLine()!!.split(\" \").map { it.toInt() }\n\n var busSize = m\n var count = 1\n for (i in list) {\n if (i <= busSize) {\n busSize = busSize - i\n } else {\n count++\n busSize = m - i\n }\n }\n println(count)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e528d4aa1b1384569869beffac805225", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val nm = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n val a = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n var result = 1\n var people=0\n for (i in 0 until nm[0]){\n if (people + a[i] <= nm[1]){\n people+=a[i]\n }\n else{\n result++\n people=a[i]\n }\n }\n println(result)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e2d4e40128db9bb30f4a727b9d8bc52e", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, busSize) = readInts()\n val groupsSizes = readInts()\n var currentSize = busSize\n var sol = 1\n for (groupSize in groupsSizes)\n if (groupSize <= currentSize)\n currentSize -= groupSize\n else {\n sol++\n currentSize = busSize - groupSize\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1d6a03452f0081b3f9936e013ae0d753", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val groupBus = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n val groupnums = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n var countbuses = 0\n var carry=0\n var count =1\n for (i in 0 until groupBus[0]-1){\n carry=groupnums[i]\n for (j in i+1 until groupBus[0]){\n carry+=groupnums[j]\n if (carry>groupBus[1])break\n count++\n }\n countbuses++\n if (count == groupBus[0])break\n }\n println(countbuses)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "20a1767b32b7cc3c844c76dbb24d119c", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val groupBus = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n val groupnums = readLine()!!.trim().split(\" \").map {it.trim().toInt()}.toIntArray()\n var countbuses = 0\n var carry=0\n if (groupnums.sum()==groupBus[1])countbuses=1\n else {\n for (i in 0 until groupBus[0] - 1) {\n carry = groupnums[i]\n for (j in i + 1 until groupBus[0]) {\n carry += groupnums[j]\n if (carry > groupBus[1]) break\n }\n countbuses++\n }\n }\n println(countbuses)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4bbebd070a27a4d60ad2582abda7768e", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.StringTokenizer\n\nfun main() {\n output {\n val n = readInt()\n val k = readInt()\n\n var ans = ModInt(0)\n\n val kp = k.powArray(n)\n val kmp = (k-1).powArray(n)\n\n for(i in 0 until n) {\n val m = C(n, i) * (kp[n-i] * kmp[i] - kmp[n]).pow(n)\n if(i and 1 == 1) ans -= m\n else ans += m\n }\n\n println(ans)\n }\n}\n\nfun Int.powArray(n: Int) = ModIntArray(n+1).also {\n it[0] = ModInt(1)\n for(i in 1..n) {\n it[i] = it[i-1] * this\n }\n}\n\nprivate val _factorialMemo = mutableListOf(ModInt(1))\n\nfun Int.factorial() = run {\n while(this > _factorialMemo.lastIndex) {\n _factorialMemo.add(_factorialMemo.last() * _factorialMemo.size)\n }\n\n _factorialMemo[this]\n}\n\nfun P(n: Int, k: Int) = n.factorial() / (n-k).factorial()\nfun C(n: Int, k: Int) = n.factorial() / k.factorial() / (n-k).factorial()\n\nconst val BILLION7 = 1e9.toInt() + 7\nconst val MODINT_BASE = BILLION7\n\ninline infix fun Int.umod(base: Int) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Long) = Math.floorMod(this, base)\ninline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()\n\nfun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)\n\nfun Int.powMod(exponent: Int, mod: Int): Int {\n var res = 1L\n var e = exponent\n var b = umod(mod).toLong()\n\n while(e > 0) {\n if(e and 1 == 1) {\n res = res * b % mod\n }\n e = e shr 1\n b = b * b % mod\n }\n return res.toInt()\n}\n\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt(this umod MODINT_BASE)\n\n/** note: Only use constructor for int within modulo range, otherwise use toModInt **/\ninline class ModInt(val int: Int) {\n companion object {\n /** can't seem to make these private or inlined without causing compiler issues */\n @JvmField val _invMemo = HashMap()\n fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }\n }\n\n inline operator fun plus(other: ModInt) = plus(other.int) // MODINT_BASE < 2^30\n inline operator fun plus(other: Int) = (int + other).toModInt() // careful of possible overflow\n inline operator fun inc() = plus(1)\n\n inline operator fun minus(other: ModInt) = minus(other.int)\n inline operator fun minus(other: Int) = (int - other).toModInt()\n inline operator fun dec() = minus(1)\n operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)\n\n inline operator fun times(other: ModInt) = times(other.int)\n inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))\n\n fun pow(exponent: Int): ModInt {\n val e = if(exponent < 0) exponent umod MODINT_BASE - 1 else exponent // assumes MODINT_BASE is prime\n return ModInt(int.powMod(e, MODINT_BASE))\n }\n\n fun pow(exponent: Long) = pow(exponent umod MODINT_BASE - 1) // assumes MODINT_BASE is prime\n\n inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */\n\n fun inv_unmemoized(): ModInt {\n require(int != 0) { \"Can't invert/divide by 0\" }\n return pow(MODINT_BASE - 2) // assumes MODINT_BASE is prime\n }\n inline fun inv_memoized() = _invMemoized(this)\n\n operator fun div(other: ModInt) = times(other.inverse())\n inline operator fun div(other: Int) = div(other.toModInt())\n\n override fun toString() = int.toString()\n}\n\ninline class ModIntArray(val intArray: IntArray): Collection {\n inline operator fun get(i: Int) = ModInt(intArray[i])\n inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }\n\n override val size: Int get() = intArray.size\n inline val lastIndex get() = intArray.lastIndex\n\n override fun contains(element: ModInt): Boolean = any { it == element }\n\n override fun containsAll(elements: Collection): Boolean = elements.all(::contains)\n\n override fun isEmpty(): Boolean = intArray.isEmpty()\n\n override fun iterator(): Iterator = object: Iterator {\n var index = 0\n override fun hasNext(): Boolean = index < size\n override fun next(): ModInt = get(index++)\n }\n}\nfun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))\ninline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =\n ModIntArray(IntArray(capacity) { init(it).int })\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\nfun iprintln(o: Any?) { println(o) } // immediate println for interactive, bypasses output{} blocks", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "860a3048818834b3f269b922db8af8fb", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\nclass Comb(n: Int, val mod: Int) {\n\n val F = LongArray(n + 1)\n val I = LongArray(n + 1)\n init {\n F[0] = 1\n for (i in 1..n) {\n F[i] = F[i - 1] * i % mod\n }\n I[n] = powMod(F[n], (mod - 2).toLong(), mod)\n for (i in n - 1 downTo 0) {\n I[i] = I[i + 1] * (i + 1) % mod\n }\n }\n\n private fun powMod(a: Long, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod(a * a % mod, n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n }\n\n fun comb(n: Int, k: Int): Long {\n return F[n] * I[k] % mod * I[n - k] % mod\n }\n\n fun inv(x: Int): Long {\n return I[x] * F[x - 1] % mod\n }\n\n /**\n * n\u306e\u30b0\u30eb\u30fc\u30d7\u304b\u3089k\u56de\u91cd\u8907\u3042\u308a\u3067\u9078\u3076\u7d44\u307f\u5408\u308f\u305b\u6570\n * n - 1\u306e\u3057\u304d\u308a\u3068k\u306e\u25cb\u3067\u8003\u3048\u308b\n */\n fun H(n: Int, k: Int) = comb(n + k - 1, k)\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val K = nl()\n val comb = Comb(N + 10, MOD)\n val powK = LongArray(N + 11)\n val powKK = LongArray(N + 11)\n powK[0] = 1\n powKK[0] = 1\n for (i in 0 until N + 10) {\n powK[i + 1] = powK[i] * K % MOD\n powKK[i + 1] = powKK[i] * (K - 1) % MOD\n }\n val dp = Array(N + 1){LongArray(N + 1)}\n dp[0][0] = 1\n for (i in 0 until N) {\n for (s in 0 .. N) {\n val cmb1 = (MOD + powK[s] - powKK[s]) % MOD // s\u306e\u4e2d\u306b\uff11\u304c\u3042\u308b\n val cmbAll = powK[s] // \u3059\u3079\u3066\n for (add in 0 .. N - s) {\n val ns = s + add\n val cl = if (add == 0) cmb1 else cmbAll // s\u5074\u306e\u7d44\u307f\u5408\u308f\u305b\n val cr1 = comb.comb(N - s, add) // add\u306e1\u90e8\u5206\n val crr = powKK[N - s - add] // add\u306e1\u4ee5\u5916\u306e\u90e8\u5206\n val cmb = cl * cr1 % MOD * crr % MOD\n dp[i + 1][ns] = (dp[i + 1][ns] + dp[i][s] * cmb % MOD) % MOD\n }\n }\n debug(dp[i + 1])\n }\n\n out.println(dp[N][N])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3a358612fde91fd6922ae72384517d96", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.SortedMap\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val K = readIntArray(n).toCollection(HashBag())\n val maxk = K.elements.max()!!\n\n val primes = IntList()\n val F = List(maxk + 1) { TreeBag() }\n\n factorize@ for(i in 2 .. maxk) {\n for(p in primes) {\n if(p * p > i) break\n if(i % p == 0) {\n F[i].addAll(F[i / p])\n F[i].add(p)\n continue@factorize\n }\n }\n primes.add(i)\n F[i].add(i)\n }\n\n for(i in 3 .. maxk) F[i].addAll(F[i-1])\n\n var ans = K.sumByLong { F[it].size.toLong() }\n var curr = K\n loop@ while(true) {\n val tails = HashMap>()\n for((i, num) in curr.entries) {\n F[i].pollLast()?.also { f -> tails.getOrPut(f) { HashBag() }.add(i, num) }\n }\n for((_, bag) in tails.entries) {\n val num = bag.size\n if(num > n/2) {\n ans -= num - (n - num)\n curr = bag\n continue@loop\n }\n }\n break\n }\n\n println(ans)\n}\n\nfun TreeBag.pollLast() = if(isEmpty()) null else last().also { remove(it) }\n\ninline fun Bag.sumByLong(func: (T) -> Long) = entries.fold(0L) { acc, (k, v) ->\n acc + func(k) * v\n}\n\ninterface Bag : Collection {\n val countMap: Map\n\n fun getCount(element: T): Int = countMap[element] ?: 0\n val elements: Set get() = countMap.keys\n val entries: Set> get() = countMap.entries\n\n override fun iterator(): Iterator = sequence {\n for((e, cnt) in countMap) {\n repeat(cnt) { yield(e) }\n }\n }.iterator()\n\n override fun contains(element: T): Boolean = countMap.containsKey(element)\n}\n\nprivate fun Bag<*>._size() = countMap.values.sum()\nprivate fun Bag<*>._equals(other: Any?) = when {\n this === other -> true\n other is Bag<*> -> countMap == other.countMap\n else -> false\n}\nprivate fun Bag<*>._hashCode() = countMap.hashCode()\n\nclass BagImpl(override val countMap: Map): Bag, AbstractCollection() {\n override val size = _size()\n override fun equals(other: Any?) = _equals(other)\n override fun hashCode() = _hashCode()\n override fun contains(element: T) = super.contains(element)\n override fun iterator() = super.iterator()\n}\nfun Bag(countMap: Map): Bag = BagImpl(countMap)\n\ninterface MutableBag : Bag, MutableCollection {\n val _countMap: MutableMap\n var _size: Int\n\n override fun add(element: T): Boolean { add(element, 1); return true }\n fun add(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n _countMap[element] = oldCount + occurrences\n _size += occurrences\n return oldCount\n }\n\n override fun remove(element: T): Boolean = remove(element, 1) > 0\n fun remove(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n val m = minOf(occurrences, oldCount)\n when(oldCount) {\n 0 -> return 0\n m -> _countMap.remove(element)\n else -> _countMap[element] = oldCount - m\n }\n _size -= m\n return oldCount\n }\n\n fun setCount(element: T, occurrences: Int): Int {\n require(occurrences >= 0)\n val oldCount = getCount(element)\n if(occurrences == 0) _countMap.remove(element)\n else _countMap[element] = occurrences\n _size += occurrences - oldCount\n return oldCount\n }\n\n override fun iterator(): MutableIterator = object: MutableIterator {\n private val mapIterator = _countMap.iterator()\n private var rem = 0\n private lateinit var lastEntry: MutableMap.MutableEntry\n private var removed = true\n override fun hasNext() = rem > 0 || mapIterator.hasNext()\n override fun next(): T {\n if(rem == 0) {\n lastEntry = mapIterator.next()\n rem = lastEntry.value\n }\n rem--\n removed = false\n return lastEntry.key\n }\n override fun remove() {\n if(removed) error(\"\")\n lastEntry.setValue(lastEntry.value - 1)\n if(lastEntry.value == 0) mapIterator.remove()\n _size--\n removed = true\n }\n }\n}\n\nabstract class AbstractMutableBag: MutableBag, AbstractMutableCollection() {\n final override val countMap: Map get() = _countMap\n final override val size get() = _size\n override fun equals(other: Any?) = _equals(other)\n override fun hashCode() = _hashCode()\n override fun contains(element: T) = super.contains(element)\n override fun iterator() = super.iterator()\n override fun add(element: T): Boolean = super.add(element)\n override fun addAll(elements: Collection): Boolean =\n if(elements is Bag) {\n for((e, n) in elements.countMap) add(e, n)\n true\n } else super.addAll(elements)\n override fun remove(element: T): Boolean = super.remove(element)\n override fun removeAll(elements: Collection): Boolean =\n if(elements is Bag) {\n var modified = false\n for((e, n) in elements.countMap) if(remove(e, n) > 0) modified = true\n modified\n } else super.removeAll(elements)\n}\n\ninterface SortedBag: MutableBag {\n override val _countMap: SortedMap\n\n fun first(): T = _countMap.firstKey()\n fun last(): T = _countMap.lastKey()\n}\n\nclass SortedBagImpl(override val _countMap: SortedMap): SortedBag, AbstractMutableBag() {\n override var _size = _size()\n}\nfun SortedBag(countMap: SortedMap): SortedBag = SortedBagImpl(countMap)\n\nclass TreeBag(override val _countMap: TreeMap): SortedBag, AbstractMutableBag() {\n constructor(): this(TreeMap())\n constructor(comparator: Comparator?): this(TreeMap(comparator))\n\n override var _size = _size()\n\n fun floor(element: T): T? = _countMap.floorKey(element)\n fun ceiling(element: T): T? = _countMap.ceilingKey(element)\n fun lower(element: T): T? = _countMap.lowerKey(element)\n fun higher(element: T): T? = _countMap.higherKey(element)\n}\n\nclass HashBag(override val _countMap: HashMap): AbstractMutableBag() {\n constructor(): this(HashMap())\n\n override var _size = _size()\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun clear() { size = 0 }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n fun isEmpty() = size == 0\n fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { this[i] = this[j].also { this[j] = this[i]} }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: String) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "83c6fb3f41aada3845fee0ec434d75eb", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val s1 = readLine()!!\n val s2 = readLine()!!\n val ans = String(CharArray(s1.length) { if (s1[it] < s2[it]) s1[it] else s2[it] })\n println(if (ans == s2) ans else -1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2038eb55368f1504a682fc35b762663c", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.StringTokenizer\nimport java.io.PrintWriter\n\nfun main() {\n for(t in 1..1) {\n val x = readString().toCharArray()\n val y = readString().toCharArray()\n var z = \"\"\n val l = x.size\n var f = false\n for(i in 0..l-1){\n if(x[i] == y[i]) z += \"z\"\n else if(x[i] < y[i]) {\n f = true\n }\n else z += y[i]\n }\n if(!f) wr(z)\n else wr(-1)\n }\n}\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val _reader = INPUT.bufferedReader()\n\nfun readLine(): String? = _reader.readLine()\nfun readLn(): String = _reader.readLine()!!\n\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\n\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\n\nfun readString() = readLn()\nfun readStrings() = readLn().split(\" \")\nfun readInt() = readLn().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLong() = readLn().toLong()\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun wr(a: String) = println(a)\nfun wr(a: Int) = println(a)\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a9baf5b605403769bd6dd0096d41b9be", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.StringTokenizer\nimport java.io.PrintWriter\n\nfun main() {\n for(t in 1..1) {\n val x = readString().toCharArray()\n val y = readString().toCharArray()\n var z = \"\"\n val l = x.size\n for(i in 0..l-1){\n if(x[i] == y[i]) z += \"z\"\n else z += y[i]\n }\n wr(z)\n }\n}\n\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n@JvmField val _reader = INPUT.bufferedReader()\n\nfun readLine(): String? = _reader.readLine()\nfun readLn(): String = _reader.readLine()!!\n\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\n\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\n\nfun readString() = readLn()\nfun readStrings() = readLn().split(\" \")\nfun readInt() = readLn().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLong() = readLn().toLong()\nfun readLongs() = readStrings().map { it.toLong() }\n\nfun wr(a: String) = println(a)\nfun wr(a: Int) = println(a)\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\ninline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9d61695d000cf789c52764335faef425", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val xs = mutableSetOf()\n val ys = mutableSetOf()\n repeat(readInt()) {\n val (x, y) = readInts()\n xs.add(x)\n ys.add(y)\n }\n if (xs.size != 2 || ys.size != 2) return print(-1)\n print((xs.max()!! - xs.min()!!) * (ys.max()!! - ys.min()!!))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1f574d8f6d91297d831d43a4baa41453", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : InputReader, pw : PrintWriter) {\n\n val n : Int = ir.nextInt()\n val x = IntArray(n)\n val y = IntArray(n)\n\n for (i in 0 until n) {\n x[i] = ir.nextInt()\n y[i] = ir.nextInt()\n }\n\n for (i in 0 until n)\n for (j in (i + 1) until n)\n if (x[i] != x[j] && y[i] != y[j]) {\n pw.print(Math.abs(x[i] - x[j]) * Math.abs(y[i] - y[j]))\n return\n }\n\n pw.print(-1)\n\n}\n\nclass InputReader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f251d6e1b46886090fe7cef16ba62b81", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\nfun main(args : Array) {\n var input = System.`in`.bufferedReader()\n try {\n var n = input.readLine().toLong()\n \n --n\n \n var ans = 0L\n// for (i in 1 .. n)\n// ans += (i and -i)\n// println(\"bruteforce: ans = \" + ans)\n//\n// ans = 0L\n var i = 0\n while (n shr i > 0) {\n if ((n and (1L shl i)) != 0L)\n ans += ((n shr (i + 1)) + 1) * (1L shl i)\n else\n ans += ((n shr (i + 1))) * (1L shl i)\n \n ++i\n }\n println(ans)\n } finally {\n input.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4d3ec92fb1032af876eb21ed6a01e3fa", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "\nfun main(args : Array) {\n var input = System.`in`.bufferedReader()\n try {\n var n = input.readLine().toLong()\n var i = 0\n \n --n\n \n var ans = 0L\n while (n shr i > 0) {\n ans += ((n shr (i + 1)) + 1) * (1L shl i)\n ++i\n }\n println(ans)\n } finally {\n input.close()\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3edeb175cf60f3e387f498fdf8ff2243", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n var (a, b) = r.readLine()!!.split(\" \").map { it.toLong() }\n var ans = 0L\n while (a % b != 0L) {\n ans += a / b\n a = b.also { b = a % b }\n }\n ans += a/b\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "df48df76a63efabe6e72a71283aec57d", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (a, b) = readLine()!!.split(' ').map(String::toLong)\n if (a < b) {\n val c: Long = a\n a = b\n b = c\n }\n var ans: Long = 0L\n while (b > 0) {\n ans += a / b\n a %= b\n val c: Long = a\n a = b\n b = c\n }\n print(\"$ans\\n\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "14631b1482d168973ee0ca7df271ae05", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n var (a, b) = r.readLine()!!.split(\" \").map { it.toLong() }\n var ans = 0L\n while (a % b != 0L) {\n ans += a / b\n a = b.also { b = a % b }\n }\n ans += a\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "02728e482981b8570121e9c1cb485a64", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n var (numParticipants, numBottles, numTowels) = readInts()\n val totalTowels = numParticipants * numTowels\n var totalBottles = 0\n while(numParticipants > 1) {\n var playing = 2\n while (playing * 2 <= numParticipants) playing *= 2\n val matches = playing / 2\n totalBottles += matches * (2 * numBottles + 1)\n numParticipants = matches + numParticipants - playing\n }\n print(\"$totalBottles $totalTowels\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "315bdba2ecb10789e6b68bfff2da0d1f", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (numCandies, numFriends) = readLine()!!.split(\" \").map(String::toInt)\n val sol = IntArray(numFriends)\n val less = numCandies / numFriends\n val more = less + if (numCandies % numFriends == 0) 0 else 1\n val numLess = numFriends - numCandies % numFriends\n for (pos in 0 until numLess) sol[pos] = less\n for (pos in numLess until numFriends) sol[pos] = more\n print(sol.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bb6bf3a4fb3bfc08b3f54af1936db3b4", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (n, k) = readInts()\n val arr = readInts()\n var sol = 0\n for (kPos in 0 until k) {\n var ones = 0\n var twos = 0\n for (pos in kPos until n step k) if (arr[pos] == 1) ones++ else twos++\n sol += min(ones, twos)\n }\n print(sol)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "01acc9731e1d16503c78baa034a97f35", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main(){\n var (n,d) = readLine()!!.split(' ').map { it.toInt() }\n var list = readLine()!!.split(' ').map { it.toInt() }.sorted()\n var m = readLine()!!.toInt()\n\n if (m>=n){\n println(list.sum() - ((m-n)*d))\n }else{\n var ans = 0\n for (i in 0..m-1){\n ans+=list[i]\n }\n println(ans)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7165cb1a0906eccd8a802ceb429af596", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.math.BigDecimal\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val line = br.readLine()\n val b = BigDecimal(line)\n println(b.stripTrailingZeros().toPlainString())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4d1c9ad10ee9e69ed90ccea15c15496a", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val A = ni() - 1\n val B = ni() - 1\n val K = ni()\n val dp = Array(K + 1){LongArray(N + 10)}\n dp[0][A] = 1\n for (i in 1 .. K) {\n for (j in 0 until N) {\n val d = abs(B - j) - 1\n val t = min(N - 1, j + d)\n val b = max(0, j - d)\n val v = dp[i - 1][j]\n dp[i][b] += v\n dp[i][j] += MOD - v\n if (j + 1 <= t + 1) {\n dp[i][j + 1] += v\n dp[i][t + 1] += MOD - v\n }\n }\n for (j in 1 until N) {\n dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD\n }\n debug(dp[i])\n }\n out.println(dp[K].take(N).sum() % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e93df582b865454baaff92d7fbb5dcca", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val A = ni() - 1\n val B = ni() - 1\n val K = ni()\n val dp = Array(K + 1){LongArray(N + 10)}\n dp[0][A] = 1\n for (i in 1 .. K) {\n for (j in 0 until N) {\n val d = abs(B - j) - 1\n val t = min(N - 1, j + d)\n val b = max(0, j - d)\n val v = dp[i - 1][j]\n dp[i][b] = (dp[i][b] + v) % MOD\n dp[i][j] = (MOD + dp[i][j] - v) % MOD\n if (j + 1 <= t + 1) {\n dp[i][j + 1] = (dp[i][j + 1] + v) % MOD\n dp[i][t + 1] = (MOD + dp[i][t + 1] - v) % MOD\n }\n }\n for (j in 1 until N) {\n dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD\n }\n debug(dp[i])\n }\n out.println(dp[K].take(N).sum() % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "63ac662aa1e7b8236b9a8c7d12f97d4c", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nval LOCAL_MODE = true\n\nfun main(args: Array) {\n val input: InputReader\n val output: PrintWriter\n if (false) {\n input = InputReader(FileInputStream(\"input.txt\"))\n output = PrintWriter(FileOutputStream(\"output.txt\"))\n } else {\n input = InputReader(System.`in`)\n output = PrintWriter(System.out)\n }\n Solver(input, output).run()\n input.close()\n output.close()\n}\n\nfun debug(x: Any) {\n if (LOCAL_MODE) {\n System.err.println(x)\n }\n}\n\nclass Solver(val input: InputReader, val output: PrintWriter) {\n\n companion object {\n val MOD = (1e9 + 7).toInt()\n }\n\n fun run() {\n if (true) {\n read()\n// output.println(solve())\n } else {\n for (stress in generateSequence({ 1 }, { it + 1 })) {\n debug(\"Stress #$stress\")\n generateStress()\n printStress()\n// val my = solve()\n// val slow = slow()\n// require(my == slow, { \"$my != $slow\" })\n }\n }\n\n }\n\n private fun printStress() {\n\n }\n\n private fun generateStress() {\n\n }\n\n private fun read() {\n val c = input.nextInt()\n val v0 = input.nextInt()\n val v1 = input.nextInt()\n val a = input.nextInt()\n val last = input.nextInt()\n\n var d = 1;\n var l = 1;\n var r = v0;\n var s = v0;\n while (true) {\n if (c in l..r) break\n d++\n s = Math.min(s + a, v1)\n l = r + 1 - last;\n r = l + s - 1;\n }\n\n output.println(d)\n }\n\n private fun solve() {\n\n }\n\n}\n\n\nclass InputReader(val stream: InputStream) : Closeable {\n\n var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n\n var tokenizer: StringTokenizer? = null\n\n override fun close() {\n stream.close()\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int = next().toInt()\n\n fun nextLong(): Long = next().toLong()\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "502d1b3c3a04100fc62bbac6a0c4e007", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nval input = FastScanner()\n\nfun main(args: Array) = input.run {\n val c = nextInt()\n val v0 = nextInt()\n val vMax = nextInt()\n val increase = nextInt()\n val back = nextInt()\n\n var ans = 0\n var n = 0\n var v = v0\n while (n < c) {\n n -= back\n n = n.coerceAtLeast(0)\n n += v\n v += increase\n v = v.coerceAtMost(vMax)\n ans++\n }\n\n println(ans)\n}\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bc087912401446109e6db2a721f33096", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val (totalPages, initialSpeed, maxSpeed, acceleration, reRead) = readLine()!!.split(\" \").map(String::toInt)\n var pages = 0\n for (day in 0..totalPages) {\n pages += min(initialSpeed + day * acceleration, maxSpeed)\n if (pages >= totalPages) return print(day + 1)\n pages -= reRead\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2db60cb7e895ff2205e0aa3d86c82012", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "class MisterBReader(val c: Int,\n val v0: Int,\n val v1: Int,\n val a: Int,\n val l: Int\n) {\n var v = v0\n var readedPages = 0\n \n fun getDaysToRead() : Int {\n var days = 1\n readedPages += v\n while(readedPages < c) {\n readedPages -= l\n v = if (v >= v1) v else v + a\n readedPages += v\n days++\n }\n return days\n }\n}\n\n\nfun main(args: Array) {\n val(c, v0, v1, a, l) = readLine()!!.split(' ').map(String::toInt)\n println(MisterBReader(c, v0, v1, a, l).getDaysToRead())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2dd3c609ba12d717656efbd0ae43cfac", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val jin = Scanner(System.`in`)\n val k = jin.nextInt()\n val pa = jin.nextLong()\n val pb = jin.nextLong()\n val p = (pa * ((pa + pb) pow -1)) % MOD\n val np = 1L - p\n val npInv = np pow -1\n //println(\"p = $p, np = $np, npInv = $npInv\")\n val dp = Array(k) { LongArray(k + 1) }\n var answer = k.toLong()\n dp[0][1] = 1L\n for (j1 in 0 until k) {\n for (j2 in 1..k) {\n //println(\"dp[$j1][$j2] = ${dp[j1][j2]}\")\n if (j2 == k) {\n answer += dp[j1][j2] * (j1.toLong() + npInv - 1L)\n answer %= MOD\n } else {\n dp[j1][j2 + 1] += dp[j1][j2] * p\n dp[j1][j2 + 1] %= MOD\n if (j1 + j2 >= k) {\n answer += ((dp[j1][j2] * np) % MOD) * (j1 + j2 - k).toLong()\n answer %= MOD\n } else {\n dp[j1 + j2][j2] += dp[j1][j2] * np\n dp[j1 + j2][j2] %= MOD\n }\n }\n }\n }\n println(((answer % MOD) + MOD) % MOD)\n}\n\nval MOD: Long = 1000000007\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "085b896ee612d310e55cb924cf092799", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = arrayListOf()\n for (i in 1..9) {\n a.add(sc.nextInt())\n }\n a[0] = (a[3] + 2 * a[5] - a[1]) / 2\n a[4] = a[2] - (a[3] - a[1]) / 2\n a[8] = (a[3] - a[1]) / 2 + a[1]\n var k = 0\n for (i in 1..3) {\n for (j in 1..3)\n print(a[k++].toString() + \" \")\n print(\"\\n\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "39ea2e393d3f307b8aff2998d8821ca3", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (a, b, c) = readInts()\n for (x in 0..c / a)\n if ((c - x * a) % b == 0) return print(\"Yes\")\n print(\"No\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9e13ec72bbb6c776904c01b9d146a6a0", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val a: Int = ir.nextInt()\n val b: Int = ir.nextInt()\n val c: Int = ir.nextInt()\n\n for (i in 0 until (c / a) + 1) {\n for (j in 0 until (c / b) + 1) {\n if (a * i + b * j == c) {\n pw.print(\"Yes\")\n return\n }\n }\n }\n\n pw.print(\"No\")\n\n}\n\n\n\nprivate fun sort(array: IntArray, barray: IntArray, low: Int, high: Int) {\n\n var i = low\n var j = high\n val x = array[low + (high - low) / 2]\n\n do {\n while (array[i] < x) ++i\n while (array[j] > x) --j\n if (i <= j) {\n val tmp = array[i]\n array[i] = array[j]\n array[j] = tmp\n\n val pmt = barray[i]\n barray[i] = barray[j]\n barray[j] = pmt\n\n i++\n j--\n }\n } while (i <= j)\n\n if (low < j) sort(array, barray, low, j)\n if (i < high) sort(array, barray, i, high)\n\n}\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "059ea1003f0e4cfdb5f01214c0d4dbfd", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashSet\n\nfun main() {\n solve(System.`in`, System.out)\n}\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = Reader(input) //Reader(FileInputStream(File(\"portals.in\")))\n val writer = PrintWriter(BufferedOutputStream(output)) //PrintWriter(FileOutputStream(File(\"output.txt\")))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(ir : Reader, pw : PrintWriter) {\n\n val a: Int = ir.nextInt()\n val b: Int = ir.nextInt()\n val c: Int = ir.nextInt()\n val first: Int = (c / a) + 1\n val second: Int = (c / b) + 1\n\n for (i in 0 until first) {\n for (j in 0 until second) {\n if (a * i + b * j == c) {\n pw.print(\"Yes\")\n return\n }\n }\n }\n\n pw.print(\"No\")\n\n}\n\n\n\nprivate fun sort(array: IntArray, barray: IntArray, low: Int, high: Int) {\n\n var i = low\n var j = high\n val x = array[low + (high - low) / 2]\n\n do {\n while (array[i] < x) ++i\n while (array[j] > x) --j\n if (i <= j) {\n val tmp = array[i]\n array[i] = array[j]\n array[j] = tmp\n\n val pmt = barray[i]\n barray[i] = barray[j]\n barray[j] = pmt\n\n i++\n j--\n }\n } while (i <= j)\n\n if (low < j) sort(array, barray, low, j)\n if (i < high) sort(array, barray, i, high)\n\n}\n\nclass Reader(stream: InputStream) {\n private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer? = null\n\n init {\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens())\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String? {\n val fullLine: String\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n fullLine = reader.readLine()\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n return fullLine\n }\n return null\n }\n\n fun toArray(): Array {\n return nextLine()!!.split(\" \".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f31b6282c928c2b85c7739df1a47505e", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val jin = Scanner(System.`in`)\n val n = jin.nextInt()\n val mInv = mint(jin.nextInt()) pow -1\n val k = jin.nextInt()\n val dp = Array(k + 1) { LongArray(it + 2) }\n dp[0][0] = 1L\n for (x in 1..k) {\n for (y in 1..x) {\n dp[x][y] = ((n - y + 1).toLong() * dp[x - 1][y - 1]) + (y.toLong() * dp[x - 1][y])\n dp[x][y] %= MOD\n }\n }\n var answer = M0\n var power = M1\n for (y in 1..k) {\n power *= mInv\n answer += mint(dp[k][y] + MOD) * power\n }\n println(answer)\n}\n\nval M0 = Mint(0)\nval M1 = Mint(1)\nval M2 = Mint(2)\n\nval MOD: Long = 998244353\nval MOD_TOTIENT = (MOD - 1).toInt()\n\nfun mint(num: Long) = Mint(num % MOD)\nfun mint(num: Int) = Mint(num % MOD)\n\ninline class Mint(val num: Long) {\n\n operator fun plus(k: Mint) = mint(num + k.num)\n operator fun minus(k: Mint) = mint(num + MOD - k.num)\n operator fun times(k: Mint) = mint(num * k.num)\n operator fun div(k: Mint) = this * (k pow -1)\n\n operator fun unaryMinus() = mint(MOD - num)\n operator fun inc() = this + M1\n operator fun dec() = this - M1\n\n infix fun pow(power: Int): Mint {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && num == 0L) {\n return this\n }\n var b = this\n var res = Mint(1)\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n }\n b *= b\n e = e shr 1\n }\n return res\n }\n\n override fun toString(): String = num.toString()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "963005a28ed5dbf57ce2b125c6b7fcdd", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val jin = Scanner(System.`in`)\n val n = mint(jin.nextInt())\n val mInv = mint(jin.nextInt()) pow -1\n val k = jin.nextInt()\n val dp = Array(k + 1) { Array(it + 2) { getM0 } }\n dp[0][0] = getM1\n for (x in 1..k) {\n for (y in 1..x) {\n dp[x][y] = ((n - mint(y) + getM1) * dp[x - 1][y - 1]) + (mint(y) * dp[x - 1][y])\n }\n }\n var answer = getM0\n var power = getM1\n for (y in 1..k) {\n power *= mInv\n answer += dp[k][y] * power\n }\n println(answer)\n}\n\nval getM0 = Mint(0)\nval getM1 = Mint(1)\nval getM2 = Mint(2)\n\nval getMOD: Long = 998244353\nval getMOD_TOTIENT = (getMOD - 1).toInt()\n\nfun mint(num: Long) = Mint(num % getMOD)\nfun mint(num: Int) = Mint(num % getMOD)\n\ninline class Mint(val num: Long) {\n\n operator fun plus(k: Mint) = mint(num + k.num)\n operator fun minus(k: Mint) = mint(num + getMOD - k.num)\n operator fun times(k: Mint) = mint(num * k.num)\n operator fun div(k: Mint) = this * (k pow -1)\n\n operator fun unaryMinus() = mint(getMOD - num)\n operator fun inc() = this + getM1\n operator fun dec() = this - getM1\n\n infix fun pow(power: Int): Mint {\n var e = power\n e %= getMOD_TOTIENT\n if (e < 0) {\n e += getMOD_TOTIENT\n }\n if (e == 0 && num == 0L) {\n return this\n }\n var b = this\n var res = Mint(1)\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n }\n b *= b\n e = e shr 1\n }\n return res\n }\n\n override fun toString(): String = num.toString()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "291f38457233b564c30aedaa5acf04ba", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map(String::toLong)\n var i = 1\n while (k % 2 == 0L) {\n i++\n k /= 2\n }\n println(i)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a2b447279f8a93b8743e8157d381e047", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)){\n val n = nextInt()\n val k = nextLong()\n val arrSize = getArrSize(n.toLong())\n println(findTargetIndex(n.toLong(), arrSize, k - 1)) \n\n}\nfun findTargetIndex(step: Long, size: Long, targetIndex: Long): Long{\n if(size == 1L) {\n return 1L\n }\n val next = size / 2\n \n if(next == targetIndex) {\n return step\n }\n if(targetIndex > next) {\n return findTargetIndex(step - 1, next, targetIndex - next - 1)\n }\n return findTargetIndex(step - 1, next, targetIndex)\n}\n\nfun getArrSize(step: Long): Long { \n if(step <= 1L) {\n return 1\n }\n return (2 * getArrSize(step - 1)) + 1\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "75c54937e1b5ceb96e1a1ee618d09cea", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n, k) = readLine()!!.split(' ').map { s -> s.toLong() }\n val size = (1L shl n.toInt()) - 1\n var l = 1L\n var r = size\n var pos = (l + r) / 2\n while (pos != k) {\n if (k > pos) {\n l = pos\n pos = (pos + r + 1) / 2\n } else {\n r = pos\n pos = (l + pos) / 2\n }\n n--\n }\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "88610e6d57fa3b84d79a17a86ef4f051", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)){\n val n = nextInt()\n val k = nextLong()\n val arrSize = getArrSize(n.toLong())\n println(findTargetIndex(n.toLong(), arrSize, k - 1)) \n\n}\nfun findTargetIndex(step: Long, size: Long, targetIndex: Long): Long{\n val next = size / 2\n\n if(next <= targetIndex) {\n return step\n }\n if(targetIndex > next) {\n return next + findTargetIndex(step - 1, next, targetIndex)\n }\n return findTargetIndex(step - 1, next, targetIndex)\n}\n\nfun getArrSize(step: Long): Long { \n if(step <= 1L) {\n return 1\n }\n return (2 * getArrSize(step - 1)) + 1\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5a825bcc0823c9643664bec956774431", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)){\n val n = nextInt()\n val k = nextLong()\n val arrSize = getArrSize(n.toLong())\n println(findTargetIndex(n.toLong(), arrSize, k - 1)) \n\n}\nfun findTargetIndex(step: Long, size: Long, targetIndex: Long): Long{\n val next = size / 2\n\n if(next == targetIndex) {\n return step\n }\n if(targetIndex > next) {\n return next + findTargetIndex(step - 1, next, targetIndex)\n }\n return findTargetIndex(step - 1, next, targetIndex)\n}\n\nfun getArrSize(step: Long): Long { \n if(step <= 1L) {\n return 1\n }\n return (2 * getArrSize(step - 1)) + 1\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4d2f462fb7527dac144d7aae0aea7f64", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\n\n\nfun main() {\n io.apply {\n\n val base = int\n val num = str().reversed()\n\n var ptr = 0\n\n fun get(): Long {\n var pow = 1L\n var ans = 0L\n var ix = ptr\n ptr++\n while (ix < num.length) {\n val x = num[ix] - '0'\n if (pow < base && ans + x * pow < base) {\n ans += x * pow\n pow *= 10\n if (x != 0)\n ptr = ix + 1\n } else {\n return ans\n }\n ix++\n }\n return ans\n }\n\n var ans = 0L\n var b = 1L\n while (ptr < num.length) {\n val g = get()\n// cout .. g .. nl\n ans += b * g\n b *= base\n }\n\n cout .. ans .. nl\n\n\n }.cout.flush()\n}\n\n// @formatter:off\nprivate val io = object {\n private val `in` = System.`in`\n private fun ll(): Long {\n var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }\n do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n\n }\n val int get() = ll().toInt(); val long get() = ll()\n fun ints(n: Int = int): IntArray { return IntArray(n) { int } }\n fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }\n val cout = PrintWriter(System.out); val nl = \"\\n\"\n private var buf = CharArray(32)\n private var bufSize = 32\n fun str(expect: Int = 32): String {\n var ix = 0\n var x: Int\n if (bufSize < expect)\n buf = CharArray(expect)\n do x = `in`.read() while (x < 33)\n do {\n if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }\n buf[ix++] = x.toChar()\n x = `in`.read()\n } while (x > 32)\n return java.lang.String.copyValueOf(buf, 0, ix)\n }\n operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(\" \") }; return this }\n operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }\n} // @formatter:on\n\n/* ----------- */\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bbcfb06cb3f11fbb3201ea789f4b941b", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\n\n\nfun main() {\n io.apply {\n\n val base = int\n val num = str()\n\n var pow = 1L\n var cur = 0L\n\n var ans = 0L\n var b = 1L\n\n for (c in num.reversed()) {\n var x = c - '0'\n if (cur + x * pow >= base || pow >= base) {\n ans += cur * b\n b *= base\n cur = x.toLong()\n pow = 10\n } else {\n cur += x * pow\n pow *= 10\n }\n }\n ans += cur * b\n cout .. ans .. nl\n\n\n\n }.cout.flush()\n}\n\n// @formatter:off\nprivate val io = object {\n private val `in` = System.`in`\n private fun ll(): Long {\n var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }\n do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n\n }\n val int get() = ll().toInt(); val long get() = ll()\n fun ints(n: Int = int): IntArray { return IntArray(n) { int } }\n fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }\n val cout = PrintWriter(System.out); val nl = \"\\n\"\n private var buf = CharArray(32)\n private var bufSize = 32\n fun str(expect: Int = 32): String {\n var ix = 0\n var x: Int\n if (bufSize < expect)\n buf = CharArray(expect)\n do x = `in`.read() while (x < 33)\n do {\n if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }\n buf[ix++] = x.toChar()\n x = `in`.read()\n } while (x > 32)\n return java.lang.String.copyValueOf(buf, 0, ix)\n }\n operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(\" \"); return this }\n operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(\" \") }; return this }\n operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }\n} // @formatter:on\n\n/* ----------- */\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0e4cf7a3d4b5d891d75d2fd5228b7f9f", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\nimport java.util.*\nimport kotlin.math.min\n\nconst val CODE_0 = '0'.toByte()\nconst val CODE_1 = '9'.toByte()\n\nvar s: String = \"\"\nvar n: Int = 0\nval dp = Array(500) { IntArray(500) }\n\nclass Main {\n companion object {\n @JvmStatic\n private fun ans(l: Int, r: Int): Int {\n dp[l][r] = when {\n dp[l][r] > 0 -> dp[l][r]\n l == r -> 1\n l > r -> 0\n else -> ((l + 1)..r).fold(1 + ans(l + 1, r)) { acc, i ->\n if (s[i] != s[l]) acc else min(acc, ans(l + 1, i - 1) + ans(i, r))\n }\n }\n return dp[l][r]\n }\n\n @JvmStatic\n fun main(args: Array) = with(Scanner(System.`in`)) {\n n = nextInt()\n s = next()\n println(ans(0, n - 1))\n }\n }\n\n\n // -----------------------------------------------------------------------------------------------------------------\n\n private class FastScanner(private val iss: InputStream = System.`in`) {\n fun nextInt(): Int {\n var v = 0\n var begin = false\n while (true) {\n val c = iss.read()\n if (c in CODE_0..CODE_1) {\n begin = true\n v *= 10\n v += c - CODE_0\n } else if (begin) {\n return v\n }\n }\n }\n }\n}\n\nfun main(args: Array) = Main.main(args)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2a3c21fc4f0fa768820a7b9f31d1b680", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\nimport java.util.*\nimport kotlin.math.min\n\nconst val CODE_0 = '0'.toByte()\nconst val CODE_1 = '9'.toByte()\n\nvar s: String = \"\"\nvar n: Int = 0\nval dp = Array(500) { IntArray(500) }\n\nclass Main {\n companion object {\n @JvmStatic\n private fun ans(l: Int, r: Int): Int {\n dp[l][r] = when {\n dp[l][r] > 0 -> dp[l][r]\n l == r -> 1\n l > r -> 0\n else -> ((l + 1)..r).fold(1 + ans(l + 1, r)) { acc, i ->\n if (s[i] != s[l]) acc else min(acc, ans(l + 1, i - 1) + ans(i, r))\n }\n }\n return dp[l][r]\n }\n\n @JvmStatic\n fun main(args: Array) = with(Scanner(System.`in`)) {\n n = nextInt()\n s = next()\n println(ans(0, n - 1))\n }\n }\n\n\n // -----------------------------------------------------------------------------------------------------------------\n\n private class FastScanner(private val iss: InputStream = System.`in`) {\n fun nextInt(): Int {\n var v = 0\n var begin = false\n while (true) {\n val c = iss.read()\n if (c in CODE_0..CODE_1) {\n begin = true\n v *= 10\n v += c - CODE_0\n } else if (begin) {\n return v\n }\n }\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "212f048ad56af41cd0bc11826bb37003", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\nimport java.util.*\nimport kotlin.math.min\n\nconst val CODE_0 = '0'.toByte()\nconst val CODE_1 = '9'.toByte()\n\nvar s: String = \"\"\nvar n: Int = 0\nval dp = Array(500) { IntArray(500) }\n\nclass Main {\n companion object {\n @JvmStatic\n private fun ans(l: Int, r: Int): Int {\n dp[l][r] = when {\n dp[l][r] > 0 -> dp[l][r]\n l == r -> 1\n l > r -> 0\n else -> ((l + 1)..r).fold(1 + ans(l + 1, r)) { acc, i ->\n if (s[i] != s[l]) acc else min(acc, ans(l + 1, i - 1) + ans(i, r))\n }\n }\n return dp[l][r]\n }\n\n @JvmStatic\n fun main(args: Array) = with(Scanner(System.`in`)) {\n n = nextInt()\n s = next()\n println(ans(0, n - 1))\n\n return@with 0\n }\n }\n\n\n // -----------------------------------------------------------------------------------------------------------------\n\n private class FastScanner(private val iss: InputStream = System.`in`) {\n fun nextInt(): Int {\n var v = 0\n var begin = false\n while (true) {\n val c = iss.read()\n if (c in CODE_0..CODE_1) {\n begin = true\n v *= 10\n v += c - CODE_0\n } else if (begin) {\n return v\n }\n }\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "02649f1c25a6bb9f65146fe0e2662d33", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numCandidates = readInt()\n val votes = readInts()\n var limakVotes = votes[0]\n val opponentsVotes = PriorityQueue() { a, b -> b.compareTo(a) }\n opponentsVotes.addAll(votes.subList(1, numCandidates))\n var sol = 0\n while (limakVotes <= opponentsVotes.peek()) {\n sol++\n limakVotes++\n opponentsVotes.add(opponentsVotes.poll() - 1)\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7c007034137cd1e572296c33a1fa3e57", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, k) = readLine()!!.split(\" \").map(String::toLong)\n print((n / k + 1) * k)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ccedf04913a85d9c7d479cd2d63c61f1", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(a: Array) = with(java.util.Scanner(System.`in`)) {\n var n = nextInt()\n var m = nextInt()\n println(((n/m)+1)*m)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "aed78ab894e7876fc8c353485534217b", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun main() {\n val (N) = readInts()\n val A = IntArray(N)\n for (i in 0 until N) {\n val (a) = readInts()\n A[i] = a\n }\n A.sort()\n\n fun test(a: IntArray): Boolean {\n for (i in 0 until 3) {\n if (a[i] > a[i + 1]) return false\n }\n for (i in 0 until 4) {\n if (!(0..1_000_000).contains(a[i])) return false\n }\n return a[3] - a[0] == (a[1] + a[2]) / 2 && a[3] - a[0] == a.sum() / 4\n }\n\n if (N == 0) {\n println(\"YES\")\n arrayOf(1, 1, 3, 3).forEach { println(it) }\n } else if (N == 1) {\n val a = A[0]\n println(\"YES\")\n arrayOf(a, 3 * a, 3 * a).forEach { println(it) }\n } else if (N == 2) {\n val a = A[0]\n val b = A[1]\n println(\"YES\")\n arrayOf(4 * a - b, 3 * a).forEach { println(it) }\n } else if (N == 3) {\n val arrays = arrayOf(\n Pair(intArrayOf(A[0], A[1], A[2], A[0] * 3), A[0] * 3),\n Pair(intArrayOf(A[0], A[1], A[0] * 4 - A[1], A[2]), A[0] * 4 - A[1]),\n Pair(intArrayOf(A[0], A[0] * 4 - A[1], A[1], A[2]), A[0] * 4 - A[1]),\n Pair(intArrayOf(A[2] - (A[0] + A[1]) / 2, A[0], A[1], A[2]), A[2] - (A[0] + A[1]) / 2)\n )\n for (a in arrays) {\n if (test(a.first)) {\n println(\"YES\")\n println(a.second)\n return\n }\n }\n println(\"NO\")\n\n } else {\n if (test(A)) {\n println(\"YES\")\n return\n }\n println(\"NO\")\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprivate val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n} catch (t: Throwable) {\n false\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }.toIntArray()\nprivate fun readLongs() = readStrings().map { it.toLong() }.toLongArray()\nprivate inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n}\nprivate fun debug(a: LongArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: IntArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: BooleanArray) {\n debug{a.map{if(it) 1 else 0}.joinToString(\"\")}\n}\nprivate fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dd8491d57813cc7c502fed3b52c49dfc", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun main() {\n val (N) = readInts()\n val A = IntArray(N)\n for (i in 0 until N) {\n val (a) = readInts()\n A[i] = a\n }\n A.sort()\n\n fun test(a: IntArray): Boolean {\n for (i in 0 until 3) {\n if (a[i] > a[i + 1]) return false\n }\n return a[3] - a[0] == (a[1] + a[2]) / 2 && a[3] - a[0] == a.sum() / 4\n }\n\n if (N == 0) {\n println(\"YES\")\n arrayOf(1, 1, 3, 3).forEach { println(it) }\n } else if (N == 1) {\n val a = A[0]\n println(\"YES\")\n arrayOf(a, 3 * a, 3 * a).forEach { println(it) }\n } else if (N == 2) {\n val a = A[0]\n val b = A[1]\n println(\"YES\")\n arrayOf(4 * a - b, 3 * a).forEach { println(it) }\n } else if (N == 3) {\n val arrays = arrayOf(\n Pair(intArrayOf(A[0], A[1], A[2], A[0] * 3), A[0] * 3),\n Pair(intArrayOf(A[0], A[1], A[0] * 4 - A[1], A[2]), A[0] * 4 - A[1]),\n Pair(intArrayOf(A[0], A[0] * 4 - A[1], A[1], A[2]), A[0] * 4 - A[1]),\n Pair(intArrayOf(A[2] - (A[0] + A[1]) / 2, A[0], A[1], A[2]), A[2] - (A[0] + A[1]) / 2)\n )\n for (a in arrays) {\n if (test(a.first)) {\n println(\"YES\")\n println(a.second)\n return\n }\n }\n println(\"NO\")\n\n } else {\n if (test(A)) {\n println(\"YES\")\n return\n }\n println(\"NO\")\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprivate val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n} catch (t: Throwable) {\n false\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }.toIntArray()\nprivate fun readLongs() = readStrings().map { it.toLong() }.toLongArray()\nprivate inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n}\nprivate fun debug(a: LongArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: IntArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: BooleanArray) {\n debug{a.map{if(it) 1 else 0}.joinToString(\"\")}\n}\nprivate fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "910de0e947cdd8055a9b1171584cd5ac", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nfun main() {\n val (N) = readInts()\n val A = IntArray(N)\n for (i in 0 until N) {\n val (a) = readInts()\n A[i] = a\n }\n A.sort()\n\n fun test(a: IntArray): Boolean {\n for (i in 0 until 3) {\n if (a[i] > a[i + 1]) return false\n }\n for (i in 0 until 4) {\n if (!(1..1_000_000).contains(a[i])) return false\n }\n return 2 * (a[3] - a[0]) == a[1] + a[2] &&\n 4 * (a[3] - a[0]) == a.sum()\n }\n\n if (N == 0) {\n println(\"YES\")\n arrayOf(1, 1, 3, 3).forEach { println(it) }\n } else if (N == 1) {\n val a = A[0]\n println(\"YES\")\n arrayOf(a, 3 * a, 3 * a).forEach { println(it) }\n } else if (N == 2) {\n val a = A[0]\n val b = A[1]\n if (a * 3 >= b) {\n println(\"YES\")\n arrayOf(a * 4 - b, a * 3).forEach { println(it) }\n } else {\n println(\"NO\")\n }\n } else if (N == 3) {\n val arrays = arrayOf(\n intArrayOf(A[0], A[1], A[2], A[0] * 3),\n intArrayOf(A[0], A[1], A[0] * 4 - A[1], A[2]),\n intArrayOf(A[0], A[0] * 4 - A[1], A[1], A[2]),\n intArrayOf(A[2] - (A[0] + A[1]) / 2, A[0], A[1], A[2])\n )\n for (a in arrays) {\n if (test(a)) {\n println(\"YES\")\n val aa = mutableListOf()\n aa.addAll(a.toList())\n A.forEach { aa.remove(it) }\n aa.forEach{ println(it) }\n\n return\n }\n }\n println(\"NO\")\n\n } else {\n if (test(A)) {\n println(\"YES\")\n return\n }\n println(\"NO\")\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprivate val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n} catch (t: Throwable) {\n false\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }.toIntArray()\nprivate fun readLongs() = readStrings().map { it.toLong() }.toLongArray()\nprivate inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n}\nprivate fun debug(a: LongArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: IntArray) {\n debug{a.joinToString(\" \")}\n}\nprivate fun debug(a: BooleanArray) {\n debug{a.map{if(it) 1 else 0}.joinToString(\"\")}\n}\nprivate fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3af1ce43d4ee6d03b6b01e59999bc3ce", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n val Q = Array(2) { scanner.next().toCharArray() }\n var res = 0\n for (i in 0..Q[0].size - 2) {\n if (Q[0][i] == '0' && Q[1][i] == '0' && Q[0][i + 1] == '0') {\n Q[0][i] = 'X'\n Q[1][i] = 'X'\n Q[0][i + 1] = 'X'\n res++\n }\n if (Q[0][i] == '0' && Q[1][i] == '0' && Q[1][i + 1] == '0') {\n Q[0][i] = 'X'\n Q[1][i] = 'X'\n Q[1][i + 1] = 'X'\n res++\n }\n if (Q[0][i] == '0' && Q[0][i + 1] == '0' && Q[1][i + 1] == '0') {\n Q[0][i] = 'X'\n Q[0][i + 1] = 'X'\n Q[1][i + 1] = 'X'\n res++\n }\n if (Q[1][i] == '0' && Q[1][i + 1] == '0' && Q[0][i + 1] == '0') {\n Q[1][i] = 'X'\n Q[1][i + 1] = 'X'\n Q[0][i + 1] = 'X'\n res++\n }\n }\n println(res)\n\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\nfun IntArray.print() {\n println(Arrays.toString(this))\n}\n\n//class Pair(var a: Int, var b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return b - a - other.b + other.a\n// }\n//}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ec6bb10daf36db3cd670c225002838f5", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main(args: Array) {\n val b = Array(2) { readLine()!!.toCharArray() }\n val n = b[0].size\n val d = Array(n) { IntArray(3 ) }\n for (i in 1 until n) {\n val best = d[i - 1].max()!!\n for (p in 0..2) d[i][p] = best\n if (b[0][i - 1] == '0' && b[1][i - 1] == '0') {\n for (p in 0..2) {\n for (j in 0..1) if (b[j][i] == '0' && (p and (1 shl j) == 0)) {\n d[i][p] = max(d[i][p], (if (i > 1) d[i - 2][0] else 0) + 1)\n }\n }\n }\n if (b[0][i] == '0' && b[1][i] == '0') {\n for (j in 0..1) {\n if (b[j][i - 1] == '0')\n d[i][0] = max(d[i][0], d[i - 1][1 shl j] + 1)\n }\n }\n }\n println(d[n - 1][0])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0a9bb3bf3aacf7662bfc08cf76149a5b", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "//package codeForces.c491_2\n\nfun main(args: Array) {\n val s1 = (readLine()!! + 'X').toCharArray()\n val s2 = (readLine()!! + 'X').toCharArray()\n\n val lenght = minOf(s1.size, s2.size)\n\n var count = 0\n var i = -1\n while (i < lenght - 1) {\n i++\n if (s1[i] == '0' && s2[i] == '0') {\n if (s1[i + 1] == '0') {\n s1[i + 1] = 'X'\n count++\n continue\n } else if (s2[i + 1] == '0') {\n s2[i + 1] = 'X'\n count++\n continue\n }\n }\n\n if (\n (s1[i] == '0' || s2[i] == '0') &&\n s1[i + 1] == '0' &&\n s2[i + 1] == '0'\n ) {\n count++\n i++\n continue\n }\n }\n\n print(count)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "886a0d79f0c2b34c3043ac78d9c5957e", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n val Q = Array(2) { \"X\" + scanner.next() + \"X\" }\n var last = 0\n var res = 0\n for (i in 0 until Q[0].length) {\n if (Q[0][i] == 'X' && Q[1][i] == 'X') {\n if ((i - last) % 3 == 0)\n res += ((i - last) / 3) * 2\n else if ((i - last) % 3== 2)\n res += ((i - last) / 3) * 2 + 1\n else\n res += ((i - last) / 3) * 2\n last = i + 1\n }\n else if (Q[0][i] == 'X' || Q[1][i] == 'X') {\n if ((i - last) % 3 == 0)\n res += ((i - last) / 3) * 2\n else if ((last - i) % 3 == 2)\n res += ((i - last) / 3) * 2 + 1\n else\n res += (((i - last) / 3) * 2) + 1\n last = i + 1\n }\n else if (Q[0][i] == '0' && Q[1][i] == '0' && ((Q[0][i - 1] == 'X' && Q[1][i - 1] != 'X') || (Q[1][i - 1] == 'X' && Q[0][i - 1] != 'X'))) {\n res++\n last = i + 1\n }\n }\n println(res)\n\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n\nfun IntArray.print() {\n println(Arrays.toString(this))\n}\n\n//class Pair(var a: Int, var b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return b - a - other.b + other.a\n// }\n//}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e970724f3f2b752014109ce16878a36a", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.*\nimport kotlin.math.*\n\nprivate fun readLn() = readLine()!! // string\nprivate fun readInt() = readLn().toInt() // int\nprivate fun readStrings() = readLn().split(\" \") // string string\nprivate fun readInts() = readStrings().map { it.toInt() } // int int\n\nfun isLeapYear(y: Int) = ((y%400 == 0) || (y%4 == 0 && y%100 != 0))\n\nfun main() {\n var n = readInt()\n val isl = isLeapYear(n)\n var nextfake = 0\n var ans = n\n do {\n ans++\n nextfake = if (isLeapYear(ans) == true) (nextfake + 2)%7 else (nextfake + 1)%7\n //println(nextfake)\n } while (nextfake != 0 || isLeapYear(ans) != isl)\n print(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9304c0d055c875978bea3c92f3212ab1", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (numStudents, k) = readLine()!!.split(\" \").map(String::toLong)\n val diplomas = (numStudents / 2) / (k + 1)\n print(\"$diplomas ${k * diplomas} ${numStudents - (k + 1) * diplomas}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b58ef394630872a6bc0264a4bc641ec8", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it -> it.toLong() }\n var a: Long = n / (2 * k + 2)\n print(\"$a ${k * a} ${n - (k + 1) * a}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "59e016cb309210895f4371c0228bfe33", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val(n, k) = readLine()!!.split(' ').map(String::toLong)\n var d = (n / 2) / (k + 1)\n var g = d * k\n var l = n - (g + d)\n println(\"$d $g $l\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d86ffbe9889c3ae3d181fbefbbc206e3", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.Comparator\n\n\nclass Solution : Runnable {\n override fun run() {\n solve()\n }\n\n fun start() {\n Thread(null, Solution(), \"whatever\", (1 shl 27).toLong()).start()\n }\n}\n\nfun main(args: Array) {\n Solution().start()\n}\n\n\nclass IO {\n companion object {\n\n private val reader: InputReader\n private val writer: OutputWriter\n\n init {\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n reader = InputReader(FileInputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/in.txt\"))\n writer = OutputWriter(FileOutputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/out.txt\"))\n } else {\n reader = InputReader(System.`in`)\n writer = OutputWriter(System.`out`)\n }\n }\n\n private fun readMultipleInts(count: Int): List {\n val map = mutableListOf()\n repeat(count) {\n map.add(reader.readInt())\n }\n return map\n }\n\n fun readInt() = reader.readInt()\n fun readLong() = reader.readLong()\n fun readTwoInts() = readMultipleInts(2)\n fun readThreeInts() = readMultipleInts(3)\n fun readFourInts() = readMultipleInts(4)\n fun readFiveInts() = readMultipleInts(5)\n fun readSixInts() = readMultipleInts(6)\n fun readString() = reader.readString()\n fun readTree(n: Int): MutableMap> {\n val graph = mutableMapOf>()\n repeat(n - 1) {\n val u = reader.readInt()\n val v = reader.readInt()\n if (!graph.containsKey(u)) graph[u] = mutableListOf()\n graph[u]!!.add(v)\n }\n return graph\n }\n\n fun readIntArray(n: Int): IntArray {\n return IntArray(n) { readInt() }\n }\n\n fun readLongArray(n: Int): Array {\n return Array(n) { readLong() }\n }\n\n fun write(obj: Any) {\n writer.printLine(obj)\n }\n\n fun flushOutput() {\n writer.flush()\n }\n\n fun closeOutput() {\n writer.close()\n }\n }\n}\n\n\nclass MATH {\n companion object {\n\n val mod = 998244353\n var ispre = false\n\n val factMod = Array(300002) { 1 }\n\n fun pre() {\n for (i in 2 until 300001) {\n factMod[i] = ((factMod[i - 1] * i.toLong()) % MATH.mod).toInt()\n }\n }\n\n fun gcd(a: Int, b: Int): Int {\n if (b == 0)\n return a\n return gcd(b, a % b)\n }\n\n fun gcd(a: Long, b: Long): Long {\n if (b == 0L)\n return a\n return gcd(b, a % b)\n }\n\n fun inverseMod(a: Int): Int {\n return powMod(a, mod - 2)\n }\n\n fun powMod(a: Int, b: Int): Int {\n //calculate a to the power b mod m\n if (b == 0) return 1\n return if (b % 2 == 1) {\n prodMod(a, powMod(a, b - 1))\n } else {\n val p = powMod(a, b / 2)\n prodMod(p, p)\n }\n }\n\n fun ncr(n: Int, r: Int): Int {\n if (!ispre) pre(); ispre = true\n return ((factMod[n].toLong() * inverseMod(((factMod[r].toLong() * factMod[n - r]) % mod).toInt())) % mod).toInt()\n }\n\n fun prodMod(val1: Int, val2: Int): Int {\n return ((val1.toLong() * val2) % mod).toInt()\n }\n\n }\n}\n\nfun solve() {\n\n val n = IO.readInt()\n if (n%2 == 0){\n IO.write(\"white\")\n IO.write(\"1 2\")\n }else{\n IO.write(\"black\")\n }\n\n IO.flushOutput()\n IO.closeOutput()\n}\n\n\nclass SuffixArray(val input : String){\n //time complexity is n(log(n))^2\n\n fun sa() : IntArray{\n val n = input.length\n var cur = IntArray(n) { i -> input[i] -'a' } //will store the current sort order\n for (i in 1 until 20){\n val newCur = IntArray(n) { 0 }\n val newlist = mutableListOf>()\n for (j in 0 until n) {\n newlist.add(Triple(j, cur[j], if ( j+ power(2, i) < n) cur[j + power(2, i)] else -1))\n }\n newlist.sortWith(comparator())\n //after sorting\n for (j in 0 until n){\n newCur[newlist[j].first] = if (j > 0 && newlist[j].second == newlist[j - 1].second && newlist[j].third == newlist[j - 1].third) newCur[newlist[j - 1].first] else j\n }\n cur = newCur\n\n }\n return cur\n }\n\n internal class comparator : Comparator>{\n override fun compare(o1: Triple?, o2: Triple?): Int {\n if (o1!!.second != o2!!.second){\n return o1.second.compareTo(o2.second)\n }else{\n //both are equal what to do now\n return o1.third.compareTo(o2.third)\n }\n }\n }\n\n\n}\n\n\n\nclass Primes{\n val limit = 1000\n val composites = IntArray(limit + 1) { 0 }\n val factors= IntArray(limit + 1) { 0 }\n val preFactors = IntArray(limit + 1) { 0 }\n val primes = mutableListOf()\n\n init {\n sieve()\n calcFactors()\n }\n\n fun sieve(){\n for (i in 2 until limit + 1){\n if (composites[i] == 0){\n primes.add(i)\n var cur = 1\n while (cur*i <= limit){\n composites[cur*i] = i\n cur++\n }\n }\n }\n }\n\n fun calcFactors(){\n for (i in 2 until limit + 1){\n var num = i\n while (num != 1){\n factors[i]++\n num /= composites[num]\n }\n }\n for (i in 2 until limit + 1){\n preFactors[i]= preFactors[i - 1] + factors[i]\n }\n }\n}\n\n\n\nfun isBitSet(num: Int, i: Int): Boolean {\n return (num.and(1.shl(i)) > 0)\n}\n\nfun power(i: Int, j: Int): Int {\n if (j == 0) return 1\n return i * power(i, j - 1)\n}\n\nclass MinSegmentTree(\n input: Array\n) {\n private val tree: Array\n private val lazy: Array\n\n constructor(size: Int) : this(Array(size) { Int.MAX_VALUE })\n\n init {\n val size = nextPowerOfTwo(input.size)\n tree = Array(2 * size) { Int.MAX_VALUE }\n lazy = Array(2 * size) { Int.MAX_VALUE }\n for (i in 0 until input.size) {\n tree[i + size] = input[i]\n }\n for (i in (size - 1) downTo 1) {\n tree[i] = Math.min(tree[leftChild(i)], tree[rightChild(i)])\n }\n }\n\n private fun updateTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int, value: Int) {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) updateLazyNode(index, lowerBound, upperBound, value)\n else {\n updateTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index), value)\n updateTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index), value)\n tree[index] = Math.min(tree[leftChild(index)], tree[rightChild(index)])\n }\n }\n\n private fun queryTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int): Int {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return Int.MAX_VALUE\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) return tree[index]\n else {\n return Math.min(queryTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index)),\n queryTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index)))\n }\n }\n\n private fun updateLazyNode(index: Int, lowerBound: Int, upperBound: Int, delta: Int) {\n tree[index] += delta\n if (lowerBound != upperBound) {\n lazy[leftChild(index)] += delta\n lazy[rightChild(index)] += delta\n }\n lazy[index] = 0\n }\n\n fun getElements(N: Int): List {\n return tree.copyOfRange(tree.size / 2, tree.size / 2 + N).asList()\n }\n\n fun update(lowerRange: Int, upperRange: Int, value: Int) {\n updateTree(lowerRange, upperRange, 1, lazy.size / 2, 1, value)\n }\n\n fun query(lowerRange: Int, upperRange: Int): Int {\n return queryTree(lowerRange, upperRange, 1, lazy.size / 2, 1)\n }\n\n private fun noOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb > u || ub < l)\n\n private fun completeOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb >= l && ub <= u)\n\n\n private fun nextPowerOfTwo(num: Int): Int {\n var exponent = 2\n while (true) {\n if (exponent >= num) {\n return exponent\n }\n exponent *= 2\n }\n }\n\n private fun midIndex(l: Int, r: Int) = (l + r) / 2\n private fun parent(i: Int) = i / 2\n private fun leftChild(i: Int) = 2 * i\n private fun rightChild(i: Int) = 2 * i + 1\n\n}\n\nclass InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var sgn: Long = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var number: Long = 0\n do {\n number *= 10L\n number += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return number * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n}\n\nclass OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n\n fun flush() {\n writer.flush()\n }\n\n}\n\nclass DinitzMaxFlowSolver(val n: Int, val s: Int, val t: Int, val graph: MutableMap>, val edgeMap: MutableMap, Edge>) {\n\n private val level = IntArray(n + 1) { -1 } //storing levels of each vertex in level graph\n var maxFlow = 0L\n\n init {\n solve()\n }\n\n fun solve() {\n val next = IntArray(n + 1) { 0 }\n while (bfs()) {\n Arrays.fill(next, 0)\n var flow = 0L\n do {\n maxFlow += flow\n flow = dfs(s, next, Long.MAX_VALUE)\n } while (flow != 0L)\n }\n }\n\n private fun dfs(at: Int, next: IntArray, flow: Long): Long {\n if (at == t) return flow\n var size = 0\n if (graph.containsKey(at)) size = graph[at]!!.size\n while (next[at] < size) {\n val edge = graph[at]!!.get(next[at])\n if (edge.remainingCapacity() > 0 && level[edge.to] == level[at] + 1) {\n val bottleNeck = dfs(edge.to, next, Math.min(flow, edge.remainingCapacity()))\n if (bottleNeck > 0) {\n edgeMap[Pair(edge.from, edge.to)]!!.flow += bottleNeck\n edgeMap[Pair(edge.to, edge.from)]!!.flow -= bottleNeck\n return bottleNeck\n }\n }\n next[at]++\n }\n return 0\n }\n\n private fun bfs(): Boolean {\n Arrays.fill(level, -1)\n val curLevel = ArrayDeque()\n curLevel.add(s)\n level[s] = 0\n\n while (curLevel.isNotEmpty()) {\n val top = curLevel.poll()\n if (graph.containsKey(top)) {\n graph[top]!!.forEach {\n if (it.remainingCapacity() > 0 && level[it.to] == -1) {\n level[it.to] = level[top] + 1\n curLevel.offer(it.to)\n }\n }\n }\n }\n return level[t] != -1\n }\n\n\n}\n\nclass Edge(val from: Int, val to: Int, val capacity: Long) {\n var flow = 0L\n fun remainingCapacity(): Long {\n return capacity - flow\n }\n}\n\n\nclass ConnectedComponents(val g : Graph, val price : IntArray){\n\n private val visited = HashSet()\n private val stack = Stack()\n private val revertedGraph = revertGraph()\n private val component = mutableListOf()\n var ways= 1L\n var min = 0L\n val mod = 1000000007\n\n init {\n getConnectedComponents()\n }\n\n\n fun getConnectedComponents() {\n g.vertices.forEach {\n if (!visited.contains(it)){\n visited.add(it)\n dfs(it)\n }\n }\n\n visited.clear()\n while (stack.isNotEmpty()){\n val node = stack.pop()\n if (!visited.contains(node)){\n visited.add(node)\n dfs2(node)\n var take = Int.MAX_VALUE\n for (i in 0 until component.size){\n if (price[component[i] - 1] < take){\n take = price[component[i] - 1]\n }\n }\n min+= take\n ways= (ways*component.filter { price[it - 1] == take }.count())%mod\n component.clear()\n }\n }\n }\n\n fun dfs(node : Int){\n if (g.edges.containsKey(node)){\n g.edges[node]!!.forEach {\n if (!visited.contains(it)){\n visited.add(it)\n dfs(it)\n }\n }\n }\n stack.push(node)\n }\n\n fun dfs2(node : Int){\n component.add(node)\n if (revertedGraph.edges.containsKey(node)){\n revertedGraph.edges[node]!!.forEach {\n if (!visited.contains(it)){\n visited.add(it)\n dfs2(it)\n }\n }\n }\n }\n\n fun revertGraph() : Graph {\n val newEdges= mutableMapOf>()\n g.edges.forEach {\n val u = it.key\n val vs = it.value\n vs.forEach { v ->\n if (!newEdges.containsKey(v)){\n newEdges[v]= mutableListOf()\n }\n newEdges[v]!!.add(u)\n }\n }\n return Graph(g.vertices, newEdges)\n }\n}\n\ndata class Graph(val vertices: MutableList, val edges : MutableMap>)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4789b57c0707acf8c001a2482a046769", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n print(readLine()!!.toLong() / 2520)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3d8950a23ab1d3190a2b1fb1c3be204d", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.StringTokenizer\n\nval err = System.err\nval bf = BufferedReader(InputStreamReader(System.`in`))\nvar st = StringTokenizer(\"\")\n\nfun nxtstring(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(bf.readLine())\n return st.nextToken()\n}\n\nfun nxtint() = nxtstring().toInt()\n\nvar n: Long = 0\nval p10 = LongArray(11)\n\nfun findmax9(): Int {\n var ans = 0\n var num = 0L\n while (true) {\n val ldn = n / p10[ans] % 10\n val od = 9 - ldn\n num += p10[ans] * od\n if (num > n) break\n ++ans\n }\n return ans\n}\n\nfun main(args: Array) {\n n = nxtint().toLong()\n p10[0] = 1\n for (i in 1..10) p10[i] = p10[i - 1] * 10\n val max9 = findmax9()\n if (max9 == 0) {\n println(n * (n - 1) / 2)\n return\n }\n var t = 0\n var ans = 0L\n while (true) {\n var num = p10[max9] * t + p10[max9] - 1\n ++t\n var l = 1\n var r = n.toInt()\n while (l < r) {\n var mid: Int = l + (r - l) / 2\n if (num - mid > n) l = mid + 1\n else r = mid\n }\n //err.printf(\"%d %d\\n\", num, l)\n if (num - l <= l || num - l > n) break\n val cnt: Long = num - l - l + 1\n ans += cnt / 2\n }\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bd9f616d5befd79cbb6cf8bb0d3d63e3", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.Math.*\nimport java.util.*\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextLong()\n\n var nine = 0L\n while (true) {\n if (2 * n - 1 < nine * 10 + 9) break\n nine = nine * 10 + 9\n }\n\n if (nine == 0L) {\n println(n * (n - 1) / 2)\n return\n }\n\n val nines = (0 until 9).map { (nine + 1) * it + nine }\n val sum = nines.map { count(it, n) }.sum()\n\n println(sum / 2)\n}\n\nfun count(nine: Long, n: Long): Long {\n val r1 = 1..n\n val r2 = (nine - n)..(nine - 1)\n\n return max(0, min(r1.endInclusive, r2.endInclusive) - max(r1.start, r2.start) + 1)\n}\n\n\nclass FastScanner(s: InputStream) {\n private var st = StringTokenizer(\"\")\n private val br = BufferedReader(InputStreamReader(s))\n\n fun next(): String {\n while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())\n\n return st.nextToken()\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextLine() = br.readLine()\n fun nextDouble() = next().toDouble()\n fun ready() = br.ready()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f7681900a2169f901346c0028978097", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val S = ns().map{it-'a'}.toIntArray()\n val T = ns().map{it-'a'}.toIntArray()\n val N = S.size\n ++S[N-1]\n for (i in N - 1 downTo 0) {\n if (S[i] == 26) {\n S[i] = 0\n ++S[i - 1]\n }\n }\n if (Arrays.equals(S, T)) {\n out.println(\"No such string\")\n } else {\n out.println(S.map { 'a'+it }.joinToString(\"\"))\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun pair(a: A, b: B) = RPair(a, b)\ndata class RPair(val _1: A, val _2: B)\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f66d15756f50a468377df47884b65450", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "enum class SetType {\n EMPTY,\n LINE,\n WHOLE_FIELD\n}\n\ntypealias Line = Triple\n\nfun Line.setType(): SetType {\n if (first == 0 && second == 0 && third == 0) return SetType.WHOLE_FIELD\n if (first == 0 && second == 0) return SetType.EMPTY\n return SetType.LINE\n}\n\nfun calcDet(line1: Line, line2: Line) = line1.first * line2.second - line1.second * line2.first\n\nfun calcIntersections(line1: Line, line2: Line): Int {\n if (line1.setType() == SetType.EMPTY || line2.setType() == SetType.EMPTY) return 0\n if (line1.setType() == SetType.WHOLE_FIELD || line2.setType() == SetType.WHOLE_FIELD) return -1\n val det = calcDet(line1, line2)\n return if (calcDet(line1, line2) != 0) 1 else 0\n}\n\n\nfun main(args: Array) {\n val line1 = readLine()!!.split(\" \").filter { it.isNotBlank() }.map { it.toInt() }.toIntArray()\n val line2 = readLine()!!.split(\" \").filter { it.isNotBlank() }.map { it.toInt() }.toIntArray()\n\n val line1T = Triple(line1[0], line1[1], line1[2])\n val line2T = Triple(line2[0], line2[1], line2[2])\n\n println(calcIntersections(line1T, line2T))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ee461c419afc6bc0a9b89b7141304c42", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "enum class SetType {\n EMPTY,\n LINE,\n WHOLE_FIELD\n}\n\ntypealias Line = Triple\nfun Line.a() = first\nfun Line.b() = second\nfun Line.c() = third\n\n\nfun Line.setType(): SetType {\n if (a() == 0 && b() == 0 && c() == 0) return SetType.WHOLE_FIELD\n if (a() == 0 && b() == 0) return SetType.EMPTY\n return SetType.LINE\n}\n\nfun calcDet(line1: Line, line2: Line) = line1.a() * line2.b() - line1.b() * line2.a()\n\nfun calcIntersections(line1: Line, line2: Line): Int {\n if (line1.setType() == SetType.EMPTY || line2.setType() == SetType.EMPTY) return 0\n if (line1.setType() == SetType.WHOLE_FIELD || line2.setType() == SetType.WHOLE_FIELD) return -1\n val det = calcDet(line1, line2)\n if (det != 0) return 1\n\n return if (line1.first != 0) {\n val c1f = line1.c() * line2.a()\n val c2f = line2.c() * line1.a()\n if (c1f == c2f) -1 else 0\n } else {\n val c1f = line1.c() * line2.b()\n val c2f = line2.c() * line1.b()\n if (c1f == c2f) -1 else 0\n }\n}\n\nfun main(args: Array) {\n val line1 = readLine()!!.split(\" \").filter { it.isNotBlank() }.map { it.toInt() }.toIntArray()\n val line2 = readLine()!!.split(\" \").filter { it.isNotBlank() }.map { it.toInt() }.toIntArray()\n\n val line1T = Triple(line1[0], line1[1], line1[2])\n val line2T = Triple(line2[0], line2[1], line2[2])\n\n println(calcIntersections(line1T, line2T))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6c3be63007c3c40a335845f586beeb0b", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.StringTokenizer\n\nfun main() {\n val n0 = readLong()\n\n val M = LongArray(17)\n for(i in 1 until M.size) M[i] = M[i-1] * 10 + 1\n\n var D = hashMapOf(n0 to 0)\n\n for(k in M.size-2 downTo 1) {\n if(M[k] > n0) continue\n\n val Dk = HashMap()\n\n for((n, c) in D) {\n Dk.checkMin(n % M[k], c + (n / M[k] * k).toInt())\n val n1 = M[k+1] - n\n Dk.checkMin(n1 % M[k], c + k + 1 + (n1 / M[k] * k).toInt())\n }\n\n D = Dk\n }\n\n val ans = D[0]\n\n println(ans)\n}\n\nfun HashMap.checkMin(k: K, v: Int) { if(!containsKey(k) || v < get(k)!!) put(k, v) }\n\n/** IO code start */\n@JvmField val _reader = System.`in`.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(System.out, false)\ninline fun output(block: PrintWriter.()->Unit) { _writer.apply(block).flush() }\nfun iprintln(o: Any?) { println(o) } // immediate println for interactive, bypasses output{} blocks", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "443f64c21ce48fd7f9034541be0ea9f4", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nval ones = ArrayList()\n\nfun lowerBound(n: Long): Int{\n var(lo, hi) = 0 to ones.size - 1\n while(lo < hi){\n val mid = (lo + hi) / 2 + (lo + hi) % 2\n if(ones[mid] < n)\n lo = mid\n else\n hi = mid - 1\n }\n return lo\n}\n\nval memo = HashMap()\n\nfun rec(n: Long): Long{\n if(n in memo)\n return memo[n]!!\n val bs = lowerBound(n)\n if(ones[bs + 1] == n){\n memo[n] = (bs + 2).toLong()\n return (bs + 2).toLong()\n }\n var ans = Long.MAX_VALUE\n if(n - ones[bs] < n)\n ans = min(ans, rec(n - ones[bs]) + bs + 1)\n if(ones[bs + 1] - n < n)\n ans = min(ans, rec(ones[bs + 1] - n) + bs + 2)\n memo[n] = ans\n return ans\n}\n\nfun main() {\n val n = readLine()!!.toLong()\n for(i in 1..16)\n ones.add(\"1\".repeat(i).toLong())\n memo[0L] = 0L\n for(i in 1L..6L)\n memo[i] = i\n for(i in 7L..11L)\n memo[i] = 13-i\n println(rec(n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "72f3ddea841f638e2e134d5a88a4c73c", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nval ones = ArrayList()\n\nfun lowerBound(n: Long): Int{\n var(lo, hi) = 0 to ones.size - 1\n while(lo < hi){\n val mid = (lo + hi) / 2 + (lo + hi) % 2\n if(ones[mid] < n)\n lo = mid\n else\n hi = mid - 1\n }\n return lo\n}\n\nfun rec(n: Long): Long{\n when {\n n == 0L -> return 0L\n n <= 6L -> return n\n n <= 11L -> return 13 - n\n }\n val bs = lowerBound(n)\n if(ones[bs + 1] == n)\n return (bs + 2).toLong()\n var ans = Long.MAX_VALUE\n if(n - ones[bs] < n)\n ans = min(ans, rec(n - ones[bs]) + bs + 1)\n if(ones[bs + 1] - n < n)\n ans = min(ans, rec(ones[bs + 1] - n) + bs + 2)\n return ans\n}\n\nfun main() {\n val n = readLine()!!.toLong()\n for(i in 1..16)\n ones.add(\"1\".repeat(i).toLong())\n println(rec(n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a2eee63517e2798511225532358397da", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val S = ns()\n val N = S.length\n val zero = 9\n val MAX = 19\n val INF = 1e9.toInt()\n val dp = Array(N + 1){IntArray(MAX){INF} }\n dp[0][zero] = 0\n for (i in 0 until N) {\n val target = S[N - 1 - i] - '0'\n for (next in 0 until MAX) {\n for (pre in 0 until MAX) {\n if (dp[i][pre] == INF) continue\n val roll = abs((next - zero) + target) // \u3053\u306e\u6841\u307e\u3067\n val rollback = abs(next - pre - roll) // \u524d\u306e\u6841\u3092\u623b\u3059\n val cost = roll * (i + 1) + rollback * i\n dp[i + 1][next] = min(dp[i + 1][next], dp[i][pre] + cost)\n }\n }\n }\n debugDim(dp)\n out.println(dp[N][zero])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f76cd60668fb5d19c4e62a497b6149e3", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n\n val sc = Scanner(System.`in`)\n val a = arrayOf(\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\")\n val n = sc.nextInt()\n val str = sc.next()\n\n for (i in 0 until 8) {\n var stop = true\n if (n == a[i].length) {\n for (j in 0 until n) {\n if (str[j] != '.') {\n if (str[j] != a[i][j]) {\n stop = false\n break\n }\n }\n }\n if (stop) {\n print(a[i])\n return\n }\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "08a1198d9e0eff872b20685f50902124", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main(){\n var n = readLine()!!.toInt()\n var str = readLine()!!\n if (n==6){\n println(\"espeon\")\n }else if (n==8){\n println(\"vaporeon\")\n }else{\n\n var list = listOf(\"jolteon\",\"flareon\",\"umbreon\",\"leafeon\",\"glaceon\",\"sylveon\")\n for (i in list){\n var flag = false;\n for (j in 0 until i.length){\n if (str[j]!='.' && str[j]!=i[j]){\n flag = true\n break\n }\n }\n if (!flag) println(i)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "abe6b22daf97253f860187f7b666a52d", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.StringTokenizer\nimport java.util.TreeMap\nimport kotlin.math.*\nimport kotlin.random.*\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val s = readLn()\n val cand = listOf(\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\")\n\n val ans = cand.find { c -> c.length == n && c.indices.all { i -> s[i] == '.' || c[i] == s[i] } }\n\n println(ans)\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() {\n iprintln(max(1, 2))\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94ba84981488604cb00b3f39efedbbcc", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nval scanner = Scanner(System.`in`)\n\nfun readInt(): Int = scanner.nextInt()\n\nfun readString(): String = scanner.next()\n\nfun main() = StringBuilder(readString())\n .also { number ->\n var remainingMoves = readInt()\n var index = 0\n\n fun getNextMaxDigitIndex(): Int? {\n if (index == number.lastIndex) return null\n var j = 1\n var maxIndex = index + j\n var maxDigit = number[maxIndex].toInt()\n repeat(remainingMoves - 1) {\n number.getOrNull(index + ++j)?.toInt()?.let { digit ->\n if (digit > maxDigit) {\n maxIndex = index + j\n maxDigit = digit\n }\n }\n }\n return if (number[maxIndex].toInt() > number[index].toInt()) maxIndex else null\n }\n\n while (index < number.length && remainingMoves > 0) {\n getNextMaxDigitIndex()?.let { nextMaxDigitIndex ->\n val maxDigit = number[nextMaxDigitIndex]\n number.deleteCharAt(nextMaxDigitIndex)\n number.insert(index, maxDigit)\n remainingMoves -= nextMaxDigitIndex - index\n }\n index++\n }\n }\n .run(::println)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a0c33debd7f37484a7a365149c011a4f", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val s = reader.next()\n\n var i = 0\n var ans = n\n while (i + 1 < n) {\n if (s[i] == 'R' && s[i + 1] == 'U' || s[i] == 'U' && s[i + 1] == 'R') {\n ans--\n i++\n }\n i++\n }\n writer.println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n val reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c02e4eac43e181138c56e125044c1d21", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var s = \"\"\n do {\n s = readLine()!!\n } while (s.length != n)\n val r = s.replace(\"UR|RU\".toRegex(), \"D\")\n println(r.length)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8b6a5ed6b9e23a11f5783b9edd052cba", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\n\nfun main(args: Array) {\n val toInt = readLine()!!.toInt()\n var previous = 'D'\n var count = 0\n val readLine = readLine()!!\n readLine.forEach { c ->\n previous = if (previous != 'D' && c != previous) {\n count++\n 'D'\n } else {\n c\n }\n }\n println(readLine.length - count)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "035520b15c68555a4aa65a99cd890b26", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n readLine()\n val s = readLine()!!\n if (s.length == 1) return print(1)\n var pos = -1\n var sol = 0\n while (++pos < s.length) {\n sol++\n if (pos < s.lastIndex && s[pos] != s[pos + 1]) pos++\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0f8a7f59e7a4736265c4fdb21e404028", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n Scanner(System.`in`.buffered()).use {\n val n = it.nextInt()\n val s = it.next()\n \n var ans = s.length\n var i = 0\n while (i < s.length - 1) {\n if ((s[i] == 'U' && s[i + 1] == 'R') || (s[i] == 'R' && s[i + 1] == 'U')) {\n --ans\n i += 2\n } else\n i++\n }\n \n println(ans)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "621b4fc792b3209d1b1200eac8bd0618", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n solve(System.`in`, System.out)\n}\n\nval MAX_N = (1e6 + 10).toInt()\nval INF = (1e9 + 7).toInt()\nval MOD = (1e9 + 7).toInt()\n\nfun solve(input: InputStream, output: OutputStream) {\n val reader = InputReader(BufferedInputStream(input))\n val writer = PrintWriter(BufferedOutputStream(output))\n\n solve(reader, writer)\n writer.close()\n}\n\nfun solve(reader: InputReader, writer: PrintWriter) {\n val n = reader.nextInt()\n val s = reader.next()\n\n var i = 0\n var ans = 0\n while (i + 1 < n) {\n if (s[i] == 'U' && s[i + 1] == 'R') {\n ans++\n i++\n } else if (s[i] == 'R' && s[i + 1] == 'U') {\n ans++\n }\n\n i++\n }\n ans = n - ans\n writer.println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n val reader: BufferedReader\n var tokenizer: StringTokenizer? = null\n\n init {\n reader = BufferedReader(InputStreamReader(stream), 32768)\n tokenizer = null\n }\n\n operator fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n try {\n tokenizer = StringTokenizer(reader.readLine())\n } catch (e: IOException) {\n throw RuntimeException(e)\n }\n\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextArrayInt(count: Int): IntArray {\n return nextArrayInt(0, count)\n }\n\n fun nextArrayInt(start: Int, count: Int): IntArray {\n val a = IntArray(start + count)\n for (i in start until start + count) {\n a[i] = nextInt()\n }\n return a\n }\n\n fun nextArrayLong(count: Int): LongArray {\n val a = LongArray(count)\n for (i in 0 until count) {\n a[i] = nextLong()\n }\n return a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dc6ebf4daa9cd6028718568c45d2a77a", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nclass Solution : Runnable {\n override fun run() {\n solve()\n }\n\n fun start() {\n Thread(null, Solution(), \"whatever\", (1 shl 27).toLong()).start()\n }\n}\n\nfun main(args: Array) {\n Solution().start()\n}\n\n\nclass IO {\n companion object {\n\n private val reader: InputReader\n private val writer: OutputWriter\n\n init {\n if (System.getProperty(\"ONLINE_JUDGE\") == null ) {\n reader = InputReader(FileInputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/in.txt\"))\n writer = OutputWriter(FileOutputStream(\"/Users/300041735/competitiveProgramming/src/codeforces/out.txt\"))\n } else {\n reader = InputReader(System.`in`)\n writer = OutputWriter(System.`out`)\n }\n }\n\n private fun readMultipleInts(count: Int): List {\n val map = mutableListOf()\n repeat(count) {\n map.add(reader.readInt())\n }\n return map\n }\n\n fun readInt() = reader.readInt()\n fun readLong() = reader.readLong()\n fun readTwoInts() = readMultipleInts(2)\n fun readThreeInts() = readMultipleInts(3)\n fun readFourInts() = readMultipleInts(4)\n fun readFiveInts() = readMultipleInts(5)\n fun readSixInts() = readMultipleInts(6)\n fun readString() = reader.readString()\n fun readTree(n: Int): MutableMap> {\n val graph = mutableMapOf>()\n repeat(n - 1) {\n val u = reader.readInt()\n val v = reader.readInt()\n if (!graph.containsKey(u)) graph[u] = mutableListOf()\n if (!graph.containsKey(v)) graph[v] = mutableListOf()\n graph[u]!!.add(v)\n graph[v]!!.add(u)\n }\n return graph\n }\n\n fun readIntArray(n: Int): IntArray {\n return IntArray(n) { readInt() }\n }\n\n fun readLongArray(n: Int): Array {\n return Array(n) { readLong() }\n }\n\n fun write(obj: Any) {\n writer.printLine(obj)\n }\n\n fun flushOutput() {\n writer.flush()\n }\n\n fun closeOutput() {\n writer.close()\n }\n }\n}\n\n\nclass MATH {\n companion object {\n\n val mod = 1000000007\n var ispre = false\n\n val factMod = Array(300002) { 1 }\n\n fun pre() {\n for (i in 2 until 300001) {\n factMod[i] = ((factMod[i - 1] * i.toLong()) % MATH.mod).toInt()\n }\n }\n\n fun gcd(a: Int, b: Int): Int {\n if (b == 0)\n return a\n return gcd(b, a % b)\n }\n\n fun gcd(a: Long, b: Long): Long {\n if (b == 0L)\n return a\n return gcd(b, a % b)\n }\n\n fun inverseMod(a: Int): Int {\n return powMod(a, mod - 2)\n }\n\n fun powMod(a: Int, b: Int): Int {\n //calculate a to the power b mod m\n if (b == 0) return 1\n return if (b % 2 == 1) {\n prodMod(a, powMod(a, b - 1))\n } else {\n val p = powMod(a, b / 2)\n prodMod(p, p)\n }\n }\n\n fun ncr(n: Int, r: Int): Int {\n if (!ispre) pre(); ispre = true\n return ((factMod[n].toLong() * inverseMod(((factMod[r].toLong() * factMod[n - r]) % mod).toInt())) % mod).toInt()\n }\n\n fun prodMod(val1: Int, val2: Int): Int {\n return ((val1.toLong() * val2) % mod).toInt()\n }\n\n }\n}\n\nfun solve() {\n\n\n val (n1, n2, k1, k2) = IO.readFourInts()\n val dp = DP(n1, n2, k1,k2)\n IO.write(dp.dp(1, 0, 0, 0 ))\n\n IO.flushOutput()\n IO.closeOutput()\n}\n\nclass DP(val n1 : Int, val n2 : Int, val k1 : Int,val k2 : Int){\n\n\n val map = Array(201) { Array(101) { Array(11) { IntArray(11) { -1 } } } }\n\n fun dp(pos : Int, horses : Int, lastHorses : Int, lastMen : Int) : Int {\n //dp[pos][horses already placed][last placed horsed][last placed men] 200*100*10*10 ~ 2 million states , should be okay\n //possible optimisation if we get TLE dp[pos][horses already placed][last placed whom ?][quantity] 200*100*2*10 ~ 0.4 million states\n\n if (pos == n1 + n2 + 1) return 1\n\n if (map[pos][horses][lastHorses][lastMen] != -1) return map[pos][horses][lastHorses][lastMen]\n val horsesRemaingToBePlaced = n2 - horses\n val footMenRemainingToBePlaced = n1 - (pos - 1 - horses)\n\n var ways= 0\n\n if (horsesRemaingToBePlaced != 0 && lastHorses < k2){\n //horse can be placed\n ways+= dp(pos + 1, horses + 1, lastHorses + 1, 0 )\n }\n if (footMenRemainingToBePlaced != 0 && lastMen < k1){\n ways+= dp(pos + 1, horses, 0, lastMen + 1)\n }\n\n map[pos][horses][lastHorses][lastMen] = ways\n return ways\n }\n}\n\ndata class Graph(val edges: MutableMap>)\n\n\nclass MinSegmentTree(\n input: Array\n) {\n private val tree: Array\n private val lazy: Array\n\n constructor(size: Int) : this(Array(size) { Int.MAX_VALUE })\n\n init {\n val size = nextPowerOfTwo(input.size)\n tree = Array(2 * size) { Int.MAX_VALUE }\n lazy = Array(2 * size) { Int.MAX_VALUE }\n for (i in 0 until input.size) {\n tree[i + size] = input[i]\n }\n for (i in (size - 1) downTo 1) {\n tree[i] = Math.min(tree[leftChild(i)], tree[rightChild(i)])\n }\n }\n\n private fun updateTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int, value: Int) {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) updateLazyNode(index, lowerBound, upperBound, value)\n else {\n updateTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index), value)\n updateTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index), value)\n tree[index] = Math.min(tree[leftChild(index)], tree[rightChild(index)])\n }\n }\n\n private fun queryTree(lowerRange: Int, upperRange: Int, lowerBound: Int, upperBound: Int, index: Int): Int {\n updateLazyNode(index, lowerBound, upperBound, lazy[index])\n if (noOverlap(lowerRange, upperRange, lowerBound, upperBound)) return Int.MAX_VALUE\n else if (completeOverlap(lowerRange, upperRange, lowerBound, upperBound)) return tree[index]\n else {\n return Math.min(queryTree(lowerRange, upperRange, lowerBound, midIndex(lowerBound, upperBound), leftChild(index)),\n queryTree(lowerRange, upperRange, midIndex(lowerBound, upperBound) + 1, upperBound, rightChild(index)))\n }\n }\n\n private fun updateLazyNode(index: Int, lowerBound: Int, upperBound: Int, delta: Int) {\n tree[index] += delta\n if (lowerBound != upperBound) {\n lazy[leftChild(index)] += delta\n lazy[rightChild(index)] += delta\n }\n lazy[index] = 0\n }\n\n fun getElements(N: Int): List {\n return tree.copyOfRange(tree.size / 2, tree.size / 2 + N).asList()\n }\n\n fun update(lowerRange: Int, upperRange: Int, value: Int) {\n updateTree(lowerRange, upperRange, 1, lazy.size / 2, 1, value)\n }\n\n fun query(lowerRange: Int, upperRange: Int): Int {\n return queryTree(lowerRange, upperRange, 1, lazy.size / 2, 1)\n }\n\n private fun noOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb > u || ub < l)\n\n private fun completeOverlap(l: Int, u: Int, lb: Int, ub: Int): Boolean = (lb >= l && ub <= u)\n\n\n private fun nextPowerOfTwo(num: Int): Int {\n var exponent = 2\n while (true) {\n if (exponent >= num) {\n return exponent\n }\n exponent *= 2\n }\n }\n\n private fun midIndex(l: Int, r: Int) = (l + r) / 2\n private fun parent(i: Int) = i / 2\n private fun leftChild(i: Int) = 2 * i\n private fun rightChild(i: Int) = 2 * i + 1\n\n}\n\nclass InputReader(private val stream: InputStream) {\n private val buf = ByteArray(1024)\n private var curChar: Int = 0\n private var numChars: Int = 0\n private val filter: SpaceCharFilter? = null\n\n fun read(): Int {\n if (numChars == -1)\n throw InputMismatchException()\n if (curChar >= numChars) {\n curChar = 0\n try {\n numChars = stream.read(buf)\n } catch (e: IOException) {\n throw InputMismatchException()\n }\n\n if (numChars <= 0)\n return -1\n }\n return buf[curChar++].toInt()\n }\n\n fun readInt(): Int {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n var sgn = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var res = 0\n do {\n if (c < '0'.toInt() || c > '9'.toInt())\n throw InputMismatchException()\n res *= 10\n res += c - '0'.toInt()\n c = read()\n } while (!isSpaceChar(c))\n return res * sgn\n }\n\n fun readLong(): Long {\n var c = read()\n while (isSpaceChar(c)) {\n c = read()\n }\n var sgn: Long = 1\n if (c == '-'.toInt()) {\n sgn = -1\n c = read()\n }\n var number: Long = 0\n do {\n number *= 10L\n number += (c - '0'.toInt()).toLong()\n c = read()\n } while (!isSpaceChar(c))\n return number * sgn\n }\n\n fun readString(): String {\n var c = read()\n while (isSpaceChar(c))\n c = read()\n val res = StringBuilder()\n do {\n res.appendCodePoint(c)\n c = read()\n } while (!isSpaceChar(c))\n return res.toString()\n }\n\n fun isSpaceChar(c: Int): Boolean {\n return filter?.isSpaceChar(c)\n ?: (c == ' '.toInt() || c == '\\n'.toInt() || c == '\\r'.toInt() || c == '\\t'.toInt() || c == -1)\n }\n\n operator fun next(): String {\n return readString()\n }\n\n interface SpaceCharFilter {\n fun isSpaceChar(ch: Int): Boolean\n }\n}\n\nclass OutputWriter {\n private val writer: PrintWriter\n\n constructor(outputStream: OutputStream) {\n writer = PrintWriter(BufferedWriter(OutputStreamWriter(outputStream)))\n }\n\n constructor(writer: Writer) {\n this.writer = PrintWriter(writer)\n }\n\n fun print(vararg objects: Any) {\n for (i in objects.indices) {\n if (i != 0)\n writer.print(' ')\n writer.print(objects[i])\n }\n }\n\n fun printLine(vararg objects: Any) {\n print(*objects)\n writer.println()\n }\n\n fun close() {\n writer.close()\n }\n\n fun flush() {\n writer.flush()\n }\n\n}\n\nclass DinitzMaxFlowSolver(val n: Int, val s: Int, val t: Int, val graph: MutableMap>, val edgeMap: MutableMap, Edge>) {\n\n private val level = IntArray(n + 1) { -1 } //storing levels of each vertex in level graph\n var maxFlow = 0L\n\n init {\n solve()\n }\n\n fun solve() {\n val next = IntArray(n + 1) { 0 }\n while (bfs()) {\n Arrays.fill(next, 0)\n var flow = 0L\n do {\n maxFlow += flow\n flow = dfs(s, next, Long.MAX_VALUE)\n } while (flow != 0L)\n }\n }\n\n private fun dfs(at: Int, next: IntArray, flow: Long): Long {\n if (at == t) return flow\n var size = 0\n if (graph.containsKey(at)) size = graph[at]!!.size\n while (next[at] < size) {\n val edge = graph[at]!!.get(next[at])\n if (edge.remainingCapacity() > 0 && level[edge.to] == level[at] + 1) {\n val bottleNeck = dfs(edge.to, next, Math.min(flow, edge.remainingCapacity()))\n if (bottleNeck > 0) {\n edgeMap[Pair(edge.from, edge.to)]!!.flow += bottleNeck\n edgeMap[Pair(edge.to, edge.from)]!!.flow -= bottleNeck\n return bottleNeck\n }\n }\n next[at]++\n }\n return 0\n }\n\n private fun bfs(): Boolean {\n Arrays.fill(level, -1)\n val curLevel = ArrayDeque()\n curLevel.add(s)\n level[s] = 0\n\n while (curLevel.isNotEmpty()) {\n val top = curLevel.poll()\n if (graph.containsKey(top)) {\n graph[top]!!.forEach {\n if (it.remainingCapacity() > 0 && level[it.to] == -1) {\n level[it.to] = level[top] + 1\n curLevel.offer(it.to)\n }\n }\n }\n }\n return level[t] != -1\n }\n\n\n}\n\nclass Edge(val from: Int, val to: Int, val capacity: Long) {\n var flow = 0L\n fun remainingCapacity(): Long {\n return capacity - flow\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dbcc9baa878288ea78f3c63fe53b49e6", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main(args : Array) {\n Thread { run() }.start()\n}\n\nval scanner = Scanner(System.`in`)\nval n1 =scanner.nextInt()\nval n2 = scanner.nextInt()\nval k1 = scanner.nextInt()\nval k2 = scanner.nextInt()\nval arr = Array>>(n1 + 1) { Array>(n2 + 1) { Array(k1 + 1) { IntArray(k2 + 1) { -1 } } } }\nval mod = 100000000\n\nfun run() {\n\n println(Q(n1, n2, 0, 0))\n\n}\n\nfun Q(q1: Int, q2: Int, w1: Int, w2: Int): Int {\n if (arr[q1][q2][w1][w2] != -1)\n return arr[q1][q2][w1][w2]\n var res = 0\n if (q1 != 0 && w1 != k1)\n res += Q(q1 - 1, q2, w1 + 1, 0)\n if (q2 != 0 && w2 != k2)\n res += Q(q1, q2 - 1, 0, w2 + 1)\n if (q1 == 0 && q2 == 0)\n res = 1\n res %= mod\n arr[q1][q2][w1][w2] = res\n return res\n}\n\n//fun run() {\n//\n// val scanner = Scanner(System.`in`)\n// val n1 = scanner.nextInt()\n// val n2 = scanner.nextInt()\n// val k1 = scanner.nextInt()\n// val k2 = scanner.nextInt()\n// val arr = Array>>(n1 + 1) { Array>(n2 + 1) { Array(k1 + 1) { IntArray(k2 + 1) } } }\n// val mod = 100000000\n// arr[0][0][0][0] = 1\n// for (i1 in 0 until n1) {\n// for (i2 in 0 until n2) {\n// for (j1 in 0 until k1) {\n// for (j2 in 0 until k2) {\n// arr[i1][i2][j1][j2] %= mod\n// arr[i1 + 1][i2][j1 + 1][j2] += arr[i1][i2][j1][j2]\n// arr[i1][i2 + 1][j1][j2 + 1] += arr[i1][i2][j1][j2]\n// arr[i1][i2 + 1][j1][j2] += arr[i1][i2][j1][j2]\n// arr[i1 + 1][i2][j1][j2] += arr[i1][i2][j1][j2]\n// }\n// }\n// }\n// }\n// var res = 0\n// for (i in 0..k1) {\n// for (j in 0..k2) {\n// res += arr[n1][n2][i][j]\n// res %= mod\n// }\n// }\n// println(res)\n//}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\nfun IntArray.print() {\n println(Arrays.toString(this))\n}\nfun Array.print() {\n for (i in this)\n i.print()\n}\nfun LongArray.print() {\n println(Arrays.toString(this))\n}\nfun Array.print() {\n for (i in this)\n i.print()\n}\nfun BooleanArray.print() {\n println(Arrays.toString(this))\n}\nfun nod(a: Long, b: Long): Long {\n var a1 = a\n var b1 = b\n while (a1 != 0L && b1 != 0L) {\n if (a1 < b1)\n b1 %= a1\n else\n a1 %= b1\n }\n return a1 + b1\n}\nfun nok(a: Long, b: Long): Long = a * b / nod(a, b)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3b13779f5a53f52d95f05130758a0c5a", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val numHalfDigits = readInt()\n val ticket = readLine()!!\n val firstHalf = ticket.substring(0 until numHalfDigits).map { c -> c.toInt() }.sorted()\n val secondHalf = ticket.substring(numHalfDigits).map { c -> c.toInt() }.sorted()\n if (firstHalf[0] == secondHalf[0]) return print(\"NO\")\n val (bigger, smaller) = if (firstHalf[0] > secondHalf[0]) firstHalf to secondHalf else secondHalf to firstHalf\n for (pos in bigger.indices)\n if (bigger[pos] <= smaller[pos]) return print(\"NO\")\n print(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b80e7ea042febbdcf3cd24355996ed27", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "// https://codeforces.com/problemset/problem/38/B Chess train\nimport kotlin.math.*;\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\n\nenum class FigType {\n ROOK, KNIGHT\n}\n\nfun chessFromString(s : String, type:FigType):ChessPos {\n val xx = (s[0] - 'a').toInt()\n val yy = (s[1]+\"\").toInt() - 1\n return ChessPos(xx,yy,type)\n}\n\n/** chess position as two ints from 0 */\nclass ChessPos(val x:Int, val y:Int, val type : FigType) {\n\n fun beats(o:ChessPos) : Boolean {\n var b : Boolean\n if (type == FigType.KNIGHT) {\n b = ((abs(x - o.x) == 1) && (abs(y - o.y) == 2))\n b = b || (abs(x - o.x) == 2 && Math.abs(y - o.y) == 1)\n } else {\n b = x == o.x\n b = b || (y == o.y)\n }\n return b\n }\n\n fun equals(o:ChessPos) : Boolean {\n val b = (x == o.x) && (y == o.y)\n return b\n }\n}\n\nfun main() {\n var numWays = 0\n val rook = chessFromString(readLn(), FigType.ROOK)\n val knight = chessFromString(readLn(), FigType.KNIGHT)\n for (x in 0..7) {\n for (y in 0..7) {\n val f = ChessPos(x,y,FigType.KNIGHT)\n if (f.equals(rook) || f.equals(knight)) {\n continue\n }\n if (rook.beats(f) || knight.beats(f) || f.beats(rook)) {\n continue\n } else {\n numWays++\n }\n }\n }\n println(numWays)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2ce050455239cec8a17ff4216cb954b7", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nprivate fun readLn() = readLine()!! // string\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() //long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints\nprivate fun readLongs() = readStrings().map {it.toLong()} // list of longs\n\nval M = 1e5.toInt()+5\nval MOD = 1e9.toInt() + 7\n\n\nfun msk(r: Int) :Int\n{\n var sol = 0;var exp = 0\n var c = r\n while(c>0)\n {\n if(c%10 == 4 || c%10 == 7)\n {\n var t = c%10\n for(q in 0 until exp) t*= 10\n exp++\n sol += t\n }\n c = c/10\n }\n return sol\n}\n\nfun main() {\n val (a,b) = readInts()\n for(i in (a+1) until 1e7.toInt())\n {\n if(msk(i) == b)\n {\n println(i)\n return\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1db56b86f4d3219e3c87947c2c6d9c06", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\n\ntailrec fun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n return gcd(b, a % b)\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val T = nl()\n val A = nl()\n val B = nl()\n\n fun answer(x: Long) {\n val d = gcd(x - 1, T)\n out.println(\"${(x - 1)/d}/${T/d}\")\n }\n\n if (A == B) {\n answer(T + 1)\n return\n }\n\n val a = A / gcd(A, B)\n if (a > T / B) {\n answer(min(T + 1, min(A, B)))\n return\n }\n val lcm = a * B\n val size = ((T + 1 + lcm - 1)/ lcm)\n val r = (T + 1) % lcm\n debug{\"$lcm $size $r\"}\n if (size == 1L) {\n answer(min(T + 1, min(A, B)))\n return\n }\n\n var ans = 0L\n ans += min(A, B) * (size - 1)\n ans += min(r + 1, min(A, B))\n debug{\"$ans\"}\n answer(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a203b0c705cc4f161f406948c90ec096", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.lang.AssertionError\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\ntailrec fun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n return gcd(b, a % b)\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val T = nl()\n val A = nl()\n val B = nl()\n\n fun answer(x: Long) {\n val d = gcd(x - 1, T)\n out.println(\"${(x - 1)/d}/${T/d}\")\n }\n\n if (A == B) {\n answer(T + 1)\n return\n }\n\n val a = A / gcd(A, B)\n if (a > T / B) {\n answer(min(T + 1, min(A, B)))\n return\n }\n val lcm = a * B\n val size = (T + 1)/ lcm\n val r = (T + 1) % lcm\n debug{\"$lcm $size $r\"}\n\n var ans = 0L\n ans += min(A, B) * size\n if (r != 0L) ans += min(r, min(A, B))\n debug{\"$ans\"}\n answer(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private inline fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private inline fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private inline fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n\n private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4855044b4c338b8036145e1e9baf6983", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main(){\n repeat(8){\n var line = readLine()!!\n var flag =\n if (line.contains(\"WW\") || line.contains(\"BB\")){\n println(\"NO\")\n return\n }else{\n\n }\n }\n println(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0bee9c0dd708b25e0ab77980fd4f7ac0", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.*\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n for (i in 0 until 8) {\n val str = scanner.next()\n for (j in 0 until 8) {\n if (str[(j + 1) % 8] == str[j]) {\n println(\"NO\")\n return\n }\n }\n }\n println(\"YES\")\n\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\n//class Pair(var a: Int, var b: Int): Comparable {\n// override fun compareTo(other: Pair): Int {\n// return b - a - other.b + other.a\n// }\n//}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cffb2eadf4f49b948121197495542aad", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val n = r.readLine()!!.toLong()\n var x = n\n val list = arrayListOf()\n\n var i = 2L;\n while (i * i <= x) {\n while (x % i == 0L) {\n list.add(i)\n x /= i\n }\n i += 1\n }\n if (x != n && x != 1L) {\n list.add(x);\n }\n\n if (list.size > 2) {\n println(1)\n println(list.get(0) * list.get(1))\n } else if (list.size == 2) {\n println(2)\n } else {\n println(1)\n println(0)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8ccf4bbae15ae9e10a1bc183e5fc616f", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args : Array) {\n //====== Input preparations ========================================================\n// val fin = BufferedReader(FileReader(\"c.in\"))\n val fin = BufferedReader(InputStreamReader(System.`in`))\n val fout = PrintWriter (System.out)\n var tokenizer = StringTokenizer(\"\")\n fun next() : String {\n while (!tokenizer.hasMoreTokens())\n tokenizer = StringTokenizer(fin.readLine())\n return tokenizer.nextToken()\n }\n fun nextInt() = next().toInt()\n fun nextPair() = nextInt() to nextInt()\n fun nextPairDec() = nextInt()-1 to nextInt()-1\n //====== Solution below ============================================================\n val s = next()\n val cnt = Array(26, {0})\n for (c in s)\n cnt[c - 'A']++\n\n var dbl = ' '\n for (i in 0..25) {\n if (cnt[i] > 1) {\n dbl = 'A' + i\n break\n }\n }\n val pos1 = s.indexOf(dbl)\n val pos2 = s.indexOf(dbl, pos1 + 1)\n if (pos2 == pos1 + 1) {\n fout.println(\"Impossible\")\n fout.close()\n return\n }\n val res = Array(2) {Array(13) {'!'}}\n var top = 0\n var down = 0\n var s1 = (pos1 + pos2) / 2\n var s2 = s1 + 1\n while (s1 > pos1)\n res[0][top++] = s[s1--]\n while (s2 < pos2)\n res[1][down++] = s[s2++]\n res[1][down++] = dbl\n fun next(pos: Pair) : Pair {\n val (r,c) = pos\n if (r == 1 && c == 12)\n return 0 to 12\n if (r == 1)\n return 1 to (c+1)\n return 0 to (c-1)\n }\n var (row,col) = 1 to down\n for (c in s.substring(pos2+1)) {\n res[row][col] = c\n val pos = next(row to col)\n row = pos.first\n col = pos.second\n }\n for (c in s.substring(0, pos1)) {\n res[row][col] = c\n val pos = next(row to col)\n row = pos.first\n col = pos.second\n }\n for (arr in res) {\n for (c in arr)\n fout.print(c)\n fout.println()\n }\n fout.close()\n fin.close()\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "57432f33420d73c4ecbd9a757630c49a", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun POW(N:Int ,P: Int ,mod : Int):Int{\n var x=1\n var n=N\n var p=P\n while (p > 0) {\n if (p%2 == 0) {\n n = n*n %mod\n p /= 2\n } else {\n x = x*n %mod\n p -= 1\n }\n }\n\n return x\n}\n\nfun main(){\n var (n,K) = readLine()!!.split(' ').map { it.toInt() }\n val mod=1000000007\n\n var FACT=mutableListOf()\n var F=mutableListOf()\n var FACT_INV=mutableListOf()\n\n FACT.add(1)\n F.add(0)\n\n for (i in 1..1000010){\n FACT.add(FACT[i-1]*i%mod)\n F.add((F[i-1]+POW(i,K,mod))%mod)\n }\n\n //println(FACT[1000010])\n\n FACT_INV.add(POW(FACT[1000010],mod-2,mod))\n\n for (i in 1000010 downTo 1){\n FACT_INV.add(FACT_INV[1000010-i]*i%mod)\n }\n\n //println(FACT_INV[0])\n //println(FACT_INV[1000010])\n FACT_INV = FACT_INV.asReversed()\n\n //println(FACT_INV[0])\n //println(FACT_INV[1000010])\n\n var ANS=0L\n var PI=1L\n\n if (n<=K+2){\n println(F[n.toInt()])\n return\n }\n\n for (i in 1..K+2){\n PI=PI*(n-i)%mod\n if ((K+2-i)%2==0){\n ANS=ANS+F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)\n ANS=(ANS+mod)%mod\n }\n else{\n ANS=ANS-F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)\n ANS=(ANS+mod)%mod\n }\n }\n println((ANS*PI+mod)%mod)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5dff1a1c94a4ef95d1d48e472c705fef", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "fun POW(N:Int ,P: Int ,mod : Int):Int{\n var x=1\n var n=N\n var p=P\n while (p > 0) {\n if (p%2 == 0) {\n n = (n.toLong()*n %mod).toInt()\n p /= 2\n } else {\n x = (x.toLong()*n %mod).toInt()\n p -= 1\n }\n }\n\n return x\n}\n\nfun main(){\n var (n,K) = readLine()!!.split(' ').map { it.toInt() }\n val mod=1000000007\n\n var FACT=mutableListOf()\n var F=mutableListOf()\n var FACT_INV=mutableListOf()\n\n FACT.add(1)\n F.add(0)\n\n for (i in 1..1000010){\n FACT.add((FACT[i-1].toLong()*i%mod).toInt())\n F.add((F[i-1]+POW(i,K,mod))%mod)\n }\n\n //println(FACT[1000010])\n\n FACT_INV.add(POW(FACT[1000010],mod-2,mod))\n\n for (i in 1000010 downTo 1){\n FACT_INV.add((FACT_INV[1000010-i].toLong()*i%mod).toInt())\n }\n\n //println(FACT_INV[0])\n //println(FACT_INV[1000010])\n FACT_INV = FACT_INV.asReversed()\n\n //println(FACT_INV[0])\n //println(FACT_INV[1000010])\n\n var ANS=0L\n var PI=1L\n\n if (n<=K+2){\n println(F[n])\n return\n }\n\n for (i in 1..K+2){\n PI=PI*(n-i)%mod\n if ((K+2-i)%2==0){\n ANS=ANS+F[i.toInt()].toLong()*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)\n ANS=(ANS+mod)%mod\n }\n else{\n ANS=ANS-F[i.toInt()].toLong()*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)\n ANS=(ANS+mod)%mod\n }\n }\n println((ANS*PI+mod)%mod)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6776fd73f2ec9dee5ffea0845dbd5690", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val n = readInt()\n var xs = readInts().sorted()\n var sol = 0\n while (xs.isNotEmpty()) {\n sol++\n var numElements = 0\n val newXs = mutableListOf()\n for (x in xs) {\n if (x >= numElements) numElements++ else newXs.add(x)\n }\n xs = newXs\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ad67d2763ae37f4db6dc43681e54e806", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\n/**\n *\n *This solution works due to the small input, but the solution is O(n^2). A linear solution can be found here:\n * https://codeforces.com/contest/388/submission/8807640\n * This solution uses -~f, which is the same than (f+1). If f is 3, ~f is -4 and -~f is 4. Probably uses it to save\n * some characters. The kotlin version of this solution is below\n */\n\n//fun main() {\n// fun readInt() = readLine()!!.toInt()\n// fun readLong() = readLine()!!.toLong()\n// fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n// fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n//\n// val n = readInt()\n// var xs = readInts().sorted()\n// var sol = 0\n// while (xs.isNotEmpty()) {\n// sol++\n// var numElements = 0\n// val newXs = mutableListOf()\n// for (x in xs) {\n// if (x >= numElements) numElements++ else newXs.add(x)\n// }\n// xs = newXs\n// }\n// print(sol)\n//}\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n readLine()\n val xs = readInts().sorted()\n var sol = 0\n for((index, x) in xs.withIndex()) sol = max(sol, index / (x+1))\n print(sol + 1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d75463a8dad6870ee922886e5b016b8c", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun solve(n:Long, m:Long, k:Long):Long? {\n var ret:Long? = 0L\n if( k == 0L )\n ret = n * m\n else if( (n-1) + (m-1) < k )\n ret = -1\n else {\n val shortSide = listOf(n, m).max()\n val longSide = listOf(n, m).max()\n\n // \u4e21\u65b9\u306e\u8fba\u3092\u5272\u3089\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u5834\u5408\n if( longSide!! < (k+1) ) {\n ret = listOf( solve(1, m, (k + 1) - n)!!, solve(n, 1, (k + 1) - m)!! ).max()\n }\n // \u7247\u65b9\u5411\u304b\u3089\u3060\u3051\u5272\u3063\u3066\u3001\u5927\u304d\u3044\u65b9\u3092\u63a1\u7528\n else {\n val nCut = ( n / (k+1) ) * m\n val mCut = ( m / (k+1) ) * n\n ret = listOf(nCut, mCut).max()\n }\n }\n return ret\n}\n\nfun main(args:Array) {\n val (n,m,k) = readLine()!!.split(\" \").map { it.toLong() } \n println( solve(n,m,k) )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0498f1141691fcce978a79d20cf743c9", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val (n, x, y) = readLine()!!.split(\" \").map { it.toLong() }\n fun minChanges(z: Long): Long {\n var res = 0\n var curr = 0\n for (chara in z.toString(2)) {\n if (chara == '1') {\n curr++\n } else {\n res += min(2, curr)\n curr = 0\n }\n }\n res += min(2, curr)\n return res.toLong() * x\n }\n var answer = Long.MAX_VALUE\n for (e in 0..29) {\n answer = min(answer, (e.toLong() * y) + ((n shr e) * x) + minChanges(n % (1L shl e)))\n }\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8b006d6b1b37270d9f67103f13c20f33", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val A = nl()\n val B = nl()\n var ans = 0L\n for (m in 1 until B) {\n val cum = A * (A + 1) / 2 % MOD\n val cnt = A\n ans += (m * cnt + m * B % MOD * cum) % MOD\n }\n out.println(ans % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n, offset) { ni() }\n }\n\n private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i + offset)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun pair(a: A, b: B) = RPair(a, b)\ndata class RPair(val _1: A, val _2: B)\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b61cd64527f37d95066d70a16e4bec09", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val A = nl()\n val B = nl()\n var ans = 0L\n for (m in 1 until B) {\n val cum = A * (A + 1) / 2 % MOD\n val cnt = A\n ans += (m * cnt + m * B % MOD * cum) % MOD\n }\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n, offset) { ni() }\n }\n\n private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i + offset)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun pair(a: A, b: B) = RPair(a, b)\ndata class RPair(val _1: A, val _2: B)\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5930687cd5822cbc1645b74e07370153", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n val k = 2 * readLine()!!.toInt()\n val occs = mutableMapOf().withDefault { 0 }\n repeat(4) {\n for (c in readLine()!!)\n if (c != '.') occs[c] = occs.getValue(c) + 1\n }\n print(if(occs.isEmpty() || occs.values.max()!! <= k) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c24664a5a15c6e521334ec559369fefb", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val (n, q) = jin.readLine().split(\" \").map { it.toInt() }\n val flowers = jin.readLine().split(\" \").map { it.toInt() }\n val types = mutableMapOf>()\n val bit = RangeBIT(n)\n val overall = TreeSet(compareBy { it.from })\n for (j in 1..n) {\n val f = flowers[j - 1]\n if (f !in types) {\n types[f] = TreeSet(compareBy { it.from })\n types[f]!!.add(Segment(0, 0, f))\n }\n val j2 = types[f]!!.last().to\n bit.update(1, j - j2, 1L)\n bit.update(n + 2 - j, n + 1 - j2, -1L)\n types[f]!!.add(Segment(j, j, f))\n overall.add(Segment(j, j, f))\n\n }\n fun changeContribution(segment: Segment, sign: Long) {\n val left = types[segment.type]!!.lower(segment)!!\n bit.update(1, 1, sign * (segment.to - segment.from).toLong())\n bit.update(n + 2 - segment.to, n + 1 - segment.from, -sign)\n bit.update(1, segment.from - left.to, sign)\n bit.update(n + 2 - segment.from, n + 1 - left.to, -sign)\n }\n fun remove(segment: Segment) {\n changeContribution(segment, -1L)\n val right = types[segment.type]!!.higher(segment)\n if (right != null) {\n changeContribution(right, -1L)\n }\n overall.remove(segment)\n types[segment.type]!!.remove(segment)\n if (right != null) {\n changeContribution(right, 1L)\n }\n }\n fun add(segment: Segment) {\n if (segment.type !in types) {\n types[segment.type] = TreeSet(compareBy { it.from })\n types[segment.type]!!.add(Segment(0, 0, segment.type))\n }\n val right = types[segment.type]!!.higher(segment)\n if (right != null) {\n changeContribution(right, -1L)\n }\n overall.add(segment)\n types[segment.type]!!.add(segment)\n changeContribution(segment, 1L)\n if (right != null) {\n changeContribution(right, 1L)\n }\n }\n val out = StringBuilder()\n for (j in 1..q) {\n val line = jin.readLine().split(\" \").map { it.toInt() }\n if (line[0] == 1) {\n val l = line[1]\n val r = line[2]\n val x = line[3]\n while (true) {\n val segment = overall.floor(Segment(r, r, 0))\n if (segment == null || segment.to < l) {\n break\n }\n remove(segment)\n if (segment.to > r) {\n add(Segment(r + 1, segment.to, segment.type))\n }\n if (segment.from < l) {\n add(Segment(segment.from, l - 1, segment.type))\n break\n }\n }\n add(Segment(l, r, x))\n //println(overall)\n /*for (k in 1..n) {\n print(\"${bit[1, k]} \")\n }*/\n //println()\n } else {\n val k = line[1]\n out.appendln(bit[1, k])\n }\n }\n print(out)\n}\n\ndata class Segment(val from: Int, val to: Int, val type: Int)\n\nclass RangeBIT internal constructor(treeTo: Int) {\n val value: LongArray\n val weightedVal: LongArray\n fun updateHelper(index: Int, delta: Long) {\n val weightedDelta = index.toLong() * delta\n var j = index\n while (j < value.size) {\n value[j] += delta\n weightedVal[j] += weightedDelta\n j += j and -j\n }\n }\n\n fun update(from: Int, to: Int, delta: Long) {\n //println(\"update($from, $to) + $delta\")\n if (from <= to) {\n updateHelper(from, delta)\n updateHelper(to + 1, -delta)\n }\n }\n\n fun query(to: Int): Long {\n var res: Long = 0\n var weightedRes: Long = 0\n var j = to\n while (j > 0) {\n res += value[j]\n weightedRes += weightedVal[j]\n j -= j and -j\n }\n return (to + 1).toLong() * res - weightedRes\n }\n\n operator fun get(from: Int, to: Int): Long {\n return if (to < from) {\n 0\n } else query(to) - query(from - 1)\n }\n\n init {\n value = LongArray(treeTo + 2)\n weightedVal = LongArray(treeTo + 2)\n }\n}\n\n/*\n10 10\n1 2 6 7 6 4 6 8 9 2\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n\n\n */", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6b08a7cfb48628606e879066e09a77bf", "src_uid": "ac85e953ff1cce050834f4e793ec1f02", "difficulty": 3500.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\n\n val (a, b) = readLine()!!.split(' ')\n var al = a.toInt()\n var ar = b.toInt()\n\n val (x, y) = readLine()!!.split(' ')\n var bl = x.toInt()\n var br = y.toInt()\n\n if(touch(al, br)==1){\n println(\"YES\")\n }\n else if(touch(ar, bl)==1){\n println(\"YES\")\n }\n else\n println(\"NO\")\n}\n\nfun touch(a:Int, b: Int): Int {\n if(a==b) {return 1}\n else if(a>b){\n if((a-b) < 2){\n return 1\n }\n else return 0\n }\n else if(a=b){\n return 1\n }\n else return 0\n }\n else return 0\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9836837b09e473fba197ead7879a35a0", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val cmd = readLine()!!\n val path = mutableSetOf>()\n var x = 0\n var y = 0\n path.add(Pair(0, 0))\n var ok = true\n for (step in cmd) {\n when (step) {\n 'L' -> x--\n 'R' -> x++\n 'U' -> y--\n 'D' -> y++\n }\n if (path.contains(Pair(x, y))) {\n ok = false\n println(\"BUG\")\n break\n }\n path.add(Pair(x, y))\n }\n if (ok) println(\"OK\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a03057992983bcc6a1dd2892d891c57e", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val (L, R) = na2(N)\n\n var ans = 0.0\n\n for (i in 0 until N) {\n for (j in 0 until N) {\n if (i == j) continue\n for (x in L[j] .. R[j]) {\n var prob = 1.0\n for (k in 0 until N) {\n if (k == j) continue\n\n prob *= if (k == i) {\n val l = max(if (i < j) x else x + 1, L[i])\n val r = R[i]\n max(0, r - l + 1)\n } else {\n val l = L[k]\n val r = min(if (j < k) x else x - 1, R[k])\n max(0, r - l + 1)\n }\n }\n ans += prob * x\n }\n }\n }\n\n debug{\"ans:$ans\"}\n for (i in 0 until N) {\n ans /= (R[i] - L[i] + 1)\n }\n\n out.println(\"%.10f\".format(ans))\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b092abef704ebb1fe5957899ea832dbb", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "Kotlin 1.6", "source_code": "\r\nfun main() {\r\n val (p1, t1) = readln().split(' ').let { (p, t) -> p.toInt() to t.toLong() }\r\n val (p2, t2) = readln().split(' ').let { (p, t) -> p.toInt() to t.toLong() }\r\n val (h, s) = readln().split(' ').let { (h, s) -> h.toInt() to s.toLong() }\r\n val minTime = LongArray(h + 1){Long.MAX_VALUE shr 1}.also { it[0] = 0L }\r\n for (c1 in 1 .. h) {\r\n val time = t1 * c1\r\n val c2 = time / t2\r\n val damage = p1 * c1 + p2 * c2 - s * if (c2 > 0) (c1 + c2 - 1) else (c1 + c2)\r\n for (i in minTime.indices) {\r\n val j = minOf(h.toLong(), i + damage).toInt()\r\n minTime[j] = minOf(minTime[j], minTime[i] + time)\r\n }\r\n }\r\n for (c2 in 1 .. h) {\r\n val time = t2 * c2\r\n val c1 = time / t1\r\n val damage = p1 * c1 + p2 * c2 - s * if (c1 > 0) (c1 + c2 - 1) else (c1 + c2)\r\n for (i in minTime.indices) {\r\n val j = minOf(h.toLong(), i + damage).toInt()\r\n minTime[j] = minOf(minTime[j], minTime[i] + time)\r\n }\r\n }\r\n val result = minTime[h]\r\n println(result)\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "db43cc18dbdbe3a997daef211e98b160", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n if((n % 2).toLong() == 0.toLong())\n print(2)\n else\n print(1)\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ad7c6ef7fe175183a7a1b2ecfa16e670", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val Xp = ni()\n val Yp = ni()\n val Xv = ni()\n val Yv = ni()\n\n var win = false\n val diagonal = min(Xv, Yv)\n for (i in 1 .. diagonal) {\n val x = Xv - i\n val y = Yv - i\n if (Xp >= x && Yp >= y) {\n val tp = Xp - x + Yp - y\n val tv = i\n win = win || tp <= tv\n }\n }\n\n for (i in 1 .. max(Xv, Yv) - diagonal) {\n val x = max(0, Xv - diagonal - i)\n val y = max(0, Yv - diagonal - i)\n if (Xp >= x && Yp >= y) {\n val tp = Xp - x + Yp - y\n val tv = i + diagonal\n win = win || tp <= tv\n }\n }\n\n if (win) out.println(\"Polycarp\")\n else out.println(\"Vasiliy\")\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n, offset) { ni() }\n }\n\n private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i + offset)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun pair(a: A, b: B) = RPair(a, b)\ndata class RPair(val _1: A, val _2: B)\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "295d99d8d1671b14220582d99da721d1", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun getN(input: Int): Int {\n val p: Double = (Math.sqrt(8.0 * input + 1) - 1.0) / 2.0\n return p.toInt() + 1\n}\n\nfun main(args: Array) {\n var k = readLine()?.toInt()!!\n var o = 'a'\n if (k == 0)\n print('a')\n else\n while (k != 0) {\n val p = getN(k)\n k -= ((p * (p - 1)) / 2)\n for (i in 1..p)\n print(o)\n o++\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5b11d11250fb197bee40d0d0fb834ed3", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n\n val queue = ArrayDeque()\n val n = readInt()\n repeat(n) {\n var current = 1\n while (queue.isNotEmpty() && queue.peekLast() == current) {\n queue.removeLast()\n current++\n }\n queue.add(current)\n }\n print(queue.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d29d6408c8572ef78fd2c3520affbf23", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.max\n\nfun main() {\n val jin = Scanner(System.`in`)\n val n = jin.nextInt()\n val q = jin.nextInt()\n val w = jin.nextLong()\n val nodes = Array(n + 1, ::Node)\n nodes[1].parent = nodes[0]\n nodes[1].edges.add(Edge(nodes[0], 0, 0))\n for (i in 0 until n - 1) {\n val a = jin.nextInt()\n val b = jin.nextInt()\n val length = jin.nextLong()\n nodes[a].edges.add(Edge(nodes[b], length, i))\n nodes[b].edges.add(Edge(nodes[a], length, i))\n }\n val dfs = Array(n) { nodes[1] }\n val qodes = Array(n - 1) { nodes[0] }\n var j = 1\n for (i in 0 until n) {\n for (k in 0 until dfs[i].edges.size - 1) {\n var edge = dfs[i].edges[k]\n if (edge.node == dfs[i].parent) {\n edge = dfs[i].edges.last()\n dfs[i].edges[k] = edge\n }\n qodes[edge.ix] = edge.node\n edge.node.parent = dfs[i]\n edge.node.parentLength = edge.length\n dfs[j] = edge.node\n j++\n }\n dfs[i].edges.removeAt(dfs[i].edges.size - 1)\n }\n for (node in dfs.reversed()) {\n node.parent.subTreeSize += node.subTreeSize\n var bestIx = -1\n for (k in 0 until node.edges.size) {\n node.edges[k].node.treeix = k\n if (node.bestChild == null || node.bestChild!!.subTreeSize < node.edges[k].node.subTreeSize) {\n node.bestChild = node.edges[k].node\n bestIx = k\n }\n }\n //println(\"$node.bestChild = ${node.bestChild}\")\n if (node.bestChild != null) {\n node.edges.last().node.treeix = bestIx\n node.edges[bestIx] = node.edges.last()\n node.edges.removeAt(node.edges.size - 1)\n }\n node.hortree = Hortree(node.edges.size)\n }\n for (node in dfs) {\n if (node.parent.bestChild == node) {\n continue\n }\n var amt = 0\n var subNode: Node? = node.bestChild\n while (subNode != null) {\n subNode.treeix = amt\n subNode = subNode.bestChild\n amt++\n }\n node.vertree = Vertree(node, amt)\n subNode = node.bestChild\n while (subNode != null) {\n subNode.vertree = node.vertree\n subNode = subNode.bestChild\n }\n }\n for (node in dfs.reversed()) {\n if (node != nodes[1]) {\n node.update()\n }\n }\n var last: Long = 0\n for (i in 1..q) {\n val d = (jin.nextLong() + last) % (n - 1)\n var e = (jin.nextLong() + last) % w\n var node = qodes[d.toInt()]\n //println(\"node = $node, e = $e\")\n node.parentLength = e\n while (node != nodes[1]) {\n node.update()\n if (node == node.parent.bestChild) {\n node = node.vertree.topNode\n } else {\n node = node.parent\n }\n }\n last = maxOf(nodes[1].hortree.posAnswer(), nodes[1].vertree.posAnswer(), nodes[1].hortree.longest() + nodes[1].vertree.longest())\n println(last)\n }\n}\n\nclass Node(val ix: Int) {\n lateinit var parent: Node\n var parentLength: Long = -1\n var subTreeSize = 1\n val edges = mutableListOf()\n var bestChild: Node? = null\n lateinit var hortree: Hortree\n lateinit var vertree: Vertree\n var treeix = -1\n\n fun update() {\n //println(\"$this.update()\")\n if (parent.bestChild == this) {\n vertree.update(\n treeix,\n Verval(\n parentLength,\n hortree.longest() + parentLength,\n hortree.longest(),\n hortree.posAnswer()\n )\n )\n } else {\n parent.hortree.update(\n treeix,\n Horval(\n max(vertree.longest(),\n hortree.longest()) + parentLength,\n 0,\n maxOf(vertree.posAnswer(), hortree.posAnswer(), vertree.longest() + hortree.longest())\n )\n )\n }\n }\n\n override fun toString() = \"nodes[$ix]\"\n}\n\nclass Edge(val node: Node, val length: Long, val ix: Int)\n\nval HORIZONTAL_IDENTITY = Horval(0, 0, 0)\nval VERTICAL_IDENTITY = Verval(0, 0, 0, 0)\n\ndata class Horval(val longest1: Long, val longest2: Long, val posAnswer: Long) {\n operator fun plus(other: Horval): Horval {\n if (longest1 > other.longest1) {\n return Horval(longest1, max(longest2, other.longest1), max(posAnswer, other.posAnswer))\n } else {\n return Horval(other.longest1, max(longest1, other.longest2), max(posAnswer, other.posAnswer))\n }\n }\n}\n\ndata class Verval(val length: Long, val longest: Long, val longestToUse: Long, val posAnswer: Long) {\n // this is above, other is below\n operator fun times(other: Verval) = Verval(\n length + other.length,\n max(longest, other.longest + length),\n max(longestToUse + other.length, other.longestToUse),\n maxOf(posAnswer, other.posAnswer, longestToUse + other.longest)\n )\n}\n\nclass Hortree(amt: Int) {\n val length: Int\n val array: Array\n\n init {\n var l = 1\n while (l < amt) {\n l *= 2\n }\n length = l\n array = Array(length * 2) { HORIZONTAL_IDENTITY }\n }\n\n fun update(index: Int, newVal: Horval) {\n var node = index + length\n array[node] = newVal\n node = node shr 1\n while (node > 0) {\n array[node] = array[2 * node] + array[(2 * node) + 1]\n node = node shr 1\n }\n }\n\n fun longest() = array[1].longest1\n fun posAnswer() = max(array[1].longest1 + array[1].longest2, array[1].posAnswer)\n}\n\nclass Vertree(val topNode: Node, amt: Int) {\n val length: Int\n val array: Array\n\n init {\n var l = 1\n while (l < amt) {\n l *= 2\n }\n length = l\n array = Array(length * 2) { VERTICAL_IDENTITY }\n }\n\n fun update(index: Int, newVal: Verval) {\n //println(\"update($index, $newVal)\")\n var node = index + length\n array[node] = newVal\n //println(\"array[$node] = ${array[node]}\")\n node = node shr 1\n while (node > 0) {\n array[node] = array[2 * node] * array[(2 * node) + 1]\n //println(\"array[$node] = ${array[node]}\")\n node = node shr 1\n }\n }\n\n fun longest() = array[1].longest\n fun posAnswer() = max(array[1].longestToUse, array[1].posAnswer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "69363d882ce53e312630610403c39944", "src_uid": "2c7349bc99e56b86a5c11b8c683b2b6c", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n readLine()\n val minutes = mutableListOf(0)\n minutes.addAll(readInts())\n minutes.add(90)\n for (pos in 0 until minutes.size - 1)\n if(minutes[pos] + 15 < minutes[pos + 1]) return print(minutes[pos] + 15)\n print(90)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d63c3de3da22e61b77fc5274a66e0a3e", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0} {"lang": "Kotlin 1.4", "source_code": "\nimport java.io.BufferedInputStream\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.math.ln\nimport kotlin.system.measureTimeMillis\n\ninline fun TIME(f:()->Unit){\n val t = measureTimeMillis(){\n f()\n }\n println(\"$t ms\")\n}\n\nobject IO{\n private const val BS = 1 shl 16\n private const val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n\n var warningActive = true\n var fakein = StringBuilder()\n\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\n val OUT: PrintWriter = PrintWriter(System.out)\n\n private val char: Char\n get() {\n while (bId == size) {\n size = IN.read(buf) // no need for checked exceptions\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextLong(): Long {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0L\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextString():String{\n val ret = StringBuilder()\n while (true){\n c = char\n if(!isWhitespace(c)){ break}\n }\n ret.append(c)\n while (true){\n c = char\n if(isWhitespace(c)){ break}\n ret.append(c)\n }\n return ret.toString()\n }\n fun isWhitespace(c:Char):Boolean{\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\n }\n fun rerouteInput(){\n if(warningActive){\n put(\"You forgot to disable tests you digital dummy!\")\n println(\"You forgot to disable tests you digital dummy!\")\n warningActive = false\n }\n val S = fakein.toString()\n println(\"New Case \")\n println(S.take(80))\n println(\"...\")\n fakein.clear()\n IN = BufferedInputStream(S.byteInputStream(),BS)\n }\n fun takeFile(name:String){\n IN = BufferedInputStream(File(name).inputStream(),BS)\n }\n}\nfun put(aa:Any){ IO.OUT.println(aa)}\nfun done(){ IO.OUT.close() }\nfun share(aa:Any){\n if(aa is IntArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is LongArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is List<*>){IO.fakein.append(aa.toString())}\n else{IO.fakein.append(aa.toString())}\n IO.fakein.append(\"\\n\")\n}\n\nval getint:Int get() = IO.nextInt()\nval getlong:Long get() = IO.nextLong()\nval getstr:String get() = IO.nextString()\nfun getline(n:Int):IntArray{\n return IntArray(n){getint}\n}\nfun getlineL(n:Int):LongArray{\n return LongArray(n){getlong}\n}\nfun getbinary(n:Int):BooleanArray{\n val str = getstr\n return BooleanArray(n){str[it] == '1'}\n}\n\nval List.ret:String\nget() = this.joinToString(\"\")\ninfix fun Any.dei(a:Any){\n //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators\n var str = \"\"\n if(this is String){ str = this\n }else if(this is Int){ str = this.toString()\n }else if(this is Long){ str = this.toString()\n }\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else{ println(\"$str : $a\")\n }\n}\nval just = \" \" // usage: just dei x , where x is the debug variable\nfun crash(){throw Exception(\"Bad programme\")} // because assertion does not work\nfun assert(a:Boolean){\n if(!a){throw Exception(\"Failed Assertion\")\n }}\nenum class solveMode {\n real, rand, tc\n}\nconst val withBruteForce = false\nconst val randCount = 100\nobject solve{\n var mode:solveMode = solveMode.real\n var tcNum:Int = 0\n var rand:()->Unit = {}\n var TC:MutableMapUnit> = mutableMapOf()\n var answersChecked = 0\n var tn:Long = 0\n fun cases(onecase:()->Unit){\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\n //safety checks\n if(pI != 998_244_353 && pI != 1_000_000_007){\n throw Exception(\"Modding a wrong prime!\")\n }\n\n if(t == 1 && mode != solveMode.real){\n tn = System.currentTimeMillis()\n }\n repeat(t){\n if(mode == solveMode.tc){\n TC[tcNum]?.let { it() }\n IO.rerouteInput()\n }else if(mode == solveMode.rand){\n rand()\n IO.rerouteInput()\n }\n currentAnswer = null\n currentBruteAnswer = null\n onecase()\n }\n if(withBruteForce){\n put(\"Checked ${answersChecked}\")\n }\n if(t == 1 && mode != solveMode.real){\n val dt = System.currentTimeMillis() - tn\n println(\"Time $dt ms \")\n }\n }\n inline fun singleCase(a:solve.()->Unit){\n val t = if(mode != solveMode.rand){1} else randCount\n repeat(t) { a() }\n }\n fun rand(a:()->Unit){\n this.rand = a\n }\n fun tc(id:Int = 0,a:()->Unit){\n TC[id] = a\n }\n inline fun brute(a:()->Unit){\n if(withBruteForce){\n a()\n }\n }\n fun usetc(a:Int = 0 ){\n this.tcNum = a\n this.mode = solveMode.tc\n }\n fun userand(){\n this.mode = solveMode.rand\n }\n\n\n var currentAnswer:String? = null\n var currentBruteAnswer:String? = null\n fun answer(a:Any){\n currentAnswer = a.toString()\n if(currentBruteAnswer != null){\n checkAnswer()\n }\n }\n fun put2(a:Any){answer(a);put(a) }\n\n fun bruteAnswer(a:Any){\n currentBruteAnswer = a.toString()\n if(currentAnswer != null){\n checkAnswer()\n }\n }\n fun checkAnswer(){\n if(currentAnswer != currentBruteAnswer){\n throw Exception(\"Failed Test: BF $currentBruteAnswer Current $currentAnswer\")\n }\n answersChecked ++\n }\n}\n// 1. Modded\nconst val p = 998244353L\nconst val pI = p.toInt()\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\ninfix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\n// 2. DP initial values\nconst val plarge = 1_000_000_727\nconst val nlarge = -plarge\nconst val phuge = 2_727_000_000_000_000_000L\nconst val nhuge = -phuge\n// 3. conveniecen conversions\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\n//3. hard to write stuff\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\nval mint:MutableList get() = mutableListOf()\nval mong:MutableList get() = mutableListOf()\n\n\ninfix fun Int.divCeil(b:Int):Int{\n //Positives numbers only!\n if(this == 0) {\n return 0\n }\n return (this-1)/b + 1\n}\ninfix fun Long.divCeil(b:Long):Long{\n //Positives numbers only!\n if(this == 0L) {\n return 0\n }\n return (this-1)/b + 1\n}\n\ninfix fun Long.modM(b:Long):Long{\n return (this * b) % p\n}\n//infix fun Int.modPlus(b:Int):Int{\n// val ans = this + b\n// return if(ans >= pI) ans - pI else ans\n//}\ninfix fun Int.modMinus(b:Int):Int{\n val ans = this - b\n return if(ans < 0) ans + pI else ans\n}\ninfix fun Int.modDivide(b:Int):Int{\n return this modM (b.inverse())\n}\nfun Int.additiveInverse():Int{\n return if(this == 0) 0 else pI - this\n}\n\n\nfun intPow(x:Int,e:Int,m:Int):Int{\n var X = x\n var E =e\n var Y = 1\n while(E > 0){\n if(E % 2 == 0){\n X = ((1L * X * X) % m).toInt()\n E /= 2\n }else{\n Y = ((1L * X * Y) % m).toInt()\n E -= 1\n }\n }\n return Y\n}\n\nfun pow(x:Long,e:Long,m:Long):Long{\n var X = x\n var E =e\n var Y = 1L\n while(E > 0){\n if(E % 2 == 0L){\n X = (X * X) % m\n E /= 2\n }else{\n Y = (X * Y) % m\n E -= 1\n }\n }\n return Y\n}\nfun Long.inverse():Long{\n return pow(this,p-2,p)\n}\nfun Int.inverse():Int{\n return intPow(this,pI-2,pI)\n}\n//make this int instead\nclass FACT{\n companion object {\n var store = IntArray(0)\n var invStore = IntArray(0)\n\n var slowStore:IntArray = IntArray(0)\n\n fun preCal(upto:Int){\n store = IntArray(upto+1)\n invStore = IntArray(upto + 1 )\n store[0] = 1\n invStore[0] = 1\n\n for(i in 1..upto) {\n store[i] = store[i-1] modM i\n invStore[i] = invStore[i-1] modM (i.inverse())\n }\n }\n fun choose(n:Int,r:Int):Int{\n if(r < 0 || r > n) return 0\n val a = store[n]\n val b = invStore[n-r]\n val c = invStore[r]\n return (a modM b) modM c\n }\n\n fun bigChoose(n:Int,r:Int):Int{\n var ret = 1\n for(i in 0 until r){\n ret = ret modM (n - i)\n }\n ret = ret modM (invStore[r])\n return ret\n }\n\n }\n}\n\nclass FFT {\n companion object{\n // val fftmod = 7340033\n// val root = 5\n// val root_1 = 4404020\n// val root_pw = 1 shl 20\n private const val fftmod = 998244353\n private const val root = 15311432\n private const val root_1 = 469870224\n private const val root_pw = 1 shl 23\n\n fun calculateRoot(){\n println(\"root :$root\")\n // intPow(3,7 * 17,fftmod)\n println(\"root_1 : $root_1\")\n // intPow(root,fftmod -2,fftmod)\n }\n\n fun fft(a:IntArray,invert:Boolean){\n val n = a.size\n var j = 0\n\n\n for(i in 1 until n){\n var bit = n shr 1\n while(j and bit > 0){\n j = j xor bit\n bit = bit shr 1\n }\n j = j xor bit\n if(i < j){\n val temp = a[i]\n a[i] = a[j]\n a[j] = temp\n }\n }\n var len = 2\n while(len <= n){\n var wlen = if(invert) root_1 else root\n var i = len\n while(i < root_pw){\n wlen = (1L * wlen * wlen % fftmod).toInt()\n i = i shl 1\n }\n i = 0\n while(i < n){\n var w = 1\n for(j in 0 until len/2){\n val u = a[i+j]\n val v = (1L * a[i+j+len/2] * w % fftmod).toInt()\n a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod\n a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod\n w = (1L * w * wlen % fftmod).toInt()\n }\n i += len\n }\n len = len shl 1\n }\n if(invert){\n val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())\n for((i,x) in a.withIndex()){\n a[i] = (1L * x * n_1 % fftmod).toInt()\n }\n }\n }\n fun fullconvolution(at:IntArray,bt:IntArray):IntArray{\n return fullconvolutionOpt(at,bt,at.size,bt.size)\n }\n\n fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{\n // 1 shl 18 done in 77 ms\n val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2\n val a = at.copyOf(maxSize)\n val b = bt.copyOf(maxSize)\n val expectedSize = at.size + bt.size - 1\n fft(a,false)\n fft(b,false)\n val new = IntArray(maxSize)\n for(i in new.indices){\n new[i] = (1L * a[i] * b[i] % fftmod).toInt()\n }\n fft(new,true)\n return new.copyOf(expectedSize)\n }\n }\n}\n\nfun stir(l:Int, r:Int):IntArray{\n if(l == r){\n return intArrayOf(l,1)\n }else{\n val mid = (l+r) shr 1\n return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))\n }\n}\n\n\n\nobject sieve{\n\n const val sieveMx = 200005\n val primeOf = IntArray(sieveMx + 1)\n var primeCounter = 0\n val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)\n val primes = IntArray(primeUpperBound)\n var sieveCalculated = false\n val nextPrime = IntArray(sieveMx+1)\n val nextPrimePower = IntArray(sieveMx+1)\n val afterPrimePowerDivison = IntArray(sieveMx+1)\n var mobius = IntArray(0)\n\n var factors:List> = mutableListOf()\n\n fun calculateSieveFast(){\n if(sieveCalculated){\n return\n }\n sieveCalculated = true\n for(i in 2..sieveMx){\n if(primeOf[i] == 0 ){\n primeOf[i] = i\n primes[primeCounter] = i\n primeCounter += 1\n }\n for(j in 0 until primeCounter){\n val p = primes[j]\n val pd = p * i\n if(p <= i && pd <= sieveMx){\n primeOf[pd] = p\n }else{\n break\n }\n }\n }\n }\n fun preparePrimePower(){\n nextPrime[1] = -1\n nextPrimePower[1] = -1\n afterPrimePowerDivison[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n val new = i / p\n nextPrime[i] = p\n if(nextPrime[new] == p){\n nextPrimePower[i] = nextPrimePower[new]\n afterPrimePowerDivison[i] = afterPrimePowerDivison[new]\n }else{\n afterPrimePowerDivison[i] = new\n }\n nextPrimePower[i] += 1\n }\n }\n fun prepareFactors(){\n // 700ms in 1M\n // shoudl not be used for 1M\n // 200ms codeforces for 200k\n factors = List(sieveMx + 1){ mutableListOf()}\n factors[1].add(1)\n\n for(i in 2..sieveMx){\n val p = nextPrime[i]\n val a = nextPrimePower[i]\n val old = afterPrimePowerDivison[i]\n\n var here = 1\n repeat(a+1){\n for(c in factors[old]){\n factors[i].add(c * here )\n }\n here *= p\n }\n// factors[1].ad\n// factors[i].addAll(i.factors())\n }\n }\n fun calculateMobius(){\n kotlin.assert(sieveCalculated)\n mobius = IntArray(sieveMx + 1)\n mobius[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n if(p == primeOf[i/p]){\n mobius[i] = 0\n }else{\n mobius[i] = -1 * mobius[i/p]\n }\n }\n }\n}\ninline fun Int.eachPrimePower(act:(Int,Int)->Unit){\n var here = this\n while(here > 1){\n act(sieve.nextPrime[here], sieve.nextPrimePower[here])\n here = sieve.afterPrimePowerDivison[here]\n }\n}\nfun GS(start:Int,ratio:Int,count:Int) = sequence {\n var ret = 1\n for(i in 1\n ..count){\n ret *= ratio\n yield(ret)\n }\n}\nfun Int.factors():List{\n val ret = mutableListOf(1)\n this.eachPrimePower { p, e ->\n val s = ret.toList()\n for(pn in GS(p,p,e)){\n ret.addAll(s.map{it * pn})\n }\n }\n return ret\n}\nfun totient(a:Int):Int{\n var ret = a\n a.eachPrimePower{\n p, _ ->\n ret /= p\n ret *= (p-1)\n }\n return ret\n}\nfun Int.numOfDivisors():Int{\n var ret = 1\n this.eachPrimePower { _, e -> ret *= (e+1) }\n return ret\n}\nfun Int.factorLook():List{\n return sieve.factors[this]\n}\n\n\nfun stirtry2(n:Int):IntArray {\n val A = IntArray(n+1){\n val x = FACT.invStore[it]\n if(it %2 == 0) x else x.additiveInverse()\n }\n val B = IntArray(n+1){\n intPow(it, n,pI) modM FACT.invStore[it]\n }\n val F = FFT.fullconvolution(A,B)\n\n return F\n}\nval recitations = mutableMapOf()\nfun getitdone(n:Int, k:Int):Int{\n if(recitations[n] != null){\n return recitations[n]!!\n }\n val that = stirtry2(n)\n var ret = 0\n for(i in 1..minOf(n,k)){\n ret = ret modPlus that[i]\n }\n// \"$n $k \" dei thatv\\\\\n\n val final = ret modMinus 1\n recitations[n] = final\n return final\n}\n\n\n\nvar n =0\nconst val singleCase = true\nfun main(){\n FACT.preCal(200005)\n sieve.calculateSieveFast()\n sieve.calculateMobius()\n\n// just dei stirtry2(6)\n solve.cases{\n n = getint\n val k = getint\n var ans = 0\n\n if(k == 1 || n ==1){\n put(1)\n return@cases\n\n }\n\n for(i in 1..n){\n val m = sieve.mobius[i].adjust()\n if(m == 0) continue\n\n val now = getitdone(n divCeil i,k)\n// i dei now\n ans = ans modPlus ( now modM m)\n }\n put(ans)\n }\n done()\n}\n/*\njust number of such patterns\n\n\n\nn\nn/2\nn/3\n\n */\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6b1de1124ce47c18cfabf3beb2b12885", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "Kotlin 1.4", "source_code": "\nimport java.io.BufferedInputStream\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.math.ln\nimport kotlin.system.measureTimeMillis\n\ninline fun TIME(f:()->Unit){\n val t = measureTimeMillis(){\n f()\n }\n println(\"$t ms\")\n}\n\nobject IO{\n private const val BS = 1 shl 16\n private const val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n\n var warningActive = true\n var fakein = StringBuilder()\n\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\n val OUT: PrintWriter = PrintWriter(System.out)\n\n private val char: Char\n get() {\n while (bId == size) {\n size = IN.read(buf) // no need for checked exceptions\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextLong(): Long {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0L\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextString():String{\n val ret = StringBuilder()\n while (true){\n c = char\n if(!isWhitespace(c)){ break}\n }\n ret.append(c)\n while (true){\n c = char\n if(isWhitespace(c)){ break}\n ret.append(c)\n }\n return ret.toString()\n }\n fun isWhitespace(c:Char):Boolean{\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\n }\n fun rerouteInput(){\n if(warningActive){\n put(\"You forgot to disable tests you digital dummy!\")\n println(\"You forgot to disable tests you digital dummy!\")\n warningActive = false\n }\n val S = fakein.toString()\n println(\"New Case \")\n println(S.take(80))\n println(\"...\")\n fakein.clear()\n IN = BufferedInputStream(S.byteInputStream(),BS)\n }\n fun takeFile(name:String){\n IN = BufferedInputStream(File(name).inputStream(),BS)\n }\n}\nfun put(aa:Any){ IO.OUT.println(aa)}\nfun done(){ IO.OUT.close() }\nfun share(aa:Any){\n if(aa is IntArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is LongArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is List<*>){IO.fakein.append(aa.toString())}\n else{IO.fakein.append(aa.toString())}\n IO.fakein.append(\"\\n\")\n}\n\nval getint:Int get() = IO.nextInt()\nval getlong:Long get() = IO.nextLong()\nval getstr:String get() = IO.nextString()\nfun getline(n:Int):IntArray{\n return IntArray(n){getint}\n}\nfun getlineL(n:Int):LongArray{\n return LongArray(n){getlong}\n}\nfun getbinary(n:Int):BooleanArray{\n val str = getstr\n return BooleanArray(n){str[it] == '1'}\n}\n\nval List.ret:String\nget() = this.joinToString(\"\")\ninfix fun Any.dei(a:Any){\n //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators\n var str = \"\"\n if(this is String){ str = this\n }else if(this is Int){ str = this.toString()\n }else if(this is Long){ str = this.toString()\n }\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else{ println(\"$str : $a\")\n }\n}\nval just = \" \" // usage: just dei x , where x is the debug variable\nfun crash(){throw Exception(\"Bad programme\")} // because assertion does not work\nfun assert(a:Boolean){\n if(!a){throw Exception(\"Failed Assertion\")\n }}\nenum class solveMode {\n real, rand, tc\n}\nconst val withBruteForce = false\nconst val randCount = 100\nobject solve{\n var mode:solveMode = solveMode.real\n var tcNum:Int = 0\n var rand:()->Unit = {}\n var TC:MutableMapUnit> = mutableMapOf()\n var answersChecked = 0\n var tn:Long = 0\n fun cases(onecase:()->Unit){\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\n //safety checks\n if(pI != 998_244_353 && pI != 1_000_000_007){\n throw Exception(\"Modding a wrong prime!\")\n }\n\n if(t == 1 && mode != solveMode.real){\n tn = System.currentTimeMillis()\n }\n repeat(t){\n if(mode == solveMode.tc){\n TC[tcNum]?.let { it() }\n IO.rerouteInput()\n }else if(mode == solveMode.rand){\n rand()\n IO.rerouteInput()\n }\n currentAnswer = null\n currentBruteAnswer = null\n onecase()\n }\n if(withBruteForce){\n put(\"Checked ${answersChecked}\")\n }\n if(t == 1 && mode != solveMode.real){\n val dt = System.currentTimeMillis() - tn\n println(\"Time $dt ms \")\n }\n }\n inline fun singleCase(a:solve.()->Unit){\n val t = if(mode != solveMode.rand){1} else randCount\n repeat(t) { a() }\n }\n fun rand(a:()->Unit){\n this.rand = a\n }\n fun tc(id:Int = 0,a:()->Unit){\n TC[id] = a\n }\n inline fun brute(a:()->Unit){\n if(withBruteForce){\n a()\n }\n }\n fun usetc(a:Int = 0 ){\n this.tcNum = a\n this.mode = solveMode.tc\n }\n fun userand(){\n this.mode = solveMode.rand\n }\n\n\n var currentAnswer:String? = null\n var currentBruteAnswer:String? = null\n fun answer(a:Any){\n currentAnswer = a.toString()\n if(currentBruteAnswer != null){\n checkAnswer()\n }\n }\n fun put2(a:Any){answer(a);put(a) }\n\n fun bruteAnswer(a:Any){\n currentBruteAnswer = a.toString()\n if(currentAnswer != null){\n checkAnswer()\n }\n }\n fun checkAnswer(){\n if(currentAnswer != currentBruteAnswer){\n throw Exception(\"Failed Test: BF $currentBruteAnswer Current $currentAnswer\")\n }\n answersChecked ++\n }\n}\n// 1. Modded\nconst val p = 998244353L\nconst val pI = p.toInt()\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\ninfix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\n// 2. DP initial values\nconst val plarge = 1_000_000_727\nconst val nlarge = -plarge\nconst val phuge = 2_727_000_000_000_000_000L\nconst val nhuge = -phuge\n// 3. conveniecen conversions\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\n//3. hard to write stuff\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\nval mint:MutableList get() = mutableListOf()\nval mong:MutableList get() = mutableListOf()\n\n\ninfix fun Int.divCeil(b:Int):Int{\n //Positives numbers only!\n if(this == 0) {\n return 0\n }\n return (this-1)/b + 1\n}\ninfix fun Long.divCeil(b:Long):Long{\n //Positives numbers only!\n if(this == 0L) {\n return 0\n }\n return (this-1)/b + 1\n}\n\ninfix fun Long.modM(b:Long):Long{\n return (this * b) % p\n}\n//infix fun Int.modPlus(b:Int):Int{\n// val ans = this + b\n// return if(ans >= pI) ans - pI else ans\n//}\ninfix fun Int.modMinus(b:Int):Int{\n val ans = this - b\n return if(ans < 0) ans + pI else ans\n}\ninfix fun Int.modDivide(b:Int):Int{\n return this modM (b.inverse())\n}\nfun Int.additiveInverse():Int{\n return if(this == 0) 0 else pI - this\n}\n\n\nfun intPow(x:Int,e:Int,m:Int):Int{\n var X = x\n var E =e\n var Y = 1\n while(E > 0){\n if(E % 2 == 0){\n X = ((1L * X * X) % m).toInt()\n E /= 2\n }else{\n Y = ((1L * X * Y) % m).toInt()\n E -= 1\n }\n }\n return Y\n}\n\nfun pow(x:Long,e:Long,m:Long):Long{\n var X = x\n var E =e\n var Y = 1L\n while(E > 0){\n if(E % 2 == 0L){\n X = (X * X) % m\n E /= 2\n }else{\n Y = (X * Y) % m\n E -= 1\n }\n }\n return Y\n}\nfun Long.inverse():Long{\n return pow(this,p-2,p)\n}\nfun Int.inverse():Int{\n return intPow(this,pI-2,pI)\n}\n//make this int instead\nclass FACT{\n companion object {\n var store = IntArray(0)\n var invStore = IntArray(0)\n\n var slowStore:IntArray = IntArray(0)\n\n fun preCal(upto:Int){\n store = IntArray(upto+1)\n invStore = IntArray(upto + 1 )\n store[0] = 1\n invStore[0] = 1\n\n for(i in 1..upto) {\n store[i] = store[i-1] modM i\n invStore[i] = invStore[i-1] modM (i.inverse())\n }\n }\n fun choose(n:Int,r:Int):Int{\n if(r < 0 || r > n) return 0\n val a = store[n]\n val b = invStore[n-r]\n val c = invStore[r]\n return (a modM b) modM c\n }\n\n fun bigChoose(n:Int,r:Int):Int{\n var ret = 1\n for(i in 0 until r){\n ret = ret modM (n - i)\n }\n ret = ret modM (invStore[r])\n return ret\n }\n\n }\n}\n\nclass FFT {\n companion object{\n // val fftmod = 7340033\n// val root = 5\n// val root_1 = 4404020\n// val root_pw = 1 shl 20\n private const val fftmod = 998244353\n private const val root = 15311432\n private const val root_1 = 469870224\n private const val root_pw = 1 shl 23\n\n fun calculateRoot(){\n println(\"root :$root\")\n // intPow(3,7 * 17,fftmod)\n println(\"root_1 : $root_1\")\n // intPow(root,fftmod -2,fftmod)\n }\n\n fun fft(a:IntArray,invert:Boolean){\n val n = a.size\n var j = 0\n\n\n for(i in 1 until n){\n var bit = n shr 1\n while(j and bit > 0){\n j = j xor bit\n bit = bit shr 1\n }\n j = j xor bit\n if(i < j){\n val temp = a[i]\n a[i] = a[j]\n a[j] = temp\n }\n }\n var len = 2\n while(len <= n){\n var wlen = if(invert) root_1 else root\n var i = len\n while(i < root_pw){\n wlen = (1L * wlen * wlen % fftmod).toInt()\n i = i shl 1\n }\n i = 0\n while(i < n){\n var w = 1\n for(j in 0 until len/2){\n val u = a[i+j]\n val v = (1L * a[i+j+len/2] * w % fftmod).toInt()\n a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod\n a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod\n w = (1L * w * wlen % fftmod).toInt()\n }\n i += len\n }\n len = len shl 1\n }\n if(invert){\n val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())\n for((i,x) in a.withIndex()){\n a[i] = (1L * x * n_1 % fftmod).toInt()\n }\n }\n }\n fun fullconvolution(at:IntArray,bt:IntArray):IntArray{\n return fullconvolutionOpt(at,bt,at.size,bt.size)\n }\n\n fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{\n // 1 shl 18 done in 77 ms\n val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2\n val a = at.copyOf(maxSize)\n val b = bt.copyOf(maxSize)\n val expectedSize = at.size + bt.size - 1\n fft(a,false)\n fft(b,false)\n val new = IntArray(maxSize)\n for(i in new.indices){\n new[i] = (1L * a[i] * b[i] % fftmod).toInt()\n }\n fft(new,true)\n return new.copyOf(expectedSize)\n }\n }\n}\n\nfun stir(l:Int, r:Int):IntArray{\n if(l == r){\n return intArrayOf(l,1)\n }else{\n val mid = (l+r) shr 1\n return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))\n }\n}\n\n\n\nobject sieve{\n\n const val sieveMx = 200005\n val primeOf = IntArray(sieveMx + 1)\n var primeCounter = 0\n val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)\n val primes = IntArray(primeUpperBound)\n var sieveCalculated = false\n val nextPrime = IntArray(sieveMx+1)\n val nextPrimePower = IntArray(sieveMx+1)\n val afterPrimePowerDivison = IntArray(sieveMx+1)\n var mobius = IntArray(0)\n\n var factors:List> = mutableListOf()\n\n fun calculateSieveFast(){\n if(sieveCalculated){\n return\n }\n sieveCalculated = true\n for(i in 2..sieveMx){\n if(primeOf[i] == 0 ){\n primeOf[i] = i\n primes[primeCounter] = i\n primeCounter += 1\n }\n for(j in 0 until primeCounter){\n val p = primes[j]\n val pd = p * i\n if(p <= i && pd <= sieveMx){\n primeOf[pd] = p\n }else{\n break\n }\n }\n }\n }\n fun preparePrimePower(){\n nextPrime[1] = -1\n nextPrimePower[1] = -1\n afterPrimePowerDivison[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n val new = i / p\n nextPrime[i] = p\n if(nextPrime[new] == p){\n nextPrimePower[i] = nextPrimePower[new]\n afterPrimePowerDivison[i] = afterPrimePowerDivison[new]\n }else{\n afterPrimePowerDivison[i] = new\n }\n nextPrimePower[i] += 1\n }\n }\n fun prepareFactors(){\n // 700ms in 1M\n // shoudl not be used for 1M\n // 200ms codeforces for 200k\n factors = List(sieveMx + 1){ mutableListOf()}\n factors[1].add(1)\n\n for(i in 2..sieveMx){\n val p = nextPrime[i]\n val a = nextPrimePower[i]\n val old = afterPrimePowerDivison[i]\n\n var here = 1\n repeat(a+1){\n for(c in factors[old]){\n factors[i].add(c * here )\n }\n here *= p\n }\n// factors[1].ad\n// factors[i].addAll(i.factors())\n }\n }\n fun calculateMobius(){\n kotlin.assert(sieveCalculated)\n mobius = IntArray(sieveMx + 1)\n mobius[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n if(p == primeOf[i/p]){\n mobius[i] = 0\n }else{\n mobius[i] = -1 * mobius[i/p]\n }\n }\n }\n}\ninline fun Int.eachPrimePower(act:(Int,Int)->Unit){\n var here = this\n while(here > 1){\n act(sieve.nextPrime[here], sieve.nextPrimePower[here])\n here = sieve.afterPrimePowerDivison[here]\n }\n}\nfun GS(start:Int,ratio:Int,count:Int) = sequence {\n var ret = 1\n for(i in 1\n ..count){\n ret *= ratio\n yield(ret)\n }\n}\nfun Int.factors():List{\n val ret = mutableListOf(1)\n this.eachPrimePower { p, e ->\n val s = ret.toList()\n for(pn in GS(p,p,e)){\n ret.addAll(s.map{it * pn})\n }\n }\n return ret\n}\nfun totient(a:Int):Int{\n var ret = a\n a.eachPrimePower{\n p, _ ->\n ret /= p\n ret *= (p-1)\n }\n return ret\n}\nfun Int.numOfDivisors():Int{\n var ret = 1\n this.eachPrimePower { _, e -> ret *= (e+1) }\n return ret\n}\nfun Int.factorLook():List{\n return sieve.factors[this]\n}\n\n\nfun stirlingNumbers(n:Int):IntArray {\n val A = IntArray(n+1){\n val x = FACT.invStore[it]\n if(it %2 == 0) x else x.additiveInverse()\n }\n val B = IntArray(n+1){\n intPow(it, n,pI) modM FACT.invStore[it]\n }\n val F = FFT.fullconvolution(A,B)\n\n return F\n}\nval recitations = mutableMapOf()\nfun getitdone(n:Int, k:Int):Int{\n if(recitations[n] != null){\n return recitations[n]!!\n }\n val that = stirlingNumbers(n)\n var ret = 0\n for(i in 1..minOf(n,k)){\n ret = ret modPlus that[i]\n }\n// \"$n $k \" dei thatv\\\\\n\n val final = ret modMinus 1\n recitations[n] = final\n return final\n}\n\n\n\nvar n =0\nconst val singleCase = true\nfun main(){\n FACT.preCal(200005)\n sieve.calculateSieveFast()\n sieve.calculateMobius()\n\n// just dei stirtry2(6)\n solve.cases{\n n = getint\n val k = getint\n var ans = 0\n\n if(k == 1 || n ==1){\n put(1)\n return@cases\n\n }\n\n for(i in 1..n){\n val m = sieve.mobius[i].adjust()\n if(m == 0) continue\n\n val now = getitdone(n divCeil i,k)\n// i dei now\n ans = ans modPlus ( now modM m)\n }\n put(ans)\n }\n done()\n}\n/*\njust number of such patterns\n\n\n\nn\nn/2\nn/3\n\n */\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ecd2cf8eee7d19327608b75adae81f0a", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "Kotlin 1.4", "source_code": "\nimport java.io.BufferedInputStream\nimport java.io.File\nimport java.io.PrintWriter\nimport kotlin.math.ln\nimport kotlin.system.measureTimeMillis\n\ninline fun TIME(f:()->Unit){\n val t = measureTimeMillis(){\n f()\n }\n println(\"$t ms\")\n}\n\nobject IO{\n private const val BS = 1 shl 16\n private const val NC = 0.toChar()\n private val buf = ByteArray(BS)\n private var bId = 0\n private var size = 0\n private var c = NC\n\n var warningActive = true\n var fakein = StringBuilder()\n\n private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)\n val OUT: PrintWriter = PrintWriter(System.out)\n\n private val char: Char\n get() {\n while (bId == size) {\n size = IN.read(buf) // no need for checked exceptions\n if (size == -1) return NC\n bId = 0\n }\n return buf[bId++].toChar()\n }\n\n fun nextInt(): Int {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextLong(): Long {\n var neg = false\n if (c == NC) c = char\n while (c < '0' || c > '9') {\n if (c == '-') neg = true\n c = char\n }\n var res = 0L\n while (c in '0'..'9') {\n res = (res shl 3) + (res shl 1) + (c - '0')\n c = char\n }\n return if (neg) -res else res\n }\n fun nextString():String{\n val ret = StringBuilder()\n while (true){\n c = char\n if(!isWhitespace(c)){ break}\n }\n ret.append(c)\n while (true){\n c = char\n if(isWhitespace(c)){ break}\n ret.append(c)\n }\n return ret.toString()\n }\n fun isWhitespace(c:Char):Boolean{\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'\n }\n fun rerouteInput(){\n if(warningActive){\n put(\"You forgot to disable tests you digital dummy!\")\n println(\"You forgot to disable tests you digital dummy!\")\n warningActive = false\n }\n val S = fakein.toString()\n println(\"New Case \")\n println(S.take(80))\n println(\"...\")\n fakein.clear()\n IN = BufferedInputStream(S.byteInputStream(),BS)\n }\n fun takeFile(name:String){\n IN = BufferedInputStream(File(name).inputStream(),BS)\n }\n}\nfun put(aa:Any){ IO.OUT.println(aa)}\nfun done(){ IO.OUT.close() }\nfun share(aa:Any){\n if(aa is IntArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is LongArray){IO.fakein.append(aa.joinToString(\" \"))}\n else if(aa is List<*>){IO.fakein.append(aa.toString())}\n else{IO.fakein.append(aa.toString())}\n IO.fakein.append(\"\\n\")\n}\n\nval getint:Int get() = IO.nextInt()\nval getlong:Long get() = IO.nextLong()\nval getstr:String get() = IO.nextString()\nfun getline(n:Int):IntArray{\n return IntArray(n){getint}\n}\nfun getlineL(n:Int):LongArray{\n return LongArray(n){getlong}\n}\nfun getbinary(n:Int):BooleanArray{\n val str = getstr\n return BooleanArray(n){str[it] == '1'}\n}\n\nval List.ret:String\nget() = this.joinToString(\"\")\ninfix fun Any.dei(a:Any){\n //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators\n var str = \"\"\n if(this is String){ str = this\n }else if(this is Int){ str = this.toString()\n }else if(this is Long){ str = this.toString()\n }\n if(a is List<*>){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is IntArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else if(a is LongArray){ println(\"$str : ${a.joinToString(\" \")}\")\n }else{ println(\"$str : $a\")\n }\n}\nval just = \" \" // usage: just dei x , where x is the debug variable\nfun crash(){throw Exception(\"Bad programme\")} // because assertion does not work\nfun assert(a:Boolean){\n if(!a){throw Exception(\"Failed Assertion\")\n }}\nenum class solveMode {\n real, rand, tc\n}\nconst val withBruteForce = false\nconst val randCount = 100\nobject solve{\n var mode:solveMode = solveMode.real\n var tcNum:Int = 0\n var rand:()->Unit = {}\n var TC:MutableMapUnit> = mutableMapOf()\n var answersChecked = 0\n var tn:Long = 0\n fun cases(onecase:()->Unit){\n val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount\n //safety checks\n if(pI != 998_244_353 && pI != 1_000_000_007){\n throw Exception(\"Modding a wrong prime!\")\n }\n\n if(t == 1 && mode != solveMode.real){\n tn = System.currentTimeMillis()\n }\n repeat(t){\n if(mode == solveMode.tc){\n TC[tcNum]?.let { it() }\n IO.rerouteInput()\n }else if(mode == solveMode.rand){\n rand()\n IO.rerouteInput()\n }\n currentAnswer = null\n currentBruteAnswer = null\n onecase()\n }\n if(withBruteForce){\n put(\"Checked ${answersChecked}\")\n }\n if(t == 1 && mode != solveMode.real){\n val dt = System.currentTimeMillis() - tn\n println(\"Time $dt ms \")\n }\n }\n inline fun singleCase(a:solve.()->Unit){\n val t = if(mode != solveMode.rand){1} else randCount\n repeat(t) { a() }\n }\n fun rand(a:()->Unit){\n this.rand = a\n }\n fun tc(id:Int = 0,a:()->Unit){\n TC[id] = a\n }\n inline fun brute(a:()->Unit){\n if(withBruteForce){\n a()\n }\n }\n fun usetc(a:Int = 0 ){\n this.tcNum = a\n this.mode = solveMode.tc\n }\n fun userand(){\n this.mode = solveMode.rand\n }\n\n\n var currentAnswer:String? = null\n var currentBruteAnswer:String? = null\n fun answer(a:Any){\n currentAnswer = a.toString()\n if(currentBruteAnswer != null){\n checkAnswer()\n }\n }\n fun put2(a:Any){answer(a);put(a) }\n\n fun bruteAnswer(a:Any){\n currentBruteAnswer = a.toString()\n if(currentAnswer != null){\n checkAnswer()\n }\n }\n fun checkAnswer(){\n if(currentAnswer != currentBruteAnswer){\n throw Exception(\"Failed Test: BF $currentBruteAnswer Current $currentAnswer\")\n }\n answersChecked ++\n }\n}\n// 1. Modded\nconst val p = 998244353L\nconst val pI = p.toInt()\nfun Int.adjust():Int{ if(this >= pI){ return this - pI }else if (this < 0){ return this + pI };return this }\nfun Int.snap():Int{ if(this >= pI){return this - pI} else return this}\ninfix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }\ninfix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\n// 2. DP initial values\nconst val plarge = 1_000_000_727\nconst val nlarge = -plarge\nconst val phuge = 2_727_000_000_000_000_000L\nconst val nhuge = -phuge\n// 3. conveniecen conversions\nval Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function\nval Char.code :Int get() = this.toInt() - 'a'.toInt()\n//3. hard to write stuff\nfun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }\nval mint:MutableList get() = mutableListOf()\nval mong:MutableList get() = mutableListOf()\n\n\ninfix fun Int.divCeil(b:Int):Int{\n //Positives numbers only!\n if(this == 0) {\n return 0\n }\n return (this-1)/b + 1\n}\ninfix fun Long.divCeil(b:Long):Long{\n //Positives numbers only!\n if(this == 0L) {\n return 0\n }\n return (this-1)/b + 1\n}\n\ninfix fun Long.modM(b:Long):Long{\n return (this * b) % p\n}\n//infix fun Int.modPlus(b:Int):Int{\n// val ans = this + b\n// return if(ans >= pI) ans - pI else ans\n//}\ninfix fun Int.modMinus(b:Int):Int{\n val ans = this - b\n return if(ans < 0) ans + pI else ans\n}\ninfix fun Int.modDivide(b:Int):Int{\n return this modM (b.inverse())\n}\nfun Int.additiveInverse():Int{\n return if(this == 0) 0 else pI - this\n}\n\n\nfun intPow(x:Int,e:Int,m:Int):Int{\n var X = x\n var E =e\n var Y = 1\n while(E > 0){\n if(E % 2 == 0){\n X = ((1L * X * X) % m).toInt()\n E /= 2\n }else{\n Y = ((1L * X * Y) % m).toInt()\n E -= 1\n }\n }\n return Y\n}\n\nfun pow(x:Long,e:Long,m:Long):Long{\n var X = x\n var E =e\n var Y = 1L\n while(E > 0){\n if(E % 2 == 0L){\n X = (X * X) % m\n E /= 2\n }else{\n Y = (X * Y) % m\n E -= 1\n }\n }\n return Y\n}\nfun Long.inverse():Long{\n return pow(this,p-2,p)\n}\nfun Int.inverse():Int{\n return intPow(this,pI-2,pI)\n}\n//make this int instead\nclass FACT{\n companion object {\n var store = IntArray(0)\n var invStore = IntArray(0)\n\n var slowStore:IntArray = IntArray(0)\n\n fun preCal(upto:Int){\n store = IntArray(upto+1)\n invStore = IntArray(upto + 1 )\n store[0] = 1\n invStore[0] = 1\n\n for(i in 1..upto) {\n store[i] = store[i-1] modM i\n invStore[i] = invStore[i-1] modM (i.inverse())\n }\n }\n fun choose(n:Int,r:Int):Int{\n if(r < 0 || r > n) return 0\n val a = store[n]\n val b = invStore[n-r]\n val c = invStore[r]\n return (a modM b) modM c\n }\n\n fun bigChoose(n:Int,r:Int):Int{\n var ret = 1\n for(i in 0 until r){\n ret = ret modM (n - i)\n }\n ret = ret modM (invStore[r])\n return ret\n }\n\n }\n}\n\nclass FFT {\n companion object{\n // val fftmod = 7340033\n// val root = 5\n// val root_1 = 4404020\n// val root_pw = 1 shl 20\n private const val fftmod = 998244353\n private const val root = 15311432\n private const val root_1 = 469870224\n private const val root_pw = 1 shl 23\n\n fun calculateRoot(){\n println(\"root :$root\")\n // intPow(3,7 * 17,fftmod)\n println(\"root_1 : $root_1\")\n // intPow(root,fftmod -2,fftmod)\n }\n\n fun fft(a:IntArray,invert:Boolean){\n val n = a.size\n var j = 0\n\n\n for(i in 1 until n){\n var bit = n shr 1\n while(j and bit > 0){\n j = j xor bit\n bit = bit shr 1\n }\n j = j xor bit\n if(i < j){\n val temp = a[i]\n a[i] = a[j]\n a[j] = temp\n }\n }\n var len = 2\n while(len <= n){\n var wlen = if(invert) root_1 else root\n var i = len\n while(i < root_pw){\n wlen = (1L * wlen * wlen % fftmod).toInt()\n i = i shl 1\n }\n i = 0\n while(i < n){\n var w = 1\n for(j in 0 until len/2){\n val u = a[i+j]\n val v = (1L * a[i+j+len/2] * w % fftmod).toInt()\n a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod\n a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod\n w = (1L * w * wlen % fftmod).toInt()\n }\n i += len\n }\n len = len shl 1\n }\n if(invert){\n val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())\n for((i,x) in a.withIndex()){\n a[i] = (1L * x * n_1 % fftmod).toInt()\n }\n }\n }\n fun fullconvolution(at:IntArray,bt:IntArray):IntArray{\n return fullconvolutionOpt(at,bt,at.size,bt.size)\n }\n\n fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{\n // 1 shl 18 done in 77 ms\n val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2\n val a = at.copyOf(maxSize)\n val b = bt.copyOf(maxSize)\n val expectedSize = at.size + bt.size - 1\n fft(a,false)\n fft(b,false)\n val new = IntArray(maxSize)\n for(i in new.indices){\n new[i] = (1L * a[i] * b[i] % fftmod).toInt()\n }\n fft(new,true)\n return new.copyOf(expectedSize)\n }\n }\n}\n\nfun stir(l:Int, r:Int):IntArray{\n if(l == r){\n return intArrayOf(l,1)\n }else{\n val mid = (l+r) shr 1\n return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))\n }\n}\n\n\n\nobject sieve{\n\n const val sieveMx = 200005\n val primeOf = IntArray(sieveMx + 1)\n var primeCounter = 0\n val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)\n val primes = IntArray(primeUpperBound)\n var sieveCalculated = false\n val nextPrime = IntArray(sieveMx+1)\n val nextPrimePower = IntArray(sieveMx+1)\n val afterPrimePowerDivison = IntArray(sieveMx+1)\n var mobius = IntArray(0)\n\n var factors:List> = mutableListOf()\n\n fun calculateSieveFast(){\n if(sieveCalculated){\n return\n }\n sieveCalculated = true\n for(i in 2..sieveMx){\n if(primeOf[i] == 0 ){\n primeOf[i] = i\n primes[primeCounter] = i\n primeCounter += 1\n }\n for(j in 0 until primeCounter){\n val p = primes[j]\n val pd = p * i\n if(p <= i && pd <= sieveMx){\n primeOf[pd] = p\n }else{\n break\n }\n }\n }\n }\n fun preparePrimePower(){\n nextPrime[1] = -1\n nextPrimePower[1] = -1\n afterPrimePowerDivison[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n val new = i / p\n nextPrime[i] = p\n if(nextPrime[new] == p){\n nextPrimePower[i] = nextPrimePower[new]\n afterPrimePowerDivison[i] = afterPrimePowerDivison[new]\n }else{\n afterPrimePowerDivison[i] = new\n }\n nextPrimePower[i] += 1\n }\n }\n fun prepareFactors(){\n // 700ms in 1M\n // shoudl not be used for 1M\n // 200ms codeforces for 200k\n factors = List(sieveMx + 1){ mutableListOf()}\n factors[1].add(1)\n\n for(i in 2..sieveMx){\n val p = nextPrime[i]\n val a = nextPrimePower[i]\n val old = afterPrimePowerDivison[i]\n\n var here = 1\n repeat(a+1){\n for(c in factors[old]){\n factors[i].add(c * here )\n }\n here *= p\n }\n// factors[1].ad\n// factors[i].addAll(i.factors())\n }\n }\n fun calculateMobius(){\n kotlin.assert(sieveCalculated)\n mobius = IntArray(sieveMx + 1)\n mobius[1] = 1\n for(i in 2..sieveMx){\n val p = primeOf[i]\n if(p == primeOf[i/p]){\n mobius[i] = 0\n }else{\n mobius[i] = -1 * mobius[i/p]\n }\n }\n }\n}\ninline fun Int.eachPrimePower(act:(Int,Int)->Unit){\n var here = this\n while(here > 1){\n act(sieve.nextPrime[here], sieve.nextPrimePower[here])\n here = sieve.afterPrimePowerDivison[here]\n }\n}\nfun GS(start:Int,ratio:Int,count:Int) = sequence {\n var ret = 1\n for(i in 1\n ..count){\n ret *= ratio\n yield(ret)\n }\n}\nfun Int.factors():List{\n val ret = mutableListOf(1)\n this.eachPrimePower { p, e ->\n val s = ret.toList()\n for(pn in GS(p,p,e)){\n ret.addAll(s.map{it * pn})\n }\n }\n return ret\n}\nfun totient(a:Int):Int{\n var ret = a\n a.eachPrimePower{\n p, _ ->\n ret /= p\n ret *= (p-1)\n }\n return ret\n}\nfun Int.numOfDivisors():Int{\n var ret = 1\n this.eachPrimePower { _, e -> ret *= (e+1) }\n return ret\n}\nfun Int.factorLook():List{\n return sieve.factors[this]\n}\n\n\nfun stirtry2(n:Int):IntArray {\n val A = IntArray(n+1){\n val x = FACT.invStore[it]\n if(it %2 == 0) x else x.additiveInverse()\n }\n val B = IntArray(n+1){\n intPow(it, n,pI) modM FACT.invStore[it]\n }\n val F = FFT.fullconvolution(A,B)\n\n return F\n}\nval recitations = mutableMapOf()\nfun getitdone(n:Int, k:Int):Int{\n if(recitations[n] != null){\n return recitations[n]!!\n }\n val that = stirtry2(n)\n var ret = 0\n for(i in 1..minOf(n,k)){\n ret = ret modPlus that[i]\n }\n// \"$n $k \" dei thatv\\\\\n\n val final = ret modMinus 1\n recitations[n] = final\n return final\n}\n\n\n\nvar n =0\nconst val singleCase = true\nfun main(){\n FACT.preCal(200005)\n sieve.calculateSieveFast()\n sieve.calculateMobius()\n\n// just dei stirtry2(6)\n solve.cases{\n n = getint\n val k = getint\n var ans = 0\n\n if(n == 1 && k == 1){\n put(1)\n return@cases\n }\n\n for(i in 1..n){\n val m = sieve.mobius[i].adjust()\n if(m == 0) continue\n\n val now = getitdone(n divCeil i,k)\n// i dei now\n ans = ans modPlus ( now modM m)\n }\n put(ans)\n }\n done()\n}\n/*\njust number of such patterns\n\n\n\nn\nn/2\nn/3\n\n */\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1410c9a531b691c20d3b3f02797fe097", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun DataReader.solve(out: PrintWriter) {\n val s = nextToken()\n\n out.println((0..s.length - 1).mapTo(mutableSetOf()) { s.substring(it) + s.substring(0, it) }.size)\n}\n\nfun Boolean.toYesNo() = if (this) \"YES\" else \"NO\"\n\nclass DataReader(private val reader: BufferedReader) {\n var st : StringTokenizer? = null\n companion object {\n fun createFromFile(name: String) = DataReader(BufferedReader(FileReader(name)))\n }\n\n fun next() : String? {\n while (st == null || !st!!.hasMoreTokens()) {\n val s = reader.readLine() ?: return null\n st = StringTokenizer(s)\n }\n\n return st?.nextToken()\n }\n\n fun nextToken() = next()!!\n\n fun nextInt() = nextToken().toInt()\n fun nextLong() = nextToken().toLong()\n fun readIntArray(n: Int) : IntArray {\n val result = IntArray(n)\n result.indices.forEach { i -> result[i] = nextInt() }\n return result\n }\n\n fun nextLine() = reader.readLine()\n}\n\nfun main(args: Array) {\n val r: Reader\n val out: PrintWriter\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n r = FileReader(\"input.txt\")\n out = PrintWriter(\"output.txt\")\n } else {\n r = InputStreamReader(System.`in`)\n out = PrintWriter(System.out)\n }\n\n DataReader(BufferedReader(r)).solve(out)\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d924a0f3af143a7dae07b7ee51c1b6ba", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val str = readLine()!!\n\n val a = Array(str.length) { \"\" }\n a[0] = str\n for (i in 1..str.length - 1) {\n a[i] = a[i - 1].substring(1) + a[i - 1][0]\n }\n\n val ans = a.toSet().size\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b56739b927beedd74d5d8e7a0974f32c", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val s = readLine()!!\n val words = mutableSetOf()\n for (start in s.indices)\n words.add(s.substring(start, s.length) + s.substring(0, start))\n print(words.size)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a76561f32ecff77293561f1e1ea1fe47", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\ndata class Player(val a: Int, val d: Int)\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val P = Array(4){Player(ni(), ni())}\n fun play(x1: Int) = run{\n (0 until 2).map { x2 ->\n val a1 = P[x1].a\n val d1 = P[1 xor x1].d\n val a2 = P[2 + x2].a\n val d2 = P[2 + (1 xor x2)].d\n\n if (a1 > d2 && d1 > a2) 0\n else if (a2 > d1 && d2 > a1) 2\n else 1\n }.max()!!\n }\n\n val res = min(play(0), play(1))\n val ans = when(res) {\n 0 -> \"Team 1\"\n 1 -> \"Draw\"\n 2 -> \"Team 2\"\n else -> \"\"\n }\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl()\n }\n return res\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "81fe5bd1e2bceed573bd4161c4375bd7", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import kotlin.math.absoluteValue\nimport kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (x1, y1) = readInts()\n val (x2, y2) = readInts()\n print((max(2, (x1 - x2).absoluteValue + 1)) * 2 + max(2, ((y1 - y2).absoluteValue + 1)) * 2)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "49c7d2433da33ce7de84d04c41fd7a5c", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val A = ni()\n val B = ni()\n if (B > A) {\n out.println(0)\n return\n }\n\n if (A == B) {\n out.println(\"infinity\")\n return\n }\n\n val mx = (A - B)\n var x = 1\n var ans = 0\n while(x * x <= mx) {\n if (mx % x == 0) {\n if (A % x == B) ans++\n if (x * x != mx && A % (mx / x) == B) ans++\n }\n x++\n }\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n, offset) { ni() }\n }\n\n private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i + offset)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun pair(a: A, b: B) = RPair(a, b)\ndata class RPair(val _1: A, val _2: B)\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f11ee691325b38da610e3048087bf971", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (vStart, vEnd) = readInts()\n val (time, d) = readInts()\n var meters = 0\n var currentTime = 0\n var currentSpeed = vStart\n while(currentTime < time) {\n meters += currentSpeed\n currentTime++\n val timeAfter = time - currentTime - 1\n val desiredSpeed = vEnd + timeAfter*d\n currentSpeed = max(currentSpeed - d, min(desiredSpeed, currentSpeed + d))\n }\n print(meters)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ebadb0b411d60387c46a3faf727e5aa8", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n var output = false\n for (a in 0..n / 1234567) {\n for (b in 0..(n - a * 1234567) / 123456) {\n for (c in 0..(n - a * 1234567 - b * 123456) / 1234) {\n if (a * 1234567 + b * 123456 + c * 1234 == n) {\n output = true\n break\n }\n }\n if(output) break\n }\n if (output) break\n }\n if (output) print(\"YES\") else print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2cb99f9a4b7890007d3f492d19a17ef4", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n for (a in 0..n / 1234567) {\n for (b in 0..(n - a * 1234567) / 123456) {\n if ((n - a * 1234567 - b * 123456) % 1234 == 0) {\n print(\"YES\")\n return\n }\n }\n }\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "42160ec29cce0372a7aee85d24cd431c", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val dp = Array(N + 1){Array(2){LongArray(N + 10)} }\n dp[0][0][0] = 1\n\n for (i in 0 until N) {\n for (j in 0 .. N) {\n for (s in 0 until 2) { // reflexive\u3092\u6e80\u305f\u3055\u306a\u3044\n for (k in 0 until 2) { // \u8ffd\u52a0\u3059\u308b\u304b\n for (l in 0 until 2) { // \u9023\u7d50\u3059\u308b\u304b\n if (k == 0 && l == 1) continue\n val nj = if (k == 1 && l == 0) j + 1 else j\n val ns = if (s == 0 && k == 1) 0 else 1\n val c = if (l == 1) j else 1\n dp[i + 1][ns][nj] = (dp[i + 1][ns][nj] + dp[i][s][j] * c) % MOD\n }\n }\n }\n }\n }\n\n debug(dp[N][0])\n debug(dp[N][1])\n\n out.println(dp[N][1].sum() % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a265bc5193d51b9d83142455f64ee03f", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nprivate val MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val dp = Array(N + 1){Array(2){LongArray(N + 10)} }\n dp[0][0][0] = 1\n\n for (i in 0 until N) {\n for (j in 0 .. N) {\n for (s in 0 until 2) { // reflexive\u3092\u6e80\u305f\u3055\u306a\u3044\n for (k in 0 until 2) { // \u8ffd\u52a0\u3059\u308b\u304b\n for (l in 0 until 2) { // \u9023\u7d50\u3059\u308b\u304b\n if (k == 0 && l == 1) continue\n val nj = if (k == 1 && l == 0) j + 1 else j\n val ns = if (s == 0 && k == 1) 0 else 1\n val c = if (l == 1) j else 1\n dp[i + 1][ns][nj] = (dp[i + 1][ns][nj] + dp[i][s][j] * c) % MOD\n }\n }\n }\n }\n }\n\n debug(dp[N][0])\n debug(dp[N][1])\n\n out.println(dp[N][1].sum() % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5682c7f6e2cfcd62c494b0e033224056", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nprivate val MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n var best = Array(2){LongArray(N + 10)}\n var next = Array(2){LongArray(N + 10)}\n best[0][0] = 1\n\n for (i in 0 until N) {\n Arrays.fill(next[0], 0)\n Arrays.fill(next[1], 0)\n for (j in 0 .. i) {\n for (s in 0 until 2) { // reflexive\u3092\u6e80\u305f\u3055\u306a\u3044\n for (k in 0 until 2) { // \u8ffd\u52a0\u3059\u308b\u304b\n for (l in 0 until 2) { // \u9023\u7d50\u3059\u308b\u304b\n if (k == 0 && l == 1) continue\n val nj = if (k == 1 && l == 0) j + 1 else j\n val ns = if (s == 0 && k == 1) 0 else 1\n val c = if (l == 1) j else 1\n next[ns][nj] = (next[ns][nj] + best[s][j] * c) % MOD\n }\n }\n }\n }\n val tmp = best\n best = next\n next = tmp\n }\n\n debug(best[0])\n debug(best[1])\n\n out.println(best[1].sum() % MOD)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a0e49fc0560879726001395280aea32d", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.io.File\n\nfun main(args: Array) {\n /*\n val lines = File(\"actual\").readText().split(\"\\n\").filter { ' ' in it }\n val correct = lines.map { s -> s.substringAfter(\" \") }\n val ns = lines.map { s -> s.substringBefore(\" \").toInt() }\n var wrong = 0\n */\n\n repeat(readLine()!!.toInt()) { test ->\n val a = readLine()!!.split(' ').map(String::toInt).toIntArray()\n\n val min = a.min()!!\n val max = a.max()!!\n val u = (Math.abs(min) + Math.abs(max)) / 2\n\n val v = a.sumByDouble { x -> x * x * 1.0 } / a.size\n val sv = Math.sqrt(v)\n\n val ans = if (2*sv > u && (u > 5 || (min >= -u && max <= u))) \"uniform\" else \"poisson\"\n println(ans)\n\n /*\n if (ans != correct[test]) {\n println(\"$test min=$min max=$max u=$u v=$v sv=$sv expected=${correct[test]} actual=$ans N=${ns[test]}\")\n wrong++\n }\n */\n }\n \n // println(\"correct ${correct.size - wrong} wrong $wrong\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "17618530514c12dea79fae8139d2a45e", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) {\n with(Scanner(System.`in`)) {\n val n = nextLong()\n val m = nextLong()\n val k = nextLong()\n val r = k % (m * n)\n if (r < n) {\n println(\"${r+1} 1\")\n } else {\n val r0 = r - n\n val t0 = r0 / (m-1)\n val t1 = r0 % (m-1)\n if (t0 % 2 == 0L) {\n println(\"${n-t0} ${1+t1}\")\n } else {\n println(\"${n-t0} ${1+m-1-t1}\")\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2c678bd1a3fadaccf0d0c123652ba248", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.HashMap\nimport kotlin.math.min\n\nfun main(args: Array)\n = Thread { run() }.start()\n\nfun run() {\n\n val scanner = Scanner(System.`in`)\n val n = scanner.nextLong()\n val m = scanner.nextLong()\n var q = scanner.nextLong()\n if (q < n) {\n println(\"${q + 1} 1\")\n return\n }\n q -= n;\n val r = n - (q / (m - 1))\n if ((n - r) % 2 == 0L)\n println(\"$r ${2 + (q % (m - 1))}\")\n else\n println(\"$r ${m - (q % (m - 1))}\")\n}\n\nclass Scanner(s: InputStream) {\n var st: StringTokenizer? = null\n var br: BufferedReader = BufferedReader(InputStreamReader(s))\n @Throws(IOException::class)\n operator fun next(): String {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n @Throws(IOException::class)\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n @Throws(IOException::class)\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n @Throws(IOException::class)\n fun nextLine(): String {\n return br.readLine()\n }\n @Throws(IOException::class)\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n @Throws(IOException::class)\n fun ready(): Boolean {\n return br.ready()\n }\n}\nclass Pair(var a: Int, var b: Int): Comparable {\n override fun compareTo(other: Pair): Int {\n return a - other.a\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0006e3058c6e3d3de167d3b930e8e523", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.text.SimpleDateFormat\nimport java.util.*\nimport kotlin.Comparator\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\nimport kotlin.math.round\nimport kotlin.random.Random\nimport kotlin.system.measureTimeMillis\n\n/**\n * 23.02.2020\n * Main\n *\n * @author Havlong\n * @version v1.0\n */\nclass LineReader(tempReader: Reader) {\n private val reader = BufferedReader(tempReader)\n fun hasNext() = peek() != -1\n private fun peek(): Int {\n reader.mark(1)\n return reader.read().also { reader.reset() }\n }\n\n fun skipSpaces() {\n while (Character.isWhitespace(peek()))\n reader.read()\n }\n\n fun readLine(): String = reader.readLine()\n fun longList() = readLine().split(' ').map(String::toLong)\n fun intList() = readLine().split(' ').map(String::toInt)\n}\n\ntypealias ML = MutableList\ntypealias MI = MutableList\ntypealias LL = List\ntypealias LLL = List\ntypealias PLL = Pair\ntypealias PPLL = Pair\n\nconst val M7 = 1000000007L\nconst val M9 = 1000000009L\nconst val MFFT = 998244353L\nconst val INF = 2000000000000000000L\n\nfun lowerBound(from: Long, to: Long, comparison: (Long) -> Long): Long {\n var left = from\n var right = to + 1\n while (left < right) {\n val mid = (left + right) / 2\n val result = comparison(mid)\n if (result >= 0) {\n right = mid\n } else {\n left = mid + 1\n }\n }\n return left\n}\n\nfun upperBound(from: Long, to: Long, comparison: (Long) -> Long): Long {\n var left = from\n var right = to + 1\n while (left < right) {\n val mid = (left + right) / 2\n val result = comparison(mid)\n if (result > 0) {\n right = mid\n } else {\n left = mid + 1\n }\n }\n return left\n}\n\nfun > List.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {\n return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()\n}\n\nfun > List.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {\n return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()\n}\n\nfun > Array.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {\n return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()\n}\n\nfun > Array.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {\n return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()\n}\n\noperator fun , B : Comparable> Pair.compareTo(other: Pair): Int {\n return first.compareTo(other.first).let { if (it == 0) second.compareTo(other.second) else it }\n}\n\nfun binPow(number: Long, power: Long, mod: Long): Long {\n var result = 1L\n var a = number % mod\n var n = power\n while (n > 0) {\n if (n % 2 != 0L)\n result = (result * a) % mod\n a = (a * a) % mod\n n /= 2\n }\n return result\n}\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = a * b / gcd(a, b)\n\nfun main(args: Array) {\n if (args.isNotEmpty() && args[0] == \"local\") {\n val reader = LineReader(FileReader(\"input.txt\"))\n PrintWriter(File(\"output.txt\")).use {\n while (reader.hasNext()) {\n it.println(\"\\n${measureTimeMillis {\n solve(reader, it)\n }} ms\\n\")\n reader.skipSpaces()\n }\n }\n } else {\n val reader = LineReader(InputStreamReader(System.`in`))\n PrintWriter(System.out).use { solve(reader, it) }\n }\n}\n\nfun solve(reader: LineReader, writer: PrintWriter) {\n val format = SimpleDateFormat(\"yyyy:MM:dd\")\n val start = format.parse(reader.readLine().trim())\n val end = format.parse(reader.readLine().trim())\n writer.println(abs(round((end.time - start.time) / 1000.0 / 3600 / 24)).toLong())\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1ed107523ef5a6f9c57eb5047f0881be", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n if (s.length < t.length) {\n print(\"need tree\")\n return\n }\n val longMap = IntArray(26)\n for (c in s) longMap[c - 'a']++\n for (c in t) {\n if (longMap[c - 'a'] > 0) longMap[c - 'a']-- else {\n print(\"need tree\")\n return\n }\n }\n val automaton = s.length != t.length\n var sPos = 0\n var lPos = 0\n while (sPos < t.length && lPos < s.length) {\n if (t[sPos] == s[lPos]) sPos++\n lPos++\n }\n print(\n when {\n automaton && sPos < t.length -> \"both\"\n automaton -> \"automaton\"\n else -> \"array\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "74938ca225ab58a4408114d255800d7c", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readLong() = readLine()!!.toLong()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val s = readLine()!!\n val t = readLine()!!\n val (longer, shorter) = if (s.length >= t.length) s to t else t to s\n if (shorter in longer) {\n print(\"automaton\")\n return\n }\n val longMap = IntArray(26)\n val shortMap = IntArray(26)\n for (c in longer) longMap[c - 'a']++\n for (c in shorter) shortMap[c - 'a']++\n var automaton = false\n var array = false\n var needTree = false\n loop@ for (pos in 0..25) {\n when {\n longMap[pos] > shortMap[pos] -> automaton = true\n longMap[pos] == shortMap[pos] -> array = true\n else -> {\n needTree = true\n break@loop\n }\n }\n }\n print(\n when {\n needTree -> \"need tree\"\n automaton && array -> \"both\"\n automaton -> \"automaton\"\n else -> \"array\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e0a73d67ca5d3262a85321f137d914c3", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.math.max\n\nprivate val scanner = Scanner(System.`in`)\nprivate val size = 100_000 + 10\n\nfun gcd(a: Int, b: Int): Int =\n if (b > 0)\n gcd(b, a % b)\n else\n a\n\nfun main() {\n scanner.apply {\n val A = nextInt()\n var sum = 0\n for (base in 2 until A) {\n var cursum = 0\n var cura = A\n while (cura > 0) {\n cursum += cura % base\n cura /= base\n }\n sum += cursum\n }\n val gcd = gcd(sum, A - 2)\n println(\"${sum/gcd}/${(A-2)/gcd}\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7f94004de2e99b6dcc50b083b63ea5fb", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.concurrent.fixedRateTimer\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_003\n\nfun powMat(a: Array, n: Long, mod: Int): Array {\n if (n == 1L) return a\n val res = powMat(mulMat(a, a, mod), n / 2, mod)\n return if (n % 2 == 1L) mulMat(res, a, mod) else res\n}\nfun mulMat(a: Array, b: Array, mod: Int): Array {\n assert(a[0].size == b.size)\n val len = a[0].size\n val h = a.size\n val w = b[0].size\n val res = Array(h){LongArray(w)}\n val th = 7e18.toLong()\n for (i in 0 until h) {\n for (j in 0 until w) {\n var v = 0L\n for (k in 0 until len) {\n v += a[i][k] * b[k][j]\n if (v > th) v %= mod\n }\n res[i][j] = if (v >= mod) v % mod else v\n }\n }\n return res\n}\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val C = nl()\n val W = ni()\n val H = ni()\n val A = Array(W + 1){LongArray(W + 1)}\n for (j in 0 .. W) {\n A[0][j] = 1\n }\n for (i in 1 .. W) {\n A[i][i - 1] = H.toLong()\n }\n debugDim(A)\n val B = powMat(A, C, MOD)\n val s = Array(W + 1){ LongArray(1) }\n s[0][0] = 1\n val calc = mulMat(B, s, MOD)\n val ans = calc.map{it[0]}.sum() % MOD\n out.println(ans)\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "55d6aa1228a63972802cc5f01dadf700", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.*\nimport kotlin.math.*\n\nprivate fun readLn() = readLine()!! // string\nprivate fun readInt() = readLn().toInt() // int\nprivate fun readStrings() = readLn().split(\" \") // string string\nprivate fun readInts() = readStrings().map { it.toInt() } // int int\n\nfun main() {\n var (n, t) = readInts()\n var a = Array>(n + 1){ arrayListOf() }\n for (i in 0..n){\n for (j in 0..i){\n a[i].add(0)\n }\n }\n\n repeat(t){\n a[0][0] += 512\n for (i in 0 until n){\n for (j in 0..i){\n var fall = max(a[i][j] - 512, 0)\n a[i + 1][j] += fall/2\n a[i + 1][j + 1] += fall/2\n a[i][j] = min(a[i][j], 512)\n }\n }\n }\n var ans = 0\n for (i in 0 until n){\n for (j in 0..i){\n ans += if (a[i][j] == 512) 1 else 0\n }\n }\n print(ans)\n //System.out.println(Arrays.deepToString(a))\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f93828ebdcd792adee2508e66311e5e3", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n repeat(readLine()!!.toInt()) {\n val a = readLine()!!.split(' ').map(String::toInt).toIntArray()\n var e = a.sum() * 1.0 / a.size\n var v = a.sumByDouble { x -> (x - e) * (x - e) } / a.size\n if (v > 2*e) {\n // Uniform\n val l = a.toSortedSet().toList()\n val ans = Math.round((l.first() + l.last()) / 2.0).toInt()\n println(ans)\n } else {\n // Poisson\n println(Math.round(e))\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "814fb7e53a0c2a9680547ed2eec6aa62", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "fun main() {\n data class R(var t: Long, var m: Int, var f: Boolean)\n readLine()\n readLine()!!.split(\" \").fold(R(1, 1, true)) { acc, i ->\n if (i == \"1\") {\n if (!acc.f) acc.t *= acc.m\n acc.m = 1\n acc.f = false\n } else {\n acc.m++\n }\n acc\n }.run { print(if (f) 0 else t) }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a23e9fe18000656b60e66cf003fae96f", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\nfun main(args: Array)\n{\n var ins:String\n var fact:BigInteger = BigInteger.valueOf(1)\n var sum:BigInteger = BigInteger.valueOf(0)\n var m:BigInteger = BigInteger.valueOf(2)\n var bb:BigInteger\n\n var nn:Int\n ins = readLine()!!\n nn = ins.toInt()\n fact = ins.toBigInteger()\n\n for(i in 1..nn)\n {\n bb = i.toBigInteger()\n fact = fact.multiply(bb)\n sum = sum.add(m.multiply(fact))\n }\n sum = sum.divide(m)\n println(sum)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6a36bd0175083696b1df9117e69b190e", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n print((readInt() + 1) shr 1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2c2174da0e8ed2cf3ac42fad49d9951c", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val n = r.readLine()!!.toInt()\n //var (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n val (day, ret) = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }\n var get = 0\n var max = v[0]\n v.forEach {\n val profit = (max-it)-ret*it\n get = maxOf(get, profit)\n max = maxOf(max, it)\n }\n println(get)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fb9822584d4510c9129854b84f46cae6", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val n = r.readLine()!!.toInt()\n //var (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n val (day, ret) = r.readLine()!!.split(\" \").map { it.toInt() }\n val v = r.readLine()!!.split(\" \").map { it.toInt() }\n var get = 0\n for (i in 1..day-1){\n val profit = (v[i-1]-v[i])-ret\n get = maxOf(get, profit)\n }\n println(get)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fba3ea322913e1a11d94702f1849f66d", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n val used = BooleanArray(5)\n var sol = 0\n val permutation = mutableListOf()\n val happiness = Array(5) { IntArray(5) }\n\n fun permute() {\n if (permutation.size == 5) {\n var oneSol = 0\n oneSol += happiness[permutation[0]][permutation[1]] + happiness[permutation[1]][permutation[0]]\n oneSol += happiness[permutation[2]][permutation[3]] + happiness[permutation[3]][permutation[2]]\n oneSol += happiness[permutation[1]][permutation[2]] + happiness[permutation[2]][permutation[1]]\n oneSol += happiness[permutation[3]][permutation[4]] + happiness[permutation[4]][permutation[3]]\n oneSol += happiness[permutation[2]][permutation[3]] + happiness[permutation[3]][permutation[2]]\n oneSol += happiness[permutation[3]][permutation[4]] + happiness[permutation[4]][permutation[3]]\n sol = max(sol, oneSol)\n } else {\n for (pos in 0..4) {\n if (used[pos]) continue\n used[pos] = true\n permutation.add(pos)\n permute()\n permutation.removeAt(permutation.lastIndex)\n used[pos] = false\n }\n }\n }\n\n for (row in 0 until 5) happiness[row] = readInts().toIntArray()\n permute()\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "28396da49d213fdd7a525503f3b174e3", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val C = nl()\n val happy = nal(2)\n val weight = nal(2)\n\n fun swap(A: LongArray) {\n val t = A[0]\n A[0] = A[1]\n A[1] = t\n }\n\n fun swap() {\n swap(happy)\n swap(weight)\n }\n\n if (weight.max()!! >= 100) {\n if (weight[0] < weight[1]) swap()\n // weight0 >= weight1 \u306b\u3059\u308b\n var ans = 0L\n var c0 = 0L\n while(c0 * weight[0] <= C) {\n val c1 = (C - c0 * weight[0]) / weight[1]\n ans = max(ans, c0 * happy[0] + c1 * happy[1])\n c0++\n }\n out.println(ans)\n } else {\n if (happy[0] * weight[1] < happy[1] * weight[0]) swap()\n // H0/W0 >= H1/W1 \u306b\u3059\u308b\n var ans = 0L\n var c1 = 0L\n while(c1 * weight[1] <= C && c1 <= weight[0] * weight[1]) {\n val c0 = (C - c1 * weight[1]) / weight[0]\n ans = max(ans, c0 * happy[0] + c1 * happy[1])\n c1++\n }\n out.println(ans)\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // \u306a\u3093\u304b\u672c\u756a\u3067\u30a8\u30e9\u30fc\u3067\u308b\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * \u52dd\u624b\u306bimport\u6d88\u3055\u308c\u308b\u306e\u3092\u9632\u304e\u305f\u3044\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "21a0880dff4dbe24cbeebae8e5b21040", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n val (h1, h2) = readInts()\n val (a, b) = readInts()\n\n // get to 10 pm\n var x = h1\n x += 8 * a\n if (x >= h2) {\n println(0)\n return\n }\n if (a <= b) {\n println(-1)\n return\n }\n\n var ans = 0\n while (x < h2) {\n x += 12 * (a - b)\n ans += 1\n }\n\n println(ans)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "75e45a9b246d2532f9c9d721fcb47e6e", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\n\n\n fun main(args: Array) {\n val infile = BufferedReader(InputStreamReader(System.`in`))\n val st = StringTokenizer(infile.readLine())\n val L = Integer.parseInt(st.nextToken())\n val R = Integer.parseInt(st.nextToken())\n val X = Integer.parseInt(st.nextToken())\n val Y = Integer.parseInt(st.nextToken())\n if (Y % X != 0) {\n println(0)\n return\n }\n var res = 0\n val boof = Y / X\n var i = 1\n while (i <= Math.sqrt(boof.toDouble())) {\n if (boof % i == 0 && X * Math.min(i, boof / i) >= L && X * Math.max(i, boof / i) <= R)\n if (rp(i, boof / i)) {\n res += 2\n if (i == boof / i)\n res--\n }\n i++\n }\n println(res)\n }\n\n fun rp(c: Int, d: Int): Boolean {\n var a = c\n var b = d\n if (b > a) {\n val t = a\n a = b\n b = t\n }\n return if (b == 0) a == 1 else rp(b, a % b)\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4727dd702da4041c381c8796685cd84d", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n\n val sc = Scanner(System.`in`)\n val n : Int = sc.nextInt()\n val m : Int = sc.nextInt()\n var k : Int = sc.nextInt()\n val a = IntArray(n)\n var count = n\n\n for (i in 0 until n) a[i] = sc.nextInt()\n Arrays.sort(a)\n\n while (k < m && count > 0) {\n count--\n k += a[count] - 1\n }\n\n if (k < m) print(-1)\n else print(n - count)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cf6fdfe4bee42f0fef1932e65e5c0797", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val n = jin.readLine().toInt()\n val piles = jin.readLine().split(\" \").map { it.toInt() }\n println(if (piles.count { it == piles.min() } <= n / 2) \"Alice\" else \"Bob\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "bb671f6eb530e1461fd897706aac2bd0", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val n = readLine()!!.toInt()\n val ys = IntArray((2 * n) + 1)\n val line = readLine()!!\n for (i in 0 until 2 * n) {\n ys[i + 1] = ys[i] + if (line[i % n] == '(') 1 else -1\n }\n if (ys[n] != 0) {\n println(0)\n println(\"1 1\")\n return\n }\n val low = ys.min()!!\n val sums = Array(3) { IntArray((2 * n) + 1) }\n //println(\"ys = ${ys.contentToString()}\")\n //println(\"low = $low\")\n for (i in 1..2 * n) {\n for (j in 0..2) {\n sums[j][i] = sums[j][i - 1]\n }\n if (ys[i] - low <= 2) {\n sums[ys[i] - low][i]++\n }\n }\n /*for (j in 0..2) {\n println(\"sums[$j] = ${sums[j].contentToString()}\")\n }*/\n val last = IntArray(2)\n val nearest = Array(2) { IntArray(n + 1) }\n for (i in 2 * n downTo 1) {\n if (ys[i] - low <= 1) {\n last[ys[i] - low] = i\n }\n if (i <= n) {\n for (j in 0..1) {\n nearest[j][i] = last[j]\n }\n }\n }\n /*for (j in 0..1) {\n println(\"nearest[$j] = ${nearest[j].contentToString()}\")\n }*/\n var answer = sums[0][n]\n var al = 1\n var ar = 1\n for (i in 1..n) {\n if (line[i - 1] == '(') {\n var j = min(nearest[0][i], nearest[1][i])\n var pos = sums[0][n] + sums[2][j - 1] - sums[2][i - 1]\n if (pos > answer) {\n answer = pos\n al = i\n ar = j\n }\n if (nearest[1][i] < nearest[0][i]) {\n j = nearest[0][i]\n pos = sums[1][j - 1] - sums[1][i - 1]\n if (pos > answer) {\n answer = pos\n al = i\n ar = j\n }\n }\n }\n }\n println(answer)\n println(\"$al ${((ar - 1) % n) + 1}\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5760231750a690d73957a7305acf6991", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val jin = BufferedReader(InputStreamReader(System.`in`))\n val out = StringBuilder()\n for (c in 1..jin.readLine().toInt()) {\n val n = jin.readLine().toInt()\n var intervalLeft = 1L\n var intervalRight = Int.MAX_VALUE.toLong()\n val treeSet = TreeSet()\n var answer = (2 * n) + 1\n val tokenizer = StringTokenizer(jin.readLine())\n var sign = true\n var constant = 0L\n for (j in 1..n) {\n val k = tokenizer.nextToken().toLong()\n if (sign) {\n if (k % 2L == 0L) {\n val h = k / 2L\n if (h - constant in intervalLeft..intervalRight || h - constant in treeSet) {\n answer -= 2\n intervalLeft = h - constant\n intervalRight = h - constant\n treeSet.clear()\n treeSet.add(h - constant)\n } else {\n answer--\n treeSet.add(h - constant)\n intervalLeft = max(intervalLeft, 1L - constant)\n intervalRight = min(intervalRight, k - 1L - constant)\n while (treeSet.isNotEmpty() && treeSet.first() < 1L - constant) {\n treeSet.remove(treeSet.first())\n }\n while (treeSet.isNotEmpty() && treeSet.last() > k - 1L - constant) {\n treeSet.remove(treeSet.last())\n }\n }\n } else {\n intervalLeft = max(intervalLeft, 1L - constant)\n intervalRight = min(intervalRight, k - 1L - constant)\n while (treeSet.isNotEmpty() && treeSet.first() < 1L - constant) {\n treeSet.remove(treeSet.first())\n }\n while (treeSet.isNotEmpty() && treeSet.last() > k - 1L - constant) {\n treeSet.remove(treeSet.last())\n }\n if (intervalLeft > intervalRight && treeSet.isEmpty()) {\n intervalLeft = 1L - constant\n intervalRight = k - 1L - constant\n } else {\n answer--\n }\n }\n } else {\n if (k % 2L == 0L) {\n val h = k / 2L\n if (constant - h in intervalLeft..intervalRight || constant - h in treeSet) {\n answer -= 2\n intervalLeft = constant - h\n intervalRight = constant - h\n treeSet.clear()\n treeSet.add(constant - h)\n } else {\n answer--\n treeSet.add(constant - h)\n intervalLeft = max(intervalLeft, constant - (k - 1L))\n intervalRight = min(intervalRight, constant - 1L)\n while (treeSet.isNotEmpty() && treeSet.first() < constant - (k - 1L)) {\n treeSet.remove(treeSet.first())\n }\n while (treeSet.isNotEmpty() && treeSet.last() > constant - 1L) {\n treeSet.remove(treeSet.last())\n }\n }\n } else {\n intervalLeft = max(intervalLeft, constant - (k - 1L))\n intervalRight = min(intervalRight, constant - 1L)\n while (treeSet.isNotEmpty() && treeSet.first() < constant - (k - 1L)) {\n treeSet.remove(treeSet.first())\n }\n while (treeSet.isNotEmpty() && treeSet.last() > constant - 1L) {\n treeSet.remove(treeSet.last())\n }\n if (intervalLeft > intervalRight && treeSet.isEmpty()) {\n intervalLeft = constant - (k - 1L)\n intervalRight = constant - 1L\n } else {\n answer--\n }\n }\n }\n constant = k - constant\n sign = !sign\n }\n out.appendln(answer)\n }\n print(out)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cee1a673da5d5dd6fe596e2b9b4612e6", "src_uid": "e809d068b3ae47eb5ecfb9ac69892254", "difficulty": 3200.0}