{"lang": "Kotlin", "source_code": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\nfun main()\n{\n //val n: Int\n //val k: Int\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 println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2a10d31705ac5d0d698ab65e80b853a8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package programkt\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": "d1f95ecbdd4edda03f2fc3621fc9d2eb", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array)\n{\n val read = Scanner(System.`in`) \n var number = read.nextInt()\n var k = read.nextInt()\n for(h in 0 until k){\n if(number%10>0)\n number-=1;\n else\n number/=10;\n }\n println(number)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "07921b72ff84729197720b2fd32adab9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args : Array) {\nvar k: Int\nvar n: Int\n var result = n\n repeat((1..k).count()) {\n if (result % 10 == 0)\n result /= 10\n else\n result--\n }\n\n print(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3153b8bf51164e56780eab99cf1174f6", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package main\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": "a16a4dc3578f74b978ccd023de3f81b8", "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 res = t\n push(res)\n if (res == null) {\n res = newNode\n } else {\n val p = split(res, newNode.key, 0)\n res = merge(p.first, newNode)\n res = merge(res, p.second)\n }\n update(res)\n return res\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 res1 = t1\n var res2 = t2\n if (res1 == null) return res2\n if (res2 == null) return res1\n push(res1)\n push(res2)\n if (res1.prior < res2.prior) {\n val c = res1\n res1 = res2\n res2 = c\n }\n val split1 = split(res2, res1.key)\n res1.left = unite(res1.left, split1.first)\n res1.right = unite(res1.right, split1.second)\n return res1\n }\n\n fun remove(t: Node?, key: Int): Node? {\n var res: Node? = t ?: return null\n if (res!!.key == key) {\n res = merge(res.left, res.right)\n } else {\n if (key < res.key) {\n res.left = remove(res.left, key)\n } else {\n res.right = remove(res.right, key)\n }\n }\n update(res)\n return res\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": "8dc04defd9c1598aee598ba4e6610497", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long int n,k;\n cin>>n>>k;\n while(k--)\n {\n if(n%10==0)\n n/=10;\n else\n n-=1;\n\n if(k==0)\n break;\n }\n cout<) {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var k = sc.nextInt()\n\n while (k > 0) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n k--\n }\n\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e1bb8075ea30c9d29147df59d2e96896", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n //println(\"Hello, World!\")\n //var num1=Scanner(System.`in`)\n val n=readLine()!!.toInt()\n val k=readLine()!!.toInt()\n for (i in 1..k) { \n if(n%10==0){\n n/=10\n }\n else{\n n=n-1\n }\n //println(\"$n\")\n } \n println(\"$n\")\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9c54d53fd87925b13cef2540601ae56d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readlnLong()\n val k = readlnLong()\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": "c3de8e8c048846974948410d8095950d", "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 print(WrongSubtractionProblem.solve(n, k))\n }\n}\n\nobject WrongSubtractionProblem {\n\n 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\n private fun decrease(number: Int): Int =\n when (number % 10) {\n 0 -> number / 10\n else -> number - 1\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1d84099c5142846660157deb8bffc434", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val inputs = readLine().orEmpty().split(' ', limit = 2)\n\nval number = inputs.first()\nval executions = inputs.last()\n\nvar output = number\nrepeat(executions) {\n val lastDigit = output % 10\n if (lastDigit > 0) {\n output -= 1\n } else {\n output /= 10\n }\n}\nprintln(output)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "62988e225c39b1b4e90e2b11ed772436", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package heroes\n\nconst val DIVIDER = 10\nconst val LARGEST_NUMBER = 1_000_000_000\nconst val ITERATIONS_MAX_NUMBER = 50\nconst val ITERATIONS_MIN_NUMBER = 2\n\nfun main(args: Array) {\n if (args.isEmpty() || args.size != ITERATIONS_MIN_NUMBER) {\n println(\"Please provide two numbers as a command-line argument\")\n return\n }\n val n = args[0].toInt()\n if (n < ITERATIONS_MIN_NUMBER || n > LARGEST_NUMBER) {\n throw Exception(\"n number out of range\")\n }\n val k = args[1].toInt()\n if (k < 1 || k > ITERATIONS_MAX_NUMBER) {\n throw Exception(\"k number out of range\")\n }\n var result = n\n for (i in 1..k) {\n if (result <= 1) {\n break\n }\n val remainder = result.rem(DIVIDER)\n if (remainder == 0) {\n result /= DIVIDER\n } else {\n result--\n }\n }\n\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4cce5ba8e891f432ef138cc88d1e5049", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package cp.april\n\n\nfun 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", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "808a0f4b5a57c9f586d71934f5ad8de8", "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.InputMismatchException\n/**\n* Built using CHelper plug-in\n* Actual solution is at the top\n*/\nobject Main {\n @JvmStatic fun 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 = AWrongSubtraction()\n solver.solve(1, `in`, out)\n out.close()\n }\n internal class AWrongSubtraction {\n fun solve(testNumber:Int, `in`:InputReader, out:PrintWriter) {\n val n = `in`.nextInt()\n val k = `in`.nextInt()\n while (k-- > 0)\n {\n // out.println(n + \" \" + (n % 10));\n if ((n % 10) == 0)\n {\n n /= 10\n }\n else\n {\n n--\n }\n }\n out.println(n)\n }\n }\n internal class InputReader(stream:InputStream) {\n private val stream:InputStream\n private val buf = ByteArray(1024)\n private val curChar:Int = 0\n private val numChars:Int = 0\n private val filter:InputReader.SpaceCharFilter\n init{\n this.stream = stream\n }\n fun read():Int {\n if (numChars == -1)\n {\n throw InputMismatchException()\n }\n if (curChar >= numChars)\n {\n curChar = 0\n try\n {\n numChars = stream.read(buf)\n }\n catch (e:IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0)\n {\n return -1\n }\n }\n return buf[curChar++].toInt()\n }\n fun nextInt():Int {\n val c = read()\n while (isSpaceChar(c))\n {\n c = read()\n }\n val sgn = 1\n if (c == '-'.toInt())\n {\n sgn = -1\n c = read()\n }\n val res = 0\n do\n {\n if (c < '0'.toInt() || c > '9'.toInt())\n {\n throw InputMismatchException()\n }\n res *= 10\n res += c - '0'.toInt()\n c = read()\n }\n while (!isSpaceChar(c))\n return res * sgn\n }\n fun isSpaceChar(c:Int):Boolean {\n if (filter != null)\n {\n return filter.isSpaceChar(c)\n }\n return isWhitespace(c)\n }\n interface SpaceCharFilter {\n fun isSpaceChar(ch:Int):Boolean\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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b744f097f89fa99258ffd42fe961666c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main (args: Array) {\n \n val Input = Scanner(System.`in`)\n var n = Input.nextLong()\n var b = Input.nextInt()\n var c = n\n var mod = 0\n \n for (i in 1..b) {\n mod = c % 10;\n if(mod != 0) {\n c -= 1;\n }\n else c /= 10;\n }\n println(c)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "84cd511e4c6072726a5de44dcc8bbb22", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Test {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n println(subtract(n, k))\n }\n\n fun subtract(n: Int, k: Int): Int {\n var n = n\n var k = k\n if (k == 0)\n return n\n if (n % 10 == 0)\n n /= 10\n else\n n--\n return subtract(n, --k)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bdc2fca4b5ea48521b8660c171727373", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package kotlin_heroes\n\nfun main(args: Array) {\n 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 }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "513cbf9bc6c4c63dd2a9500f1ddc7ade", "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 }\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7f38319958ba9fe1adf47712f44caa4c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main (args: Array) {\n \n val Input = Scanner(System.`in`)\n var n = Input.nextLong()\n var b = Input.nextInt()\n var c = n, mod\n\n for (i in 1..b) {\n mod = c % 10;\n if(mod != 0) {\n c -= 1;\n }\n else c /= 10;\n }\n println(c)\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3b38f1e144dd4cc097aa6390a43c9806", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLine()!!.toLong()\n var k = readLine()!!.toLong()\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": "c4955611b3f46422ae2165d9d5d91a92", "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\n}\n\nfun main() {\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 = CodeForceIncorrectMinus.execute(n, k)\n\n println(\"result=$result\")\n\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "446761f6c33236e0e95814ede24e955c", "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 num=$num 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": "a7db8e61670454244d65703ae28ce1ad", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import jdk.nashorn.internal.objects.Global.print\nimport 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": "d20b8cf56537eeb6dc90d556c35c15f4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "object WrongSubtraction {\n @JvmStatic\n fun main(vararg args: String){\n val x = wrongSub(512, 4)\n println(x)\n }\n\n fun wrongSub(n: Int, times: Int): Int {\n var total = n;\n for(i in 0 until times){\n if(total % 10 == 0){\n total /= 10\n }else{\n total -= 1\n }\n }\n return total\n }\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "84cf15d5ab204c89bd8e53c5f0e2ca4e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.text.*\nclass Main {\n internal var IINF = 1e18.toLong()\n internal var mod = 1e9.toLong() + 7\n internal val INF = 1e9.toInt()\n internal val MX = 2e6.toInt() + 5\n internal var df = DecimalFormat(\"0.00000000\")\n internal var PI = 3.141592653589793238462643383279502884197169399\n internal var eps = 1e-6\n internal var `in`:FastReader\n internal var out:PrintWriter\n //SOLUTION BEGIN\n //Into the Hardware Mode\n @Throws(Exception::class)\n internal fun pre() {}\n @Throws(Exception::class)\n internal fun solve(TC:Int) {\n val n = nl()\n val k = nl()\n for (i in 0 until k)\n {\n if (n % 10 == 0L)\n n = n / 10\n else\n n--\n }\n pn(n)\n }\n //SOLUTION END\n @Throws(Exception::class)\n internal fun hold(b:Boolean) {\n if (!b) throw Exception(\"Hold right there, Sparky!\")\n }\n internal fun exit(b:Boolean) {\n if (!b) System.exit(0)\n }\n @Throws(Exception::class)\n internal fun run() {\n if (fileIO)\n {\n `in` = FastReader(\"input.txt\")\n out = PrintWriter(\"output.txt\")\n }\n else\n {\n `in` = FastReader()\n out = PrintWriter(System.out)\n }\n //Solution Credits: Taranpreet Singh\n val T = if ((multipleTC)) ni() else 1\n pre()\n for (t in 1..T) solve(t)\n out.flush()\n out.close()\n }\n internal fun digit(s:Long):Int {\n val ans = 0\n while (s > 0) {\n s /= 10\n ans++\n }\n return ans\n }\n internal fun gcd(a:Long, b:Long):Long {\n return if ((b == 0L)) a else gcd(b, a % b)\n }\n internal fun gcd(a:Int, b:Int):Int {\n return if ((b == 0)) a else gcd(b, a % b)\n }\n internal fun bit(n:Long):Int {\n return if ((n == 0L)) 0 else (1 + bit(n and (n - 1)))\n }\n internal fun p(o:Any) {\n out.print(o)\n }\n internal fun pn(o:Any) {\n out.println(o)\n }\n internal fun pni(o:Any) {\n out.println(o)\n out.flush()\n }\n @Throws(Exception::class)\n internal fun n():String {\n return `in`.next()\n }\n @Throws(Exception::class)\n internal fun nln():String {\n return `in`.nextLine()\n }\n @Throws(Exception::class)\n internal fun ni():Int {\n return Integer.parseInt(`in`.next())\n }\n @Throws(Exception::class)\n internal fun nl():Long {\n return java.lang.Long.parseLong(`in`.next())\n }\n @Throws(Exception::class)\n internal fun nd():Double {\n return java.lang.Double.parseDouble(`in`.next())\n }\n internal inner class FastReader {\n var br:BufferedReader\n var st:StringTokenizer\n constructor() {\n br = BufferedReader(InputStreamReader(System.`in`))\n }\n @Throws(Exception::class)\n constructor(s:String) {\n br = BufferedReader(FileReader(s))\n }\n @Throws(Exception::class)\n fun next():String {\n while (st == null || !st.hasMoreElements())\n {\n try\n {\n st = StringTokenizer(br.readLine())\n }\n catch (e:IOException) {\n throw Exception(e.toString())\n }\n }\n return st.nextToken()\n }\n @Throws(Exception::class)\n fun nextLine():String {\n val str = \"\"\n try\n {\n str = br.readLine()\n }\n catch (e:IOException) {\n throw Exception(e.toString())\n }\n return str\n }\n }\n companion object {\n internal var multipleTC = false\n internal var memory = false\n internal var fileIO = false\n @Throws(Exception::class)\n @JvmStatic fun main(args:Array) {\n if (memory)\n Thread(null!!, object:Runnable {\n public override fun run() {\n try\n {\n Main().run()\n }\n catch (e:Exception) {\n e.printStackTrace()\n }\n }\n }, \"1\", (1 shl 28).toLong()).start()\n else\n Main().run()\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "afc6987f8948af1410489afefaec6112", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(): Unit {\n var (n, k) = readLine()!!.split(\" \")!!.let { Pair(it[0], it[1]) }\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": "a1ced191e7f2d90dbab72767b9b7e50e", "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": "97569a52abe8ae94a41d441e97d95168", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tval (a, b) = readLine()!!.split(' ').map(String::toInt)\n\tprintln(a + b)\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": "31796f694e7f6f13aa2b501391a7442e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package practice2.a\n\nimport utils.Utils\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": "ac1fb7d265470d63a5d44bf553ec1851", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.rizkimaulana.kotlin.heroes\n\nfun main(args: Array) {\n var number = args.first()\n val deductor = args[1].toInt()\n\n for (x in deductor downTo 1) {\n if (number[number.length - 1].toInt() - '0'.toInt() > 0 ) {\n number = (number.toInt() - 1).toString()\n } else {\n if (number.isNotEmpty())\n number = number.dropLast(1)\n else\n number = \"0\"\n }\n }\n println(number)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "00e9231047f884f21a9e9cf84ee1af79", "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\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": "2ac5d2cb16b67d23e4f9b532b815364f", "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 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 val wrongSubtraction = WrongSubtraction()\n println(wrongSubtraction.subtract(args[0].toInt(), args[1].toInt()))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d737fa55953386ac82bb101a372f69e8", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nobject Main {\n\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var k = sc.nextInt()\n\n while (k > 0) {\n if (n % 10 == 0) {\n n /= 10\n } else {\n n--\n }\n k--\n }\n\n println(n)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2fb629cf74ddf471e50a6904862d8a88", "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.InputMismatchException\n/**\n* Built using CHelper plug-in\n* Actual solution is at the top\n*/\nobject Main {\n @JvmStatic fun 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 = AWrongSubtraction()\n solver.solve(1, `in`, out)\n out.close()\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 while (k-- > 0)\n {\n // out.println(n + \" \" + (n % 10));\n if ((n % 10) == 0)\n {\n n /= 10\n }\n else\n {\n n--\n }\n }\n out.println(n)\n }\n }\n internal class InputReader(stream:InputStream) {\n private val stream:InputStream\n private val buf = ByteArray(1024)\n private val curChar:Int = 0\n private val numChars:Int = 0\n private val filter:InputReader.SpaceCharFilter\n init{\n this.stream = stream\n }\n fun read():Int {\n if (numChars == -1)\n {\n throw InputMismatchException()\n }\n if (curChar >= numChars)\n {\n curChar = 0\n try\n {\n numChars = stream.read(buf)\n }\n catch (e:IOException) {\n throw InputMismatchException()\n }\n if (numChars <= 0)\n {\n return -1\n }\n }\n return buf[curChar++].toInt()\n }\n fun nextInt():Int {\n val c = read()\n while (isSpaceChar(c))\n {\n c = read()\n }\n val sgn = 1\n if (c == '-'.toInt())\n {\n sgn = -1\n c = read()\n }\n val res = 0\n do\n {\n if (c < '0'.toInt() || c > '9'.toInt())\n {\n throw InputMismatchException()\n }\n res *= 10\n res += c - '0'.toInt()\n c = read()\n }\n while (!isSpaceChar(c))\n return res * sgn\n }\n fun isSpaceChar(c:Int):Boolean {\n if (filter != null)\n {\n return filter.isSpaceChar(c)\n }\n return isWhitespace(c)\n }\n interface SpaceCharFilter {\n fun isSpaceChar(ch:Int):Boolean\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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bc97d624060b64bb4ffb7ac5dcc53885", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class SubtractionChallenger(val n: Int, val k: Int) {\n \n fun main(args : Array) {\n var result = n\n repeat((1..k).count()) {\n if (result % 10 == 0)\n result /= 10\n else\n result--\n }\n\n print(result)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "85cfa1e147680206faa7634b2a1cb431", "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 */\nobject Main {\n fun 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\n internal class TaskA {\n fun 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}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "767613fef18e044506fea6b73a1eb147", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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}\nanswer\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e708bafb798d952381016fa76bb1a0e4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar (n, k) = readLine()!!.split(' ').map(toInt)\n\tfor (i in 1..k)\n\t{\n\t\tif (n%10 == 0) n /= 10 else n--\n\t}\n\tprintln(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "971ce6afad96b1e13ae565de5f105655", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n \tval(n,k)=readLine()!!.split(' ').map(String::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": "cccd0190398d0b9482e9ab0234b7cdf5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package example.myapp\n\nfun main(args: Array) {\n wrongSubstraction(args[0].toInt(), args[1].toInt())\n}\n\nfun wrongSubstraction(number: Int, steps: Int) {\n if (steps == 0) {\n println(number)\n return\n }\n if (number % 10 != 0) {\n wrongSubstraction(number - 1, steps - 1)\n } else {\n wrongSubstraction(number / 10, steps - 1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "abc4de0c325519826a64c8fcf728f140", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n var (n, k) = readLine()!!!.split(\" \").map { it.toInt() }\n \n while (k > 0)\n {\n if (n % 10 == 0) n /= 10\n else n -= 1\n }\n \n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b6fa025ec78d6d8e5075e600daed0da0", "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 (x 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": "a6b7dcbca2ef0f660a5e9e433de5d7ab", "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.InputMismatchException\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakhar17252\n */\nobject Main {\n fun main() {\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(`in`, out)\n out.close()\n }\n\n internal class AWrongSubtraction {\n fun solve(`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 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": "7c5aa6e82f372897673cabddfedeffd1", "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 val number = Integer.parseInt(str[0])\n val k = Integer.parseInt(str[1])\n while (k > 0)\n {\n val 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": "a2a54142973fc86d3d90ed832dea2c96", "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:Long = reader.nextlong()\n var integer1:Long = reader.nextlong()\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": "7639ef5c1a24b60dd64d09b3a4c5ba75", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package training\n\n\nfun main(args :Array) {\n print(wrongSubstraction(args))\n}\n\nfun wrongSubstraction(args: Array): String {\n val split = args[0].split(\" \")\n var number = split[0]\n var times = Integer.valueOf(split[1])\n\n while (times > 0) {\n number = wrongSubstractionNumber(number, times)\n times--\n }\n return number\n}\n\nfun wrongSubstractionNumber(number: String, times: Int): String {\n if (number.last() == '0') {\n return number.substring(0, number.length - 1)\n }\n return (Integer.valueOf(number) - 1).toString()\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0a3417083d7fc04d89190e79eef35d0d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nimport java.util.Scanner\nfun main() {\n val reader = Scanner(System.`in`)\n var num:Long = reader.nextLong()\n var counter:Long=reader.nextLong()\n while(counter!=0&&(num/10)!=0){\n counter--;\n if (num % 10 == 0) {\n while (num % 10 == 0) {\n num = num / 10\n }\n } else {\n num--\n }\n }\n println(num)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1495ce0cfbdcfde85c0125061439aa43", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun readln() = readLine()!!\nfun readint() = readln().toInt() \nfun readlong() = readln().toLong() \nfun readdouble() = readln().toDouble()\nfun readstrings() = readln().split(\" \")\nfun readints() = readstrings().map { it.toInt() } \nfun readlongs() = readstrings().map { it.toLong() } \nfun readdoubles() = readstrings().map { it.toDouble() }\n\nfun main() {\n\tvar n=readint()\n val st = \"kotlin\"\n var g = Array>(36){mutableSetOf()}\n for(i in 0 until n){\n var s=readln()\n var x=0\n var y=0\n while(st[x]!=s[0])x++\n while(st[y]!=s[s.length-1])y++\n \ty=(y+1)%6\n g[x*6+y].add(i+1)\n }\n\tvar now=0\n var ans=IntArray(n)\n for(id in 0 until n) {\n var pos=now*6+now\n if(g[pos].size!=0){\n var z=g[pos].first()\n ans[id]=z\n g[pos].remove(z)\n now=i\n continue\n }\n for(i in 0..5){\n pos=now*6+i\n if(g[pos].size!=0){\n var z=g[pos].first()\n ans[id]=z\n g[pos].remove(z)\n now=i\n break\n }\n assert(i!=5)\n }\n }\n println(ans.joinToString(\" \"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f82fa8157a2f3d5de90e4689b20779f2", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\nimport java.lang.Long.parseLong\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 F {\n\n internal var edges: Array>? = 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 val n = scanInt()\n edges = Array(6) { Array(6) { null } }\n for (i in 0..5) {\n for (j in 0..5) {\n edges!![i][j] = IntList()\n }\n }\n for (i in 0 until n) {\n val s = scanString()\n val a = \"kotlin\".indexOf(s[0])\n val b = \"nkotli\".indexOf(s[s.length - 1])\n edges!![a][b]!!.push(i)\n }\n dfs(0)\n }\n\n internal fun dfs(cur: Int) {\n for (next in 0..5) {\n while (edges!![next][cur]!!.size > 0) {\n val i = edges!![next][cur]!!.pop()\n dfs(next)\n out!!.print((i + 1).toString() + \" \")\n }\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}\n\nfun main(args: Array) {\n F.main(args)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e3fa29fd1302581dc71df297985371dd", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\nimport java.lang.Long.parseLong\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 F {\n\n internal var edges: Array>? = 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 val n = scanInt()\n edges = Array(6) { arrayOfNulls(6) }\n for (i in 0..5) {\n for (j in 0..5) {\n edges!![i][j] = IntList()\n }\n }\n for (i in 0 until n) {\n val s = scanString()\n val a = \"kotlin\".indexOf(s[0])\n val b = \"nkotli\".indexOf(s[s.length - 1])\n edges!![a][b]!!.push(i)\n }\n dfs(0)\n }\n\n internal fun dfs(cur: Int) {\n for (next in 0..5) {\n while (edges!![next][cur]!!.size > 0) {\n val i = edges!![next][cur]!!.pop()\n dfs(next)\n out!!.print((i + 1).toString() + \" \")\n }\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}\n\nfun main(args: Array) {\n F.main(args)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "938c1e1bf629e3313256256ad869684a", "src_uid": "a853ca8432d7b8966b12fc85c28ab979", "difficulty": 2300.0} {"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..n-1){\n a=reader.nextInt()\n println(\"${max(floor((a-1)/2), 0)}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d69d5df48ba0c58187f9a8b7e0bd793", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main(args: Array) {\n \n val read = Scanner(System.`in`)\n val testNum = read.nextInt()\n for(i in 1..testNum) {\n var firstNum = read.nextInt()\n var secondNum = firstnum - 1\n var sum = secondNum / 2\n println(\"$sum\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bf686812d5af4e1b94e849a9b85b6725", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "package com.example.sliderexperiment\n\nimport kotlin.math.pow\n\nfun 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\tnoOfPossibilities = candies / 2\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": "48309d06777ce53663b64fc8d33d3295", "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 (item : Int in t) {\n var n = read.nextInt()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "273b6b5a80d154ab3d244a6266ea81e4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun contest1432problemB() {\n val cases = readLine()!!.toInt()\n for (i in 0 until cases) {\n val n = readLine()!!.toInt()\n println(ceil(n / 2.0).toInt() - 1)\n }\n}\n\nfun main() {\n contest1432problemB()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "dfd3be95ab5edb979af31b588f3b28f5", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n var l: String? = null\n while (run {l = readLine(); l} != null)\n println((l+1)/2)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9fee97a6af9a86c6421b9734fadbb126", "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 = sc.nextInt()\n var n: Int\n var x: Int\n \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": "cec9608257bc6de0807029d31a29ef6a", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.jvm.JvmStatic\n\nobject a {\n @JvmStatic\n fun main(args: Array) {\n val sc = Scanner(System.`in`)\n var t = sc.nextInt()\n while (t-- > 0) {\n val a = sc.nextInt()\n var count = 0\n var i = 0.0\n i = Math.ceil(a / 2.toDouble())\n while (i < a) {\n if (i > a - i) count++\n i++\n }\n println(count)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2ad606c53d39d0ff20ad33dc297ab747", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "// 06.11.2020\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 t = readInt ()\n for ( i in 0 until t )\n {\n val n = readInts ()\n var x : Int = (n + 1) / 2\n println (x);\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4cfb64a346b869f9e26b7232a77860dc", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.untl.*\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\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": "b78157a8c3e847f58e0ec54d84bfcd42", "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": "22f13890e95dff926d730ddc1dd1a128", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject B {\n @JvmStatic\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": "e0f87e21a120394beafd3724e3174752", "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 main() = for(x in 1..readInt()) println((readInt() - 1) / 2)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6d37eccb390086714afb40f36d8ecb2c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Candiess {\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": "9e13962a9940a43ba6a71a6e45e3b15b", "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(args: Array) {\n var t = readInt()\n while (t--) {\n var n = readInt();\n println((n-1)/2);\n }\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b465aa224f161470e3be988f351ee76a", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun readLn()=readLine()!!\nprivate fun readInt()=readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\nfun readLongs()=readStrings().map{it.toLong()}\nprivate fun lolilover() = println()\nfun max(x : Int, y : Int) : Int{\n if(x > y)return x\n else return y\n}\n\nfun min(x : Long, y : Long) : Long{\n if(x < y)return x\n else return y\n}\n\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val Q = readLine()!!.toLong()\n for (i in 1..Q){\n val(a) = readLine()!!.toLong()\n println((a-1)/2)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5c415e89c24b0faf19e6c4bc8e8fa359", "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 b:int=read.nextInt()\n while(b>0){\n var a:Int=read.nextInt()\n \n println(a/2);\n \n \n \n b--;\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "76f5c77f3054bb720a54660278cfa06c", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun 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": "8ae39055cf39b0084ea1a3aa0cc28ad9", "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 main() {\n val i = readInt()\n var results = mutableListOf()\n for(x in 1..i) {\n val g = readInt() - 1\n results.add(g / 2)\n }\n print(results)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e86ad7c0bd3ee77ac38a2936205957b4", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readline()\n for (i in t) {\n val n = readline()\n println((n-1)/2)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0bf3432caf91673e7410dea6fd75af6b", "src_uid": "b69170c8377623beb66db4706a02ffc6", "difficulty": null} {"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 m = input.nextLong()\n val n = input.nextLong()\n val a = input.nextLong()\n\n if (m % a == 0L && n % a == 0L) {\n output.print(m / a * n / a)\n return\n }\n\n var rowCount = 0L\n var collCount = 0L\n var sum = 0L\n\n while (sum < n || sum < m) {\n if (sum < m) rowCount++\n if (sum < n) collCount++\n sum += a\n }\n\n output.print(rowCount * collCount)\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 nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7c0879c634df2818969279031e857cd2", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n val (m,n,a)= scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var x = (m/a.toDouble())\n var y = (n/a.toDouble())\n var ans = Math.ceil(x) * Math.ceil(y)\n println(ans.toLong)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4a695c6e6533270877663efe8de87ca0", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val inputList: List = readInts()\n var l = inputList[0]/ inputList[2]\n var w = inputList[1]/ inputList[2]\n\n if(inputList[0] % inputList[2] != 0) l++\n if(inputList[1] % inputList[2] != 0) w++\n\n print(l * w)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6bb10fe0986494658061b2dd54536448", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val i = readLine()!!.split(\" \").map{ it.toInt() }\n val t1:Long = i[0] % i[2]\n val t2:Long = i[1] % i[2]\n \n var r:Long = ((i[0] + t1) / i[2]) * ((i[1] + t2) / i[2])\n if(r < 1) r = 1\n println(r)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5dc2ddd72d05fd95ac01758414d6c13a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n \nfun main(args: Array) {\n val input = Scanner(System.`in`)\n var n:Long = input.nextInt()\n var m:Long = input.nextInt()\n var a:Long = input.nextInt()\n var x:Long = n/a\n var y:Long = m/a\n if(x * a < n){\n \tx++\n }\n if(y * a < m){\n \ty++\n }\n println(x*y)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "af9f7811f01622994ce406866facf4f8", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val input = Scanner(System.`in`)\n\n val n = input.nextInt()\n val m = input.nextInt()\n val a = input.nextInt()\n\n var result = (n downTo 1 step a).count()\n if (m > n) {\n for (i in m downTo n step a) {\n result++\n }\n }\n println(result)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a262ea60f09aa74ec27731fe30ee2bc7", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun 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", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f33151a607576d921ac97f312d8df1b5", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package com.rozag.codeforces\n\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n\n val n = scanner.nextInt()\n val m = scanner.nextInt()\n val a = scanner.nextInt()\n\n print(Math.ceil(n.toDouble() / a).toInt() * Math.ceil(m.toDouble() / a).toInt())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e3d25b40e535f04d3dee90bc434614dd", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextLong()\n val b = sc.nextLong()\n val c = sc.nextLong() \n \n var x:Long = a / c\n var y:Long = b / c\n if(a%c !=0) x += 1L\n if(b%c !=0) y += 1L\n print(x * y)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "948632442fd6b0274a560cbcc7e6adcc", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package set_1\n//import java.util.*;\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 readInts(): List {\n val words: List = readWords()\n var lst: ArrayList = ArrayList()\n for (word in words) {\n try {\n var v: Int = word.toInt()\n lst.add(v)\n }\n catch(nfe: NumberFormatException) {\n println(\"invalid word: \" + word)\n }\n }\n return lst\n}\n\nfun main(args: Array) {\n val lst: List = readInts()\n val n = lst[0]\n val m = lst[1]\n val a = lst[2]\n val width = (n-1) / a + 1\n val height = (m-1) / a + 1\n val num = width * height;\n println(num)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "249ae8717175e72f700878ec07fa9a81", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt() \n \n var x:Long = a / c\n var y:Long = b / c\n if(a%c !=0) x += 1L\n if(b%c !=0) y += 1L\n print(x * y)\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3d8868af4e4613921a16d8e0b1a94786", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package warmup\n\nimport kotlin.math.min\n\n\n// https://codeforces.com/contest/1171/problem/B\n\n\nfun readInts() : List = readLine()?.split(\" \")?.map { it.toInt() }?.toList() ?: emptyList()\n\nfun s1() {\n val (y, b, r) = readInts()\n when {\n r in (y..b) || (y in r..b) || b in ((r+1) .. (y-1)) -> {\n println(if (r > 1) r + (r-1) + (r-2) else r)\n }\n b in (y + 1)..r -> println(y + (y+1) + (y+2))\n else -> println(b + (b+1) + (b-1))\n }\n}\n\nfun main(args: Array) {\n\n //while (true) { s1() }\n s1()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6e20544420a2b5147596f045fbc69484", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val (yellow, blue, red) = readLine()!!.split(' ').map { it.toInt() }\nval maxYellow = maxOf(yellow, blue - 1, red - 2)\nprint(maxYellow * 3 + 3)", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fabd9ba63d7c37b2ee2070b97e084805", "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": "d63ffaefcb8767ea6c6cad87ce3b11c5", "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].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 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": "2ffe9c491f34f08adce2ba51a55389b8", "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 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": "919697ba861f0490d798a9462d337fec", "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 mini = min(mini, m - i)\n }\n mini += 1\n println(mini * 3)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c3ab4cc309e1c85eed3942725637251e", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main( args : Array) {\n\n// val str = \"8 13 9\"\n// val str =\"13 3 6\"\n val str =readln()\n val ar = str.split(\" \")\n val y=ar[0].toInt()\n val b=ar[1].toInt()\n val r=ar[2].toInt()\n\n if (r<=y+2 && r<=b+1) {\n println(r*3-3)\n }\n\n if (b<=r-1 && b<=y+1) {\n println(b*3)\n }\n\n if (y<=b-1 && y<=r+21) {\n println(y*3+3)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c1ddeb09fdadd8d679cc5bda259006e2", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//package b\n\nimport a.nline\nimport java.io.PrintWriter\nimport java.util.*\n\nfun solve() {\n val (y, b, r) = na()\n val u = Math.min(Math.min(y+1, b), r-1)\n out.println(u*3)\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": "43e2a9458db665748da2ecdb019ad8f9", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "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 }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a215accced5b7a9ad7c8752b42c1d191", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "#include\n#include\nusing namespace std;\nint main(){\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\tint y,b,r;\n\tcin>>y>>b>>r;\n\tint blues=min(y+1,b);\n\tint reds=min(blues+1,r);\n\tcout<<(reds-1)*3;\n return 0;\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f4aba1a502a8abe161c89a59928a4a2c", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n var (y, b, r) = readLine()!!.split(' ')\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": "03b5bde85af2dc491a901e193bcfbe98", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "class Main {\n\n fun main(): Int {\n val yellow = readLine()!!.toInt()\n val blue = readLine()!!.toInt()\n val red = readLine()!!.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": "f48ea10d19e3ec93fe9ee165caa3dcd3", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array): int {\n val inputNums = args[0].split(\" \")\n var min = 1\n inputNums.forEachIndexed { index, s ->\n if (index + s.toInt() > min) {\n min = s.toInt()\n }\n }\n return (min+1)*3\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "72ad135745b91771805cdfdfb07efea9", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.utils.Scanner\n\n fun main(args:Array) {\n var sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var m = sc.nextInt()\n var 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": "d1f994666259d9ecc8a13f25084651cc", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun ans(): String {\n val arr = arrayOf(4, 7, 47, 74, 447, 474, 477, 774, 747, 744)\n val num = readLine()\n val num1: Int? = num?.toInt()\n\n arr.forEach {i->\n\n if (num1 != null) {\n \n if (num1 == i || num1 % i == 0) {\n return \"YES;\n }\n }\n }\nreturn \"NO;\n}\n\nfun main() {\n\nprint(ans())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e3c95f4d08e69d6c6ccc580845df48c9", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (_, place) = readLine()!!.split(\" \").map { it.toInt() }\n val scores = readLine().split(\" \").map { it.toInt() }\n println(solution(scores, place))\n}\n\nfun solution(scores: List, place: Int): Int {\n val scoreAtPlace = scores[place]\n var num = 0\n for (score in scores) {\n if (score < scoreAtPlace || score == 0) {\n return num\n }\n num++\n }\n return num\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8a5094ae0f42b3fc1dd1088829caaa97", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val a = readLine()!!toInt()\n println(if (a % 4 == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c1736d10558e6364eb329df30f044788", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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": "03599bdf6480c5250467dc01c4c38d83", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fn 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": "8241da5ecd9bd09d18485a4c5b5024a9", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(){\n var w:Int = 5\n if(w % 2 == 0 ){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "07e86ef80b43d2b38968c5bb6e19b03b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var n = readLn().toInt()\n if(n%2 == 0 && n != 2)\n println(\"YES\")\n else print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b443decc53cd33b0ba5d0b6a6917fd48", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val 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": "aa375ae61cfa27759a5d2e6d31c33fe8", "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": "ef22cc564966ca8039e7a578293e1e6c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "val x = input() \nif (x % 2 == 0) \n print(\"YES\")\nelse \n print(\"NO\")", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "615d6ce23424a9d4b0c06df913ad611a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun checkWatermelon() {\n val x = input()\n if (x % 2 == 0) \n print(\"YES\")\n else \n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "72b6caa014f8ad7c56d6b9fef7359a1e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.com.tasks.archive.task4A\n\nfun main() {\n val weight = readLine()!!.toInt()\n val lastBit = weight and 1\n print(if (weight > 2 && lastBit == 0) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "adc49f0ca8488a8eb0cd7e456cb0ec28", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "var w\nif (w/2 ==0){\nprintln(\"YES\")\n}else {\nprintln(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3cde68a02993149501093cbf809f2f94", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n var n = readLine().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": "734c3455c6cdf0a5a3dd28e5c4959a11", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun(w){\n return w\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "bb35a8c0995108ad2b3c767571ecfafa", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.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\nobject Main {\n private var br: BufferedReader? = null\n private var st: StringTokenizer? = null\n private var pw: PrintWriter? = null\n\n internal var ret = 1e18.toLong()\n\n @Throws(IOException::class)\n fun main(args: Array) {\n br = BufferedReader(InputStreamReader(System.`in`))\n pw = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))\n val qq = 1\n //int qq = Integer.MAX_VALUE;\n //int qq = readInt();\n\n /*\nreminders:\narrays of objects are problematic, prefer ArrayList instead\nglobal things must be initialized to something (explicit null)\n\t\t */\n for (casenum in 1..qq) {\n val n = readInt()\n val m = readInt()\n val k = readInt()\n val l = IntArray(n)\n val prefSum = LongArray(n + 1)\n for (i in 0 until n) {\n l[i] = readInt()\n }\n Arrays.sort(l)\n for (i in 0 until n) {\n prefSum[i + 1] = prefSum[i] + l[i]\n }\n var i = 0\n while (i + m <= n) {\n solve(l, prefSum, k, i, i + m)\n i++\n }\n pw!!.println(ret)\n }\n exitImmediately()\n }\n\n fun solve(l: IntArray, prefSum: LongArray, inc: Int, left: Int, right: Int) {\n // [left, right)\n var innerL = left\n var innerR = Math.min(l.size - 1, (left + right) / 2)\n while (innerL < innerR) {\n val midmid = (innerL + innerR + 1) / 2\n val decisionPoint = l[midmid].toLong()\n val lower = (midmid - left) * decisionPoint - (prefSum[midmid] - prefSum[left])\n if (lower <= inc) {\n innerL = midmid\n } else {\n innerR = midmid - 1\n }\n }\n var mid = l[innerL].toLong()\n run {\n val lower = (innerL - left) * mid - (prefSum[innerL] - prefSum[left])\n mid += (inc - lower) / (innerL - left + 1)\n mid = Math.min(mid, l[innerL + 1].toLong())\n }\n mid = Math.min(mid, l[(left + right) / 2].toLong())\n val lower = (innerL - left) * mid - (prefSum[innerL] - prefSum[left])\n val higher = prefSum[right] - prefSum[innerL] - (right - innerL) * mid\n if (lower > inc) {\n throw RuntimeException(\"WTF\")\n }\n ret = Math.min(ret, lower + higher)\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 st = StringTokenizer(readLine()!!.trim { it <= ' ' })\n }\n return st!!.nextToken()\n }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "825e174b08f0b089b006437cfa228c80", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nimport kotlin.math.*\nvar reader = Scanner(System.`in`)\n\nconst val MAXN: Int = 200007\n\nfun get_sum(l: Int, r: Int): Long{\n if(l == 0){\n return prefix[r]\n }\n return prefix[r] - prefix[l - 1]\n}\n\nfun get_median(l: Int, r: Int): Pair{\n var first: Long\n if((l + r) % 2 == 1){\n first = (a[(l + r) / 2] + a[(l + r + 1) / 2]) / 2\n }\n else{\n first = a[(l + r) / 2]\n }\n\n return Pair(first, (l + r) / 2)\n}\n\nfun get_poss(l: Int, r: Int, k: Long): Pair{\n var l2: Int = l\n var r2: Int = r\n\n while(l2 != r2){\n var mid: Int = (l2 + r2 + 1) / 2\n var up: Long = (mid - l + 1) * a[mid] - get_sum(l, mid)\n\n if(up <= k){\n l2 = mid\n }\n else{\n r2 = mid - 1\n }\n }\n\n var up: Long = (l2 - l + 1) * a[l2] - get_sum(l, l2)\n var ret: Long = a[l2] + (k - up) / (l2 - l + 1)\n ret = min(ret, a[min(l2 + 1, r)])\n\n return Pair(ret, l2)\n}\n\nfun calc_score(l: Int, r: Int, x: Long, idx: Int): Long{\n var lvalue: Long = (idx - l + 1) * x - get_sum(l, idx)\n var rvalue: Long = get_sum(idx + 1, r) - (r - idx) * x\n\n return lvalue + rvalue\n}\n\nfun main(){\n var n: Int = reader.nextInt()\n var m: Int = reader.nextInt()\n var k: Long = reader.nextLong()\n\n var a: LongArray = LongArray(n)\n var prefix: LongArray = LongArray(n)\n\n for(i: Int in 0 until n){\n a[i] = reader.nextLong()\n }\n a = a.sorted().toLongArray()\n\n prefix[0] = a[0]\n for(i: Int in 1 until n){\n prefix[i] = a[i] + prefix[i - 1]\n }\n\n var ans: Long = 1\n for(i in 0 until 18){\n ans *= 10\n }\n\n for(i: Int in m - 1 until n){\n var med: Pair = get_median(i - m + 1, i)\n var poss: Pair = get_poss(i - m + 1, i, k)\n\n if(poss.first < med.first){\n med = poss\n }\n\n ans = min(ans, calc_score(i - m + 1, i, med.first, med.second))\n }\n\n println(ans)\n\n return\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "93578cdb26414bfb7143f7cd2d85de26", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n val bi = BufferedReader(InputStreamReader(System.`in`));\n val strs = bi.readLine().split(\" \")\n val n = Integer.parseInt(strs[0])\n val m = Integer.parseInt(strs[1])\n val k = Integer.parseInt(strs[2])\n val line = bi.readLine()\n val a = IntArray(n, {it -> 0})\n var it = 0\n for (numStr in line.split(\" \")) {\n a[it] = Integer.parseInt(numStr)\n it += 1\n }\n a.sort()\n val sums = LongArray(n + 1, {it -> 0})\n for (i in 1..n)\n sums[i] = sums[i - 1] + a[i - 1]\n val bb = LongArray(n, {it -> 0})\n for (i in 0..(n - 1)) {\n bb[i] = a[i].toLong() * i - sums[i]\n }\n var ans = 1000000000000000000\n var ind = 0\n for (i in 0..(n - m)) {\n val ind = i + (m - 1) / 2\n val pp = k - sums[i]\n if (bb[ind] - a[ind].toLong() * i <= pp) {\n val mm = ind\n ans = minOf(ans, a[mm].toLong() * (mm - i).toLong() - (sums[mm] - sums[i]) + (sums[i + m] - sums[mm + 1]) - a[mm].toLong() * (i + m - mm - 1).toLong()); \n continue \n }\n while (bb[ind] - a[ind].toLong() * i <= pp) {\n ind += 1\n }\n val l = ind\n val kk = a[l].toLong() * (l - i).toLong() - (sums[l] - sums[i])\n val value = a[l] + (k - kk) / (l - i + 1)\n val rem = (l - i + 1).toLong()\n ans = minOf(ans, value * rem - (sums[l + 1] - sums[i]) + (sums[i + m] - sums[l + 1]) - value.toLong() * (m - rem).toLong()); \n }\n val log = BufferedWriter(OutputStreamWriter(System.`out`));\n log.write(ans.toString() + \"\\n\")\n log.flush();\n}\n ", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7e8ea5b6cda65c214611c7e356ed0192", "src_uid": "9c3abb6508c16d906d16f70acaf155ff", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val reader = BufferedReader(InputStreamReader(System.`in`))\n reader.use {\n val el = it.readLine()\n print(el.capitalize())\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ddba1fa11e55d546857e1774be944a44", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val stringInput = readLine()\n var t:Int = stringInput.toInt()\n var result = 0\n var temp: Int;\n while(t>0)\n {\n var stringInput1 = readLine()\n \tvar n:Int = stringInput1.toInt()\n if(n in 2..7)\n println(\"1\");\n if(n > 7)\n {\n temp = n%2\n if(temp > 0)\n {\n \tn = n-3;\n result = n/2;\n result++;\n }\n if(temp < 1)\n {\n result = n/2;\n }\n println(result)\n }\n t --;\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6f541998a7db88154d56773c9b78d5e7", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n val n = readLine()!!.toInt()\n n /= 2\n println(n)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "34aa69754264d6344397b15fe65f4e51", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "var t = 0\nt = Integer.valueOf(readLine())\nwhile(t>0){\nvar x = 0\nx = Integer.valueOf(readLine())\nvar num = 7\nvar cnt = 0\nwhile(x>1){\ncnt++\nx-=2\n}\nprintln(\"$cnt\")\t\nt--\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9ed455242746e75f91e6bc950f844c47", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package train\n\nfun 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\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8aecbe536366d39e34712a9824093ce0", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "var 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": "307e52a89f008a9a086af2d6d924a953", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val t = nextInt()\n for (i in 0 until t){\n val x = nextInt()\n println(Math.floor(x/2))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8a7c318792cea9490abfe57b6e40391f", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " val n = Integer.valueOf(readLine()!!)\n \n repeat(n) {\n val x = Integer.valueOf(readLine()!!)\n println(x / 7)\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "13ab5fcc223f9a8deb77315d7133a473", "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 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": "d12629e4df41c37a949a8fc1c533810c", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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(\"input: $number - output: ${rolls.size}\")\n return rolls\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "219076120cddc19cf980747f22d9bb57", "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 / 2)\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "140c011f4ce69236a6ba464de875e1f8", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package heroes.practice\n\nimport kotlin.random.Random\n\nfun main() {\n val numberOfQueries = readLine()!!\n\n val t: Int = numberOfQueries.toInt()\n val queries = Array(t) { readLine()!!.toInt() }\n queries.forEach { println(calculate(it, 0)) }\n}\n\nfun calculate(q: Int, n: Int): Int = if (q in 2..7) {\n n + 1\n} else {\n calculate(q - Random.nextInt(2, 7), n+1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f844f816cd9628675bb9c8f3b2dcb06a", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " main()\n\n fun main() {\n val t = readInt()\n for (i in 1..t) {\n val summ = readLine()!!.toInt()\n rekurencja(summ)\n }\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": "d1281af44cf8933f8e811f499ad40897", "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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d76a4f6fcc0042b563f757d8e4b3ab42", "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 val 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": "f58b31b5e105c98e1ed6041ccdcfbc01", "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": "947340a54677bf30ffd37c2cd3261275", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nfun main(args:Array) {\n\tval sc = Scanner(System.`in`)\n\t// PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\tint x = sc.nextInt()\n\twhile (x-- > 0)\n\t{\n\t\tval t = sc.nextInt()\n\t\tval ans:Int\n\t\tif (t % 2 == 0)\n\t\t ans = t / 2\n\t\telse\n\t\t ans = (t - 3) / 2 + 1\n\t\tprintln(ans)\n\t // out.write(ans);\n\t}\n// out.close();\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2373c60a450faa5003627aa4d0cee609", "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 /= 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": "d8ebf8ef1790d57a7de87a78f13a7738", "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 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": "a68570a3e51bd1e59f1c454b1ec1721e", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val scanner = Scanner(System.`in`)\n val t:Int = scanner.nextLine().toInt()\n for (i in 1..t) {\n val n = scanner.nextLine().toInt()\n val C = scanner.nextLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n candies(C)\n }\n}\n\nfun candies(C: MutableList) {\n var moves = 0\n var aliceTot = 0\n var bobTot = 0\n var prev = 0\n var aOrB = true\n var curr : Int\n while (C.isNotEmpty()) {\n curr = 0\n do {\n if (aOrB) {\n curr += C.removeAt(0)\n } else {\n curr += C.removeAt(C.size - 1)\n }\n } while (curr <= prev && C.isNotEmpty())\n\n if (aOrB) {\n aliceTot += curr\n } else {\n bobTot += curr\n }\n\n prev = curr\n aOrB = !aOrB\n moves++\n }\n println(\"$moves $aliceTot $bobTot\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "8d449c657f615d4a35c3fd2053ce241a", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "private fun solve(){\n val nn = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map{it.toInt()}\n var moves=0; var asum=0; var bsum=0; var prevv=0; var ll=0; var rr=nn-1;\n while (ll<=rr) {\n if(ll<=rr) {\n moves++\n var cur=0\n while (ll<=rr && cur<=prevv) cur += aa[l++]\n asum+=cur\n prevv=cur\n }\n if(ll<=rr){\n moves++\n var cur=0\n while (ll<=rr && cur<=prevv) cur += aa[rr--]\n bsum+=cur\n prevv=cur\n }\n }\n println(\"$moves $asum $bsum\")\n}\n \nfun main(){\n var T = readLine()!!.toInt()\n while(T-->0) solve()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9d4199b671a60124f01026e300d75787", "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": "839a58adbfb34ab3ede23cbdb5ca77b0", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main(){\n val scanner= Scanner(System.`in`)\n for(t:Int in 1 .. scanner.nextInt()) {\n var arr=ArrayList()\n for(i:Int in 1..scanner.nextInt()){\n arr.add(scanner.nextInt())\n }\n var lastSum=0\n var sumi=0\n var sumj=0\n var sum=0\n var turn=true\n var count=1\n while(arr.size>0){\n if(turn){\n var i = arr.removeFirst()\n sumi+=i\n sum+=i\n }else{\n var j = arr.removeLast()\n sumj+=j\n sum+=j\n }\n if(lastSum0){\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) {\n val sc = Scanner(System.`in`)\n var t = 1\n t = sc.nextInt()\n while (t-- > 0)\n {\n var n = sc.nextInt()\n var a = IntArray(n)\n for (i in 0 until n)\n {\n a[i] = sc.nextInt()\n }\n var st = 1\n var en = n - 1\n var cnt = 1\n var prev = a[0]\n var al = a[0]\n var bo = 0\n while (true)\n {\n if (cnt % 2 == 1)\n {\n var qw = 0\n while (qw <= prev && en >= st)\n {\n qw += a[en]\n en--\n }\n bo += qw\n if (qw > prev)\n {\n prev = qw\n cnt++\n }\n else\n {\n if (qw != 0)\n {\n cnt++\n }\n break\n }\n }\n else\n {\n var qw = 0\n while (qw <= prev && en >= st)\n {\n qw += a[st]\n st++\n }\n al += qw\n if (qw > prev)\n {\n prev = qw\n cnt++\n }\n else\n {\n if (qw != 0)\n {\n cnt++\n }\n break\n }\n }\n }\n println(\"$cnt $al $bo\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "51174b85b5dc1152380a6cedb9485f1d", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun readLn() = readLine()!! // string line\nfun readInt() = readLn().toInt() // single int\nfun readStrings() = readLn().split(\" \") // list of strings\nfun readInts() = readStrings().map { it.toInt() } // list of ints\n\nfun main() {\n var T = readInt()\n for (q in 1..T) {\n var N = readInt()\n var Candy = readInts()\n var A_idx = -1\n var B_idx = N\n var A_sum = 0\n var B_sum = 0\n var PrevEat = 0\n var ThisEat = 0\n var TurnWho = 0\n var TurnCnt = 0\n while (A_idx < B_idx) {\n if (ThisEat == 0) TurnCnt += 1\n if (TurnWho == 0) {\n A_idx += 1\n A_sum += Candy[A_idx]\n ThisEat += Candy[A_idx]\n } else {\n B_idx -= 1\n B_sum += Candy[B_idx]\n ThisEat += Candy[B_idx]\n }\n if (ThisEat > PrevEat) {\n PrevEat = ThisEat\n ThisEat = 0\n TurnWho = if (Turn == 0) 1 else 0\n }\n }\n print(\"$TurnCnt $A_sum $B_sum\\n\")\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "80576ad96dedef89b8d92a5c60d94e38", "src_uid": "d70ee6d3574e0f2cac3c683729e2979d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\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] = Math.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": "2b113eda381d0fbb9e4a05ac131a0f4a", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "package codeforces.kotlinheroes3\n\nprivate fun solve() {\n\tval (n, k) = readInts()\n\tval a = readInts()\n\tval b = a.sortedDescending()\n\tval toConnect = b.indices.map { b[0].toLong() - it - b[it] }.sum()\n\tval top = b[0] + maxOf(k - toConnect + n - 1, 0).toInt() / n\n\tval d = mutableMapOf()\n\tb.indices.fold(k) { toSpend, i ->\n\t\tval spend = minOf(top - i - b[i], toSpend)\n\t\td[b[i]] = spend\n\t\ttoSpend - spend\n\t}\n\tprintln(a.map { d[it] }.joinToString(\" \"))\n}\n\nfun main() = repeat(readInt()) { solve() }\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a5b57eff1444ea7d77d8a241f1ad913b", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n val br = System.`in`.bufferedReader()\n\n val times = br.readInt()\n\n repeat(times) {\n val emps = br.readInt()\n var bonus = br.readInt()\n\n val order = ArrayList>()\n val adds = IntArray(emps)\n val tots = IntArray(emps)\n val orig = IntArray(emps)\n\n repeat(emps) { pos ->\n order += br.readInt() to pos\n tots[pos] = order.last().first\n orig[pos] = order.last().first\n }\n\n order.sortBy(Pair::first)\n\n for (i in order.size - 2 downTo 0) {\n val diff = min(order[i + 1].first - order[i].first - 1, bonus)\n bonus -= diff\n adds[order[i].second] = diff\n tots[order[i].second] += diff\n\n val j = order.removeAt(i)\n order.add(i, j.first + diff to j.second)\n\n if (bonus == 0) {\n break\n }\n }\n\n if (bonus != 0) {\n val toDist = bonus / emps\n bonus %= emps\n\n for (i in order.lastIndex downTo 0) {\n adds[order[i].second] += toDist\n val j = order[i]\n order[i] = (j.first + toDist) to j.second\n tots[order[i].second] += toDist\n }\n }\n\n if (bonus != 0) {\n for (j in 0 until bonus) {\n val i = order.lastIndex - j\n order[i] = order[i].first + 1 to order[i].second\n adds[order[i].second]++\n tots[order[i].second]++\n }\n }\n\n println(adds.joinToString(\" \"))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2512e0ccd8b63d2736f91a3ca5d859de", "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": "af098138a2a7d761a6a2d75ddd25bbf1", "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) = readLongs()\n var a = readLongs()\n var v = mutableListOf>()\n for(j in 0 .. (n-1)){\n v.add(Pair(j,a[j.toInt()]))\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 val m = (l+r)/2\n var tk : Long = 0\n for(j in 0 .. (n-1)){\n tk += (m-j) - v[j.toInt()].second\n }\n if(tk >= k){\n r = m\n } else{\n l = m + 1\n }\n }\n var tk = k\n var ans = LongArray(size = n.toInt())\n for(j in 0 .. (n-1)){\n if(tk > (l-j)-v[j.toInt()].second) {\n ans[(v[j.toInt()].first).toInt()] = (l-j)-v[j.toInt()].second\n tk -= (l-j)-v[j.toInt()].second\n } else {\n ans[(v[j.toInt()].first).toInt()] = tk\n tk = 0\n }\n }\n for(j in 0 .. (n-1)){\n if(j > 0)print(\" \")\n print(ans[j.toInt()])\n }\n println(\"\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5c2454a50905ae74eabf0da502df5765", "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) = readLongs()\n var a = readLongs()\n var v = mutableListOf>()\n for(j in 0 .. (n-1)){\n v.add(Pair(j,a[j.toInt()]))\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 val m = (l+r)/2\n var tk : Long = 0\n for(j in 0 .. (n-1)){\n tk += (m-j) - v[j.toInt()].second\n }\n if(tk >= k){\n r = m\n } else{\n l = m + 1\n }\n }\n var tk = k\n var ans = LongArray(size = n.toInt())\n for(j in 0 .. (n-1)){\n if(tk > (l-j)-v[j.toInt()].second) {\n ans[v[j.toInt()].first.toInt()] = (l-j)-v[j.toInt()].second\n tk -= (l-j)-v[j.toInt()].second\n } else {\n ans[(v[j.toInt()].first).toInt()] = tk\n tk = 0\n }\n }\n for(j in 0 .. (n-1)){\n if(j > 0)print(\" \")\n print(ans[j.toInt()])\n }\n println(\"\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0ab161e3efa27b52eade173fac68b011", "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.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": "cc28a823e8853c0bc9d9f3218da66008", "src_uid": "685ecfc7293b4e762863be2e3368e576", "difficulty": null} {"lang": "Kotlin", "source_code": "fun getCharIndex(c: Char) = c.toByte().toInt() - 'a'.toByte().toInt()\n\nfun main() {\n val n: Int = readLine()!!.toInt()\n if (n == 1) {\n println(\"Yes\")\n } else {\n val s: Array = readLine()!!.toCharArray()\n var f: Array = Array(26){0}\n s.forEach { c -> ++f[getCharIndex(c)] }\n var possible: Boolean = false\n f.forEach { fi -> possible = possible || (f[i] > 1) }\n if (possible) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "76aa35926d80175f508f890ca477d788", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package A\n\nimport java.util.*\n\n/**\n * Created by nuts on 2/8/17.\n */\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val a = input.nextInt()\n val b = input.nextInt()\n var j: Int = 0\n for(i in 1..a) {\n if(a % i == 0) {\n if(++j == b) {\n print(i)\n return\n }\n }\n }\n print(-1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5b08aa4c2599b51bd3a4b8aa2e90b4bc", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main()\n val x = readLine()!!.toLowerCase()\n println(x.replaceAll(\"[aoyeui]+\".toRegex(), \".\"))", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "386883e0032498906d110aed35c6756b", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.lang.StringBuilder\n\nobject TaskManager {\n\n val vowels: String = \"AOYEUI\"\n\n fun stringTask(input: String) : String {\n\n val result: StringBuilder = StringBuilder()\n\n input.forEach {\n\n if (vowels.contains(it, ignoreCase = true)) {\n return@forEach\n } else {\n result.append(\".\" + it.toLowerCase())\n }\n }\n\n return result.toString()\n\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "00365754b73e50f0b9b3a8beae78ccac", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nfun main() {\n\n var nums= readLine()!!.split(\"+\");\n nums=nums.sorted();\n sortArray(nums);\n}\n\nfun sortArray(nums: List){\n for (i in nums.indices){\n if(i==(nums.size-1))\n print(nums.get(i))\n else\n print(nums.get(i)+\"+\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "e39efbc33bb03482ab70d7733f0e9886", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n printnln(readLine()!!.split('+').sorted().joinToString(\"+\"))\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0f32babfe41265ec9faa1ad993f89894", "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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2838000238c4c26d748fbe3f3b6397c7", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\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[temp]!= null)\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", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a662c28c4746ee609782c3bc2bf1fa7b", "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": "e711b24b88a5b20fbb364a73a6eff6e7", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(){\n readLine();\n let characters = readLine()!!;\n \n var best_count = -1;\n var best_index = -1;\n \n var i = 0;\n while(i < characters.length - 1){\n var count = 0;\n \n val reference1 = characters.get(i);\n val reference2 = characters.get(i + 1);\n \n var j = i;\n while(j < characters.length - 1){\n val character1 = characters.get(j);\n val character2 = characters.get(j + 1);\n \n if(character1 == reference1 && character2 == reference2){\n count = count + 1;\n }\n \n j = j + 1;\n }\n \n if(count > best_count){\n best_count = count;\n best_index = index;\n }\n \n i = i + 1;\n }\n \n println(characters.substring(best_index, best_index + 2));\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c09c73920413f6a105775d12a0430c94", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.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\nimport java.util.HashMap\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 solve(1, `in`, out)\n out.close()\n}\n\nfun solve(testNumber: Int, `in`: Scanner, out: PrintWriter) {\n val n = `in`.nextInt()\n val s = `in`.next()\n val m = HashMap()\n var ans = \"\"\n var ans_x = 0\n for (i in 0 until n - 1) {\n val ss = s.substring(i, i + 2)\n val x = m.getOrDefault(ss, 0)\n m.put(ss, x + 1)\n if (x + 1 > ans_x) {\n ans = ss\n ans_x = x + 1\n }\n }\n out.println(ans)\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6179808200d621755dd94fe01b3c7244", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package practice\n\nfun String.twoGrams(): Map = this.zipWithNext { a, b -> \"$a$b\" }.groupingBy { it }.eachCount()\n\nfun Map.max(): String? = this.maxBy { it.value }?.key\n\nfun main() {\n val n = readLine()?.toIntOrNull() ?: error(\"n not valid\")\n val s = readLine()?.substring(0 until n) ?: error(\"s not valid\")\n\n println(s.twoGrams().max())\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "193f70365732eb0aed3e9c4802a4facc", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.regex.Pattern\n\nfun main(args: Array) {\n val ss = twogram()\n print(ss)\n}\n\nfun twogram1(): Pair?{\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 return m\n }else return \"\" to 0\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "94a4eee1fce6db6b788fbab80c9cc795", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n val reader = Scanner(System.`in`)\n reader.nextInt()\n val s = reader.next().trim()\n val m = mutableMapOf()\n for (k in s.zipWithNext().map { \"${it.first}${it.second}\" })\n m[i] = m.getOrDefault(k, 0) + 1\n println(m.maxBy { it.value }?.key)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4d8d5e71d9a585fb75982182a94fc5b4", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "rivate 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(args: Array) {\n var n = readInt()\n var s = readLn()\n var m = HashMap()\n for (i in 0..n-2) {\n var t = s.substring(i, i + 2)\n if (m.containsKey(t)) {\n m.put(t, m.get(t)!! + 1)\n } else {\n m.put(t, 1)\n }\n }\n var mx = -1\n var res = \"\"\n for (t in m.keys) {\n if (m.get(t)!! > mx) {\n mx = m.get(t)!!\n res = t\n }\n }\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6cc624894c72eecc61badda6388025fd", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": " fun main(arguments: Array){\n val myLength = Integer.parseInt(readLine()!!);\n val myString = readLine()!!;\n \n var best_index = 0;\n var best_count = 0;\n \n var i = 0;\n while(i < (myLength - 1)){\n var count = 1;\n val reference1 = myString.charAt(i);\n val reference2 = myString.charAt(i + 1);\n \n var j = i + 1;\n while(j < (myLength - 1)){\n val char1 = myString.charAt(j);\n val char2 = myString.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(myString.substring(best_index, best_index + 2));\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b30252625108f1603559f6b738b4612f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.OutputStream\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.InputMismatchException\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakhar17252\n */\nfun main(args: Array) {\n val inputStream = System.`in`\n val outputStream = System.out\n val `in` = Main.InputReader(inputStream)\n val out = PrintWriter(outputStream)\n val solver = Main.BTwoGram()\n solver.solve(1, `in`, out)\n out.close()\n}\n\nobject Main {\n internal class BTwoGram {\n fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {\n val n = `in`.nextInt()\n val s = `in`.nextString()\n\n val freq = Array(26) { IntArray(26) }\n\n for (i in 0 until n - 1) {\n freq[s.charAt(i) - 'A'][s.charAt(i + 1) - 'A']++\n }\n\n var ans = StringBuilder()\n var maxi = 0\n for (i in 0..25) {\n for (j in 0..25) {\n if (freq[i][j] > maxi) {\n maxi = freq[i][j]\n ans = StringBuilder()\n ans.append(('A'.toInt() + i).toChar())\n ans.append(('A'.toInt() + j).toChar())\n }\n }\n }\n\n out.println(ans.toString())\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 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 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": "407a2e3db49a8b28bc883c2f626b7bf3", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.parseInt\nimport java.lang.Long.parseLong\nimport java.lang.Math.max\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 B {\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 val n = scanInt()\n val s = scanString()\n val cnts = IntArray(26 * 26)\n var maxcnt = 0\n for (i in 0 until n - 1) {\n maxcnt = max(maxcnt, ++cnts[s[i] - 'A' + (s[i + 1] - 'A') * 26])\n }\n for (i in 0 until 26 * 26) {\n if (cnts[i] == maxcnt) {\n out!!.print(\"\" + (i % 26 + 'A'.toInt()).toChar() + (i / 26 + 'A'.toInt()).toChar())\n break\n }\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": "7bf6df5e6304a24e65f2da936602dd3b", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": " fun main(){\n readLine();\n val characters = readLine()!!;\n \n var best_count = -1;\n var best_index = -1;\n \n var i = 0;\n while(i < characters.length - 1){\n var count = 0;\n \n val reference1 = characters.get(i);\n val reference2 = characters.get(i + 1);\n \n var j = i;\n while(j < characters.length - 1){\n val character1 = characters.get(j);\n val character2 = characters.get(j + 1);\n \n if(character1 == reference1 && character2 == reference2){\n count = count + 1;\n }\n \n j = j + 1;\n }\n \n if(count > best_count){\n best_count = count;\n best_index = index;\n }\n \n i = i + 1;\n }\n \n println(characters.substring(best_index, best_index + 2));\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b1f245084209951e3c2a29517a718a7f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject test {\n fun main(argv: Array) {\n var cin = Scanner(System.`in`)\n var len = cin.nextInt()\n var n = cin.next()\n val map = mutableMapOf()\n for (i in 0 until len - 1) {\n var temp = String(\"\")\n temp += n.charAt(i)\n temp += n.charAt(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 = 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}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b7f78a6dbc4b44516d170e0f9dfaee8a", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.regex.Pattern\n\nfun main(args: Array) {\n val ss = twogram1()\n print(ss.first)\n}\n\nfun twogram1(): Pair?{\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 return m\n }else return \"\" to 0\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "34c8d50c11f7a78ef4301785d0ddc018", "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": "af32c5e3ec01f430a92e873b417f938b", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package round494.div3\n\nimport java.util.*\n\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt()\n val c = IntArray(100)\n for (i in 0 until n) {\n c[nextInt()]++;\n }\n print(c.max()!!)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1b5db0f9110ea958cb82714cbc1bfe89", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforces.round394\n\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\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6db83adb85c18b7fa7ba3d40ea42b211", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n for (i in 1..200) {\n for (j in i..200) {\n var even = 0\n var odd = 0\n for (k in i..j) {\n if (k mod 2 == 0) even++ else odd++\n }\n if (even == a && odd == b) {\n println(\"YES\")\n return;\n }\n }\n }\n println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "508881fd0d9d564499532be5e22fad9f", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "package archive\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 (a, b) = readInts()\n var years = 0\n while (a <= b) {\n a *= 3\n b *= 2\n years++\n }\n println(years)\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "349246403457f53317f713a814a45a61", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val t = readLine()!!.toInt()\n fun absMax(r: Array): Int {\n var k = -1\n for (i in r.indices)\n if (r[i] != 0 && (k == -1 || abs(r[i]) < abs(r[k])))\n k = i\n return k\n }\n\n fun sumPositive(r: Array): Int {\n var s = 0\n for (i in r)\n if(i > 0)\n s += i\n return s\n }\n for (i in 1..t) {\n val n = readLine()!!.toInt()\n val x = readLine()!!.split(\" \").map { it.toInt() }.toTypedArray()\n val k = absMax(x)\n println(sumPositive(x) - abs(x[k]))\n for (j in 0 until n)\n if((x[j] < 0) == (j == k))\n print(1)\n else\n print(0)\n println()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "967b9c8d914e28877ec8f04199f92e9b", "src_uid": "52b86006d324475ffcd1259f8e68fc54", "difficulty": null} {"lang": "Kotlin", "source_code": "fun main(){\n var inputInt = readLine()!!.toInt()\n val inputInt = 8\n var numberStr = (inputInt+1).toString()\n numberStr.lastIndexOf(\"0\").let {\n if(it>0){\n print(numberStr.substring(0,numberStr.lastIndexOf(\"0\")-1))\n }else{\n print(numberStr)\n }\n }\n\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "af7968542558e9d06eebd28ee548822e", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val input = System.`in`.readAllBytes().decodeToString().splitToSequence('\\n').iterator()\n fun readLine() = input.next()\n val (n, m, k) = readLine().split(\" \").map { it.toInt() }\n val a = readLine().split(\" \").map { it.toLong() }\n val b = readLine().split(\" \").map { it.toLong() }\n val c = List(n) { readLine().split(\" \").map { it.toLong() } }\n val ab = a.union(b).toSet().toList().sorted()\n\n\n var actualMax = 0L\n var indexA = 0\n var indexB = 0\n val upgradedC = LongArray(ab.size) {\n val cost = ab[it]\n while (indexA != n && a[indexA] <= cost) {\n for (j in 0 until indexB) {\n actualMax = max(actualMax, c[indexA][j])\n }\n indexA++\n }\n while (indexB != m && b[indexB] <= cost) {\n for (i in 0 until indexA) {\n actualMax = max(actualMax, c[i][indexB])\n }\n indexB++\n }\n actualMax\n }\n\n\n var minimum = Long.MAX_VALUE\n for (i in upgradedC.indices) {\n upgradedC[i] += k.toLong()\n var runs = 0L\n var actual = 0L\n\n for (j in ab.indices) {\n if (ab[j] > actual) {\n var ru = (ab[j] - actual) / upgradedC[j - 1]\n if (ru * upgradedC[j - 1] != (ab[j] - actual)) ru++\n runs += ru\n actual += ru * upgradedC[j - 1]\n }\n }\n\n minimum = min(minimum, runs)\n upgradedC[i] -= k.toLong()\n }\n\n\n println(minimum)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "90115b14149def1212c3e48499fa9528", "src_uid": "309d0bc338fafcef050f336a7fa804c7", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val input = System.`in`.readAllBytes().decodeToString().splitToSequence('\\n').iterator()\n fun readLine() = input.next()\n val (n, m, k) = readLine().split(\" \").map { it.toInt() }\n val a = readLine().split(\" \").map { it.toLong() }\n val b = readLine().split(\" \").map { it.toLong() }\n val c = List(n) { readLine().split(\" \").map { it.toLong() } }\n val ab = a.union(b).toSet().toList().sorted()\n\n\n var actualMax = 0L\n var indexA = 0\n var indexB = 0\n val upgradedC = LongArray(ab.size) {\n val cost = ab[it]\n while (indexA != n && a[indexA] <= cost) {\n for (j in 0 until indexB) {\n actualMax = max(actualMax, c[indexA][j])\n }\n indexA++\n }\n while (indexB != m && b[indexB] <= cost) {\n for (i in 0 until indexA) {\n actualMax = max(actualMax, c[i][indexB])\n }\n indexB++\n }\n actualMax\n }\n\n\n var minimum = Long.MAX_VALUE\n for (i in upgradedC.indices) {\n upgradedC[i] += k.toLong()\n var runs = 0L\n var actual = 0L\n\n for (j in ab.indices) {\n if (ab[j] > actual) {\n var run = (ab[j] - actual) / upgradedC[j - 1]\n if (run * upgradedC[j - 1] != (ab[j] - actual)) run++\n runs += run\n actual += run * upgradedC[j - 1]\n }\n }\n\n minimum = min(minimum, runs)\n upgradedC[i] -= k.toLong()\n }\n\n\n println(minimum)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "79a3d074887b9029daadb31a52d8e212", "src_uid": "309d0bc338fafcef050f336a7fa804c7", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.io.*\nimport java.lang.Integer.max\n\nclass IOStream {\n val br = BufferedReader(InputStreamReader(System.`in`))\n var st: StringTokenizer? = null\n\n fun nextToken(): String? {\n while (st == null || !st!!.hasMoreTokens())\n st = StringTokenizer(br.readLine())\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return nextToken()!!.toInt()\n }\n\n fun nextLong(): Long {\n return nextToken()!!.toLong()\n }\n}\n\nfun main(args: Array) {\n val inp = IOStream()\n val out = PrintWriter(System.out)\n val n = inp.nextInt()\n val m = inp.nextInt()\n val k = inp.nextInt()\n val a = Array(n, { i -> inp.nextLong() })\n val b = Array(m, { i -> inp.nextLong() })\n val c = Array(n, { i -> Array(m, { j-> inp.nextInt() }) })\n val best = Array(n, { i -> Array(m, { j-> c[i][j] }) })\n for (i in 0..n-1) for (j in 0..m-1) {\n if (i>0) best[i][j]=Math.max(best[i][j],best[i-1][j])\n if (j>0) best[i][j]=Math.max(best[i][j],best[i][j-1])\n }\n val inf = 1000000000000000L\n var i = 0\n var j = 0\n var num = 0\n val wi = Array(n + m + 1, { i->0 })\n val wj = Array(n + m + 1, { i->0 })\n val v = Array(n + m + 1, { i->0L })\n var st = 0\n while (i=m || a[i] Array(2, { j-> inf }) })\n val z = Array(num, { i -> Array(2, { j-> inf }) })\n f[st]=0\n z[st]=0\n for (i in st..num-2) for (j in 0..1) if (f[i][j] f[i][j] + cnt) {\n f[nxt][j] = f[i][j] + cnt\n z[nxt][j] = z[i][j] + cur * cnt\n }\n }\n if (j==1) continue\n cur += k\n for (nxt in i+1..num-1) {\n val cnt = (v[nxt] - z[i][j] + cur - 1) / cur\n if (f[nxt][1] > f[i][j] + cnt) {\n f[nxt][1] = f[i][j] + cnt\n z[nxt][1] = z[i][j] + cur * cnt\n }\n }\n }\n out.println(Math.min(f[num-1][0],f[num-1][1]));\n out.close();\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "17415dda46df9533e442b34c2571aff7", "src_uid": "309d0bc338fafcef050f336a7fa804c7", "difficulty": 2600.0} {"lang": "Kotlin", "source_code": "import kotlin.streams.toList\n\nfun main(args: Array) {\n val a = readLine()!!.chars().toList()\n if (a.distinct().count() % 2 == 0) {\n print(\"CHAT WITH HER!\")\n } else {\n print(\"IGNORE HIM!\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6619582508b7d5affac2126dfffaf45a", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.test\n\nfun main() {\n println(if (hashSetOf().apply { addAll(readLine()!!.toList()) }.size % 2 == 0) \"CHAT WITH HER!\" else \"IGNORE HIM!\")\n}\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "96768126f75b960bcbce8e222b680dd6", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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": "e0923b2b0d917c8675f613b40479318d", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n \npublic class CF58A {\n public static void main(String[] args) {\n Scanner cin = new Scanner(System.in);\n String f = \"hello\";\n String s = cin.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": "56d532c9b8f3cfb3013c6020fb153708", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n readLine()\n val s = readLine()\n if(s.contains(\"11\")) print(\"No\")\n else {\n if(s.contains(\"000\")) print(\"No\")\n else print(\"Yes\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6e87e2b6caab20ebe22dd3b3b7885b7f", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "package GlobalRound3\n\nfun main() {\n var (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n println(c * 2 + Math.min(a, b) * 2 + 1)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2d50318b06ec7f29e67b8c744d1d37c8", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "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 ofu strings\nprivate fun readLongs() = readStrings().map { it.toLong() } // list of ints\n\nfun main(args:Array){\n val (a,b,c) = readInts()\n var d = 2*c + minOf(a,b) * 2\n if (a!=b) d++\n println(d)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0ef04c3bfcd7a8171694b667afd67cc6", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(arg: Array) {\n val s = readLine()!!\n var metka = '0'\n var o = 0\n var k = 0\n for (i in 0..s.length-1) {\n if (s[i] == metka) o++\n else {\n metka = s[i]\n k = maxOf(k, o)\n o = 1\n }\n }\n if (k >= 7) println(\"YES\")\n else println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a625d4ef7c3f8ba22366c7d8cad0c54a", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package a\n\nimport java.util.*\n\nfun main(args: Array) {\n val word = Scanner(System.`in`).nextLine()\n\n var counter = 0\n\n word.forEachIndexed { index, c ->\n println(\"before $counter\")\n\n if (index == 0) counter++\n else {\n if (c == '0' && word[index - 1] == '0') counter++\n else if (c == '1' && word[index - 1] == '1') counter++\n else counter = 1\n }\n\n if (counter == 7) return println(\"YES\")\n }\n\n println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2ca9b04177721d0977edf154e9e2cb1b", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.StringTokenizer\n\nval mod = (1e9 + 7).toInt()\n\nfun main(args: Array) {\n val sc = FastScanner(System.`in`)\n\n val n = sc.nextLong()\n val m = sc.nextLong()\n val k = sc.nextInt()\n\n if (k == -1 && (n + m) % 2 == 1L) {\n println(0)\n return\n }\n\n\n println(pow(pow(2, m - 1), n - 1))\n\n}\n\nfun pow(x: Long, y: Long): Long {\n var y = y % (mod - 1)\n\n var res = 1L\n var deg = x\n while (y > 0) {\n if (y % 2 == 1L) {\n res = (res * deg) % mod\n }\n deg = (deg * deg) % mod\n y /= 2\n }\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", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "c7668b02492057790558c37ae742964d", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "\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": "9f0f3209c6dfe350b8a375f4f9298b02", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n\tvar n = readLine().toInt()\n\tvar A = readLine()!!.split(' ').map{it.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": "36ee50eeb9974f8670be3d58296315af", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.example.myapplication\n\nimport java.util.*\nimport kotlin.math.max\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 for(i1 in n / max1 downTo 0) {\n val remains1 = n - i1 * max1\n for(i2 in remains1 / max2 downTo 0) {\n val remains2 = remains1 - i2 * max2\n if (remains2 % max3 == 0) {\n print(i1 + i2 + remains2 / max3)\n return\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "1d33fda7bc305f1deb701cfc56d1e6ef", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "package Kotlin\n\nimport java.util.*\n\n/**\n * Created by Administrator on 2017/6/8.\n */\n\n fun main(args: Array) {\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(\"Yse\")\n }else if (isSort(a)){\n println(\"Yse\")\n }else{\n println(\"No\")\n }\n}\n\n@Suppress(\"UNREACHABLE_CODE\")\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\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "10f238618e54f5c9a8c0a20de5b8865b", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.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(matrix))\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": "d90ffe7e3515e49c532f9156b0b02b80", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package com.nikartix.competitive\n\nimport java.io.FileInputStream\nimport java.io.PrintStream\nimport kotlin.math.abs\nimport kotlin.system.exitProcess\n\nfun changeIO() {\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n System.setOut(PrintStream(\"src/main/resources/output.file\"))\n System.setIn(FileInputStream(\"src/main/resources/input.file\"))\n }\n}\n\nfun main() {\n changeIO()\n for (i in 0 .. 4) {\n val line = readLine()!!.split(' ')\n for (j in line.indices) {\n if (line[j] == \"1\") {\n print(abs(2-i) + abs(2-j))\n exitProcess(0);\n }\n }\n }\n}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "9813b774bde08ff4636f6d7b4af14ddc", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nobject Solution\n{\n @JvmStatic\n fun main(args: Array)\n {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n val arr: CharArray\n `in`.nextLine()\n val str = `in`.nextLine()\n arr = str.toCharArray()\n val s = Stack()\n var count = 0\n for (i in arr.indices)\n {\n if (s.isEmpty())\n {\n s.push(arr[i])\n }\n else\n {\n if (s.peek() == arr[i])\n {\n if (!s.isEmpty())\n {\n count++\n }\n else\n {\n count++\n }\n }\n else\n {\n s.push(arr[i])\n }\n }\n }\n println(count)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2b18f6c4d8c357d9757b6e824d01bb57", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "6f088b5b3a5ff09c3786f8767db1cc37", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val input = Scanner(System.`in`)\n while (input.hasNext()) {\n val s = input.next()\n val len = s.length\n var res = 0\n for (elem in s.toCharArray()) {\n if (elem == 'a') {\n res++\n }\n }\n res *= 2\n if (res > len) {\n println(len)\n } else {\n println(len - res)\n }\n }\n input.close()\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "a4fffa4820bfcc540207b95faacafc19", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport java.util.function.BiFunction\nimport kotlin.collections.ArrayList\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 = DGraphAndQueries()\n solver.solve(1, `in`, out)\n out.close()\n System.err.println((System.currentTimeMillis() - startTime).toString() + \"ms\")\n }\n }\n\n internal class DGraphAndQueries {\n lateinit var arr: IntArray\n lateinit var parent: IntArray\n lateinit var tin: IntArray\n lateinit var tout: IntArray\n var n = 0\n var ind = 0\n var clock = 0\n lateinit var visited: BitSet\n lateinit var tour: Array>\n lateinit var graph: Array>\n fun find(u: Int): Int {\n return if (parent[u] == u) u else find(parent[u]).also { parent[u] = it }\n }\n\n fun merge(p: Pair) {\n val u = find(p.a)\n val v = find(p.b)\n if (u == v) {\n return\n }\n val next = ind++\n parent[v] = next\n parent[u] = parent[v]\n graph[next] = ArrayList(Arrays.asList(u, v))\n }\n\n fun dfs(u: Int) {\n tour[clock] = Pair(arr[u], clock++.also { tin[u] = it })\n if (u >= n) {\n for (v in graph[u]) {\n dfs(v)\n }\n }\n tout[u] = clock - 1\n }\n\n fun solve(kase: Int, `in`: InputReader, pw: Output) {\n n = `in`.nextInt()\n val m = `in`.nextInt()\n val q = `in`.nextInt()\n arr = IntArray(n + q)\n Arrays.fill(arr, -1)\n parent = IntArray(n + q)\n graph = Array(n + q) { ArrayList() }\n ind = n\n for (i in 0 until n) {\n arr[i] = `in`.nextInt()\n }\n for (i in 0 until n + q) {\n parent[i] = i\n }\n val edges: Array> = Array(m) { Pair(0, 0) }\n for (i in 0 until m) {\n edges[i] = Pair(`in`.nextInt() - 1, `in`.nextInt() - 1)\n }\n val marked = BitSet(m)\n val queries = Array(q) { IntArray(2) }\n for (i in 0 until q) {\n queries[i] = intArrayOf(`in`.nextInt(), `in`.nextInt() - 1)\n if (queries[i][0] == 2) {\n marked.set(queries[i][1])\n }\n }\n for (i in 0 until m) {\n if (!marked[i]) {\n merge(edges[i])\n }\n }\n for (i in q - 1 downTo 0) {\n if (queries[i][0] == 2) {\n merge(edges[queries[i][1]])\n } else {\n queries[i][1] = find(queries[i][1])\n }\n }\n Utilities.Debug.dbg(ind)\n Utilities.Debug.dbg(*graph)\n tour = Array(ind) { Pair(0, 0) }\n tin = IntArray(ind)\n tout = IntArray(ind)\n visited = BitSet(ind)\n clock = 0\n for (i in 0 until n) {\n val u = find(i)\n if (!visited!![u]) {\n dfs(u)\n visited!!.set(u)\n }\n }\n Utilities.Debug.dbg(*tour)\n val st = TPointSegmentTree(tour, BiFunction { t, u -> if (t.a>=u.a) t else u })\n for (query in queries) {\n if (query[0] == 1) {\n val u = query[1]\n val v = st.query(tin[u], tout[u])!!\n Utilities.Debug.dbg(u, v)\n pw.println(v.a)\n st[v.b] = Pair(0, v.b)\n }\n }\n }\n }\n\n internal class TPointSegmentTree(arr: Array, operation: BiFunction) {\n var n: Int\n var ind = 0\n var ql = 0\n var qr = 0\n var arr: Array\n var value: Array\n var operation: BiFunction\n private fun build(o: Int, l: Int, r: Int) {\n if (l == r) {\n value[o] = arr[l]\n return\n }\n val lc = o shl 1\n val rc = lc or 1\n val mid = l + r shr 1\n build(lc, l, mid)\n build(rc, mid + 1, r)\n value[o] = value[lc]?.let { value[rc]?.let { it1 -> operation.apply(it, it1) } }\n }\n\n private operator fun set(o: Int, l: Int, r: Int) {\n if (l == r) {\n value[o] = arr[l]\n return\n }\n val lc = o shl 1\n val rc = lc or 1\n val mid = l + r shr 1\n if (ind <= mid) {\n set(lc, l, mid)\n } else {\n set(rc, mid + 1, r)\n }\n value[o] = value[lc]?.let { value[rc]?.let { it1 -> operation.apply(it, it1) } }\n }\n\n operator fun set(ind: Int, `val`: T) {\n this.ind = ind\n arr[ind] = `val`\n set(1, 0, n - 1)\n }\n\n private fun query(o: Int, l: Int, r: Int): T? {\n if (ql <= l && qr >= r) {\n return value[o]\n }\n val lc = o shl 1\n val rc = lc or 1\n val mid = l + r shr 1\n var ret: T? = null\n if (ql <= mid) {\n ret = query(lc, l, mid)\n }\n if (qr > mid) {\n ret = if (ret == null) {\n query(rc, mid + 1, r)\n } else {\n query(rc, mid + 1, r)?.let { operation.apply(ret!!, it) }\n }\n }\n return ret\n }\n\n fun query(l: Int, r: Int): T? {\n ql = l\n qr = r\n return query(1, 0, n - 1)\n }\n\n init {\n n = arr.size\n this.arr = arr\n value = arrayOfNulls(n shl 2) as Array\n this.operation = operation\n build(1, 0, n - 1)\n }\n }\n\n internal class Utilities {\n object Debug {\n val LOCAL = System.getProperty(\"ONLINE_JUDGE\") == 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\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 println(i: Int) {\n println(i.toString())\n }\n\n fun println(s: String?) {\n sb.append(s)\n println()\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 interface InputReader {\n fun nextInt(): Int\n }\n\n internal class Pair(var a: T1, var b: T2) : Comparable> {\n constructor(p: Pair) : this(p.a, p.b) {}\n\n override fun toString(): String {\n return a.toString() + \" \" + b\n }\n\n override fun hashCode(): Int {\n return Objects.hash(a, b)\n }\n\n override fun equals(o: Any?): Boolean {\n if (o is Pair<*, *>) {\n val p = o\n return a == p.a && b == p.b\n }\n return false\n }\n\n override fun compareTo(p: Pair): Int {\n val cmp = (a as Comparable).compareTo(p.a)\n return if (cmp == 0) {\n (b as Comparable).compareTo(p.b)\n } else cmp\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 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 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}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "2515b158be4b0256c21d69417056fb3f", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.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 1..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": "bd21e40dee14d06676fdd4cb0ce923bb", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.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\nfun next() = if(hasNext()) st.nextToken()!! else throw RuntimeException(\"No tokens\")\n\nfun nextInt() = next().toInt()\n\nfun nextLong() = next().toLong()\n\nfun 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": "b1510bb0f92903af31bdf3ae3b9588c6", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "package ru.spbau.mit\n\nimport java.util.*\n\nclass Solver(k: Int, internal val bookTitle: CharArray) {\n companion object {\n private val IMPOSSIBLE = \"IMPOSSIBLE\".toCharArray()\n }\n private val unusedLetters: ArrayDeque\n init {\n val firstKLetters = 'a' until 'a' + k\n val usedLetters = bookTitle.toSet()\n unusedLetters = ArrayDeque(firstKLetters - usedLetters)\n }\n\n fun solve(): CharArray {\n val ok = removePairedQuestionMarks() && removeSingleQuestionMarks()\n return if (ok) bookTitle else IMPOSSIBLE\n }\n\n internal fun removeSingleQuestionMarks(): Boolean {\n for (i in 0 until bookTitle.size / 2) {\n val currentSymbol = bookTitle[i]\n val correspondingIndex = i.getCorrespondingIndex\n val correspondingSymbol = bookTitle[correspondingIndex]\n when {\n currentSymbol == '?' -> bookTitle[i] = correspondingSymbol\n correspondingSymbol == '?' -> bookTitle[correspondingIndex] = currentSymbol\n currentSymbol != correspondingSymbol -> return false\n }\n }\n return true\n }\n\n internal fun removePairedQuestionMarks(): Boolean {\n for (i in 0 until bookTitle.size / 2) {\n val currentSymbol = bookTitle[i]\n val correspondingIndex = i.getCorrespondingIndex\n val correspondingSymbol = bookTitle[correspondingIndex]\n if (currentSymbol == '?' && correspondingSymbol == '?') {\n bookTitle[i] = getAndExtractMaxUnusedLetterOrA()\n bookTitle[correspondingIndex] = bookTitle[i]\n }\n }\n return unusedLetters.isEmpty()\n }\n\n private fun getAndExtractMaxUnusedLetterOrA(): Char {\n return if (unusedLetters.isEmpty()) 'a' else unusedLetters.removeLast()\n }\n\n private val Int.getCorrespondingIndex:Int get() = bookTitle.size - this - 1\n}\n\nfun main(args: Array) {\n val input = Scanner(System.`in`)\n val k = input.nextInt()\n val bookTitle = input.next().toCharArray()\n print(Solver(k, bookTitle).solve())\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "45be2e735f6e226f22c9a17c06be5466", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n// n a x b y\n val (n,ai,x,bi,y) = readLine()!!.split(\" \").map{ it.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": "4636f3aea1543331ab5f70056358b0dd", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.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 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": "25cef9725e3a2234c823f64a7a51af3a", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "//http://rextester.com Kotlin 1.1\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": "90c50c184d796f349d1410468aa232ff", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Kotlin 1.6", "source_code": "fun main() { repeat(readln().toInt()) { println( 100 / gcd( 100 , readln().toInt())) }\r\n fun gcd(a: Int, b: Int): Int { return if (b == 0) { a } else gcd(b, a % b) } }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "cc7d2f461faea38311f128a0dd10de28", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.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 scanner = Scanner(System.`in`)\n\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n scanner.nextLine()\n val x = scanner.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": "2ee6547329e0f9abce7c9962d66bda61", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.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 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": "2b7f5beebf97515abf8c491f920ff26e", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "object Solution {\n @JvmStatic\n fun main(args: Array) {\n val t = readLine()!!.toInt()\n for (i in 0 until t) {\n val x = readLine()!!.toInt()\n val digit = x % 10 - 1\n val part = when (x.toString().length) {\n 1 -> 1\n 2 -> 3\n 3 -> 6\n 4 -> 10\n else -> 0\n }\n println(digit * 10 + part)\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f8d8fbbe8a05bfa837c0232b83834e1e", "src_uid": "289a55128be89bb86a002d218d31b57f", "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": "f45426fa5fe18df965fb9093a87c5ce6", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package `codeforces-parser`.`1099-kotlin`.A\n\nvar _debug = false;\nfun debug(vararg vals: T): Unit {\n\tif (!_debug) {\n\t\treturn\n\t}\n\tfor (v in vals) {\n\t\tSystem.err.print(v); System.err.print(\" \")\n\t}\n\tSystem.err.println()\n}\n\nfun main(args: Array) {\n\tif (args.size > 0 && args[0] == \"-d\") {\n\t\t_debug = true;\n\t}\n\n\tval (w, h) = readLine()!!.split(' ').map(String::toLong)\n\tval (u1, d1) = readLine()!!.split(' ').map(String::toLong)\n\tval (u2, d2) = readLine()!!.split(' ').map(String::toLong)\n\n\tval sum = w + (h * (h + 1) / 2)\n\tval result = Math.max(sum - u1 - u2, 0)\n\n\tprintln(result)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "0a4667a56952b9bccd49590a5cd17d5d", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Kotlin", "source_code": " import java.io.BufferedReader;\n import java.io.IOException;\n import java.io.InputStream;\n import java.io.InputStreamReader;\n import java.io.PrintWriter;\n\n\n import java.util.*;\n\n\n public class Main {\n\n\n\n\n\n\n\n\n public static void main (String[]args) throws IOException {\n Scanner in = new Scanner(System.in);\n\n\n try (PrintWriter or = new PrintWriter(System.out)) {\n\n char[]a=in.next().toCharArray();\n\n int ans=0;\n boolean state=false;\n for (int i = 1; i < 1<0)temp.append(a[j]);\n }\n if (temp.length()>0)\n {\n for (int j = 0; j < temp.length(); j++) {\n if (temp.charAt(j)=='0'){\n temp.deleteCharAt(0);\n j=-1;\n }\n }\n if (temp.length()>0){\n int s=Integer.parseInt(temp.toString());\n int sqr=(int)Math.sqrt(s);\n if (sqr*sqr==s){\n ans=Math.max(ans,temp.length());\n state=true;\n }\n }\n\n }\n }\n or.println(state?a.length-ans:-1);\n\n\n\n\n\n\n\n\n\n }\n\n }\n\n\n\n\n\n\n\n\n static long gcd(long a, long b)\n {\n if (b == 0)\n return a;\n return gcd(b, a % b);\n }\n\n\n\n\n\n\n\n static class Scanner {\n\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s) {\n br = new BufferedReader(new InputStreamReader(s));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) {\n st = new StringTokenizer(br.readLine());\n }\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n String x = next();\n StringBuilder sb = new StringBuilder(\"0\");\n double res = 0, f = 1;\n boolean dec = false, neg = false;\n int start = 0;\n if (x.charAt(0) == '-') {\n neg = true;\n start++;\n }\n for (int i = start; i < x.length(); i++) {\n if (x.charAt(i) == '.') {\n res = Long.parseLong(sb.toString());\n sb = new StringBuilder(\"0\");\n dec = true;\n } else {\n sb.append(x.charAt(i));\n if (dec) {\n f *= 10;\n }\n }\n }\n res += Long.parseLong(sb.toString()) / f;\n return res * (neg ? -1 : 1);\n }\n\n public boolean ready() throws IOException {\n return br.ready();\n }\n\n }\n }\n\n class Pair implements Comparable {\n int first, second;\n\n public Pair(int first, int second) {\n this.first = first;\n this.second = second;\n }\n\n\n @Override\n public int compareTo(Pair o) {\n if (first!=o.first)return first-o.first;\n return second-o.second;\n }\n }\n\n class Tempo {\n\n int first,second,third;\n\n public Tempo(int first, int second, int third) {\n this.first = first;\n this.second = second;\n this.third = third;\n }\n }", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "d510fe34807bb782a2290b62e7d713b0", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "package codeforces.round371div2\n\nfun main(vararg args: String) {\n val (l1, r1, l2, r2, k) = readLine()!!.split(' ').map { it.toLong() }\n val l = Math.max(l1, l2)\n val r = Math.min(r1, r2)\n if (l > r) {\n println(0)\n } else {\n var o = r - l + 1\n if (k in l..r) o -= 1\n println(o)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "4b5699c2a2b346cee20abebdb9ffbdc1", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "package ventureCup2017Elimination\n\nimport 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(String::toInt)\nprivate fun String.toLongs() = split(\" \").map(String::toLong)\n\nfun isPrime(p: Int): Boolean {\n val upb = Math.sqrt(p.toDouble()).toInt()\n for (i in 2..upb) {\n if (p % i == 0)\n return false\n }\n return true\n}\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val n = input.readLine().toInt()\n for (m in 1..1000) {\n val p = n * m + 1\n if (!isPrime(p)) {\n output.println(m)\n return\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "3e014d3d992a9936e8238fb068c4b37c", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package templates\n\nimport 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\nfun dayToInt(s: String) = when (s) {\n \"monday\" -> 0\n \"tuesday\" -> 1\n \"wednesday\" -> 2\n \"thursday\" -> 3\n \"friday\" -> 4\n \"saturday\" -> 5\n \"sunday\" -> 6\n else -> throw IllegalArgumentException()\n}\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val d1 = dayToInt(input.readLine())\n val d2 = dayToInt(input.readLine())\n\n if (listOf(28, 30, 31).any { (d1 + it) % 7 == d2 })\n output.println(\"YES\") else\n output.println(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f23727fcad23766748f76cf9005cc062", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.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": "3cbb1cb376e85a030b69209af6423561", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "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": "d54730c16b85ae66b0c947af51a9a31c", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"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 for(i in 0 until factors.size)\n {\n for(j in 0 until 10)\n {\n transfer[i][j] = -1;\n }\n }\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}\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "b27d8a2f5a7a9329a8b528d40b00c55e", "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 this.out = out\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": "a54733e8c440bc8b6c283b16d4cf50eb", "src_uid": "d38877179ddbc55028d8f0a4da43cd46", "difficulty": null} {"lang": "Kotlin", "source_code": "package com.company.main\n\nimport java.util.*\n\nfun main(args : Array) {\n var s = Scanner(System.`in`)\n\n var n = s.nextInt()\n\n println(n / 2 * 3)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "333f416ba81bfc9c90a02966c7a0e3e8", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package A\n\nimport java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\n\nfun solve() {\n val (n, k) = nextArray(2)\n val ans = ArrayList()\n\n val s = mutableSetOf()\n for ((index, a) in nextArray(n).withIndex()) {\n if (!s.contains(a)) {\n s.add(a).also { ans.add(index+1) }\n }\n if (ans.size == k) {\n break\n }\n }\n if (ans.size == k) {\n println(\"YES\\n${ans.joinToString(separator = \" \")}\")\n } else {\n println(\"NO\")\n }\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": "376394bd0addadd90b5b05a4b89f5cc4", "src_uid": "5de6574d57ab04ca195143e08d28d0ad", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(arg: Array) {\n val problem399 = Problem399()\n problem399.solve(arg)\n}\n\nopen class Problem399 {\n fun solve(arg: Array) {\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": "77014f8a3ab63b557eab81c2d8ab3283", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "package codeforce\n\nfun main(args: Array) {\n val problem399 = Problem399()\n problem399.solve(args)\n}\n\nopen class Problem399 {\n fun solve(arg: Array) {\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": "d623249ada0d59434ddc9f3bb5fe5d00", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main() {\n val input: Int = nextInt()\n if (input % 5 == 0) {\n println((input/5))\n } else {\n println((input/5)+1)\n }\n\n \n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "5e37459d2ce33e3299ea0bb14c79f55a", "src_uid": "4b3d65b1b593829e92c852be213922b6", "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": "a7d73c8b479991323e23a4834e9c60d2", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.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())== BigInteger.ZERO){\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+= BigInteger.TWO\n if (startingPoint%divisibleBy.toBigInteger()== BigInteger.ZERO){\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": true, "code_uid": "aecc52c1236197c5831f5d5070c0dbdc", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "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 -= 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": "a14ce940e5727062262a49f4767e1f4a", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array){\n\tval y = \" 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\"\n readLine()!!\n\tprintln(if(y.contains(readLine()!!)) \"YES\" else \"NO\"\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "02e21fc4769b78af943dd922e705a48a", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n var dir:string = readLine()\n var a:string = readLine()\n for(index in 0..a.size-1)\n {\n if(a[index]==';')\n {\n a[index]=l\n }\n else if (a[index]==',')\n {\n a[index]=m\n }\n }\n println(a)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "00c974b4cf1cbf4bd622409b1001f5b7", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport java.util.*\n\nfun main (args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val v = b * (Math.log10(a.toDouble()) / Math.log10(b.toDouble()))\n\n if (a == b) {\n println(\"=\")\n return\n }\n\n when {\n v < a -> println(\"<\")\n v > a -> println(\">\")\n else -> {\n println(\"=\")\n throw Exception(\"nope\")\n }\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "f3f9e1e67707785b54cdcf03ac7fab44", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.awt.Point;\nimport java.io.*;\nimport java.util.*;\nimport java.math.BigInteger;\n\npublic class EasyNum {\n static boolean[] primes;\n static int[] memo;\n static int mod = (1<<30);\n public static void main(String[] args) {\n MyReader mr = new MyReader();\n\n int a = mr.nextInt();\n int b = mr.nextInt();\n int c = mr.nextInt();\n\n memo = new int[a*b*c+1];\n primes = new boolean[a*b*c+1];\n\n initPrimes();\n\n int res = 0;\n\n for (int i = 1; i <= a; i++)\n for(int j = 1; j<=b;j++)\n for(int k = 1; k<=c ;k++){\n int val = i*j*k;\n if(memo[val] == 0){\n memo[val] = findDiv(val);\n }\n\n res+=memo[val];\n res%=mod;\n }\n\n\n System.out.println(res);\n\n\n }\n\n private static int findDiv(int val) {\n int res = 1;\n for (int i = 2;i<=val;i++){\n if(primes[i] && val%i == 0){\n int count = 0;\n while (val%i == 0){\n count++;\n val/=i;\n }\n\n res=res*(count+1);\n }\n }\n\n return res;\n }\n\n private static void initPrimes() {\n Arrays.fill(primes,true);\n int n = primes.length;\n for (int i = 2; i < n; i++) {\n if (primes[i]){\n for (int j = 2; j*i < n ; j+=i) {\n primes[j*i] = false;\n }\n }\n }\n }\n\n static class MyReader {\n BufferedReader br;\n StringTokenizer st;\n\n MyReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String res = \"\";\n try {\n res = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n return res;\n }\n\n Integer[] nextIntArray(int n) {\n Integer[] arr = new Integer[n];\n for (int i = 0; i < n; i++) {\n arr[i] = nextInt();\n }\n\n return arr;\n }\n\n Long[] nextLongArray(int n) {\n Long[] arr = new Long[n];\n for (int i = 0; i < n; i++) {\n arr[i] = nextLong();\n }\n\n return arr;\n }\n\n String[] nextStringArray(int n) {\n String[] arr = new String[n];\n for (int i = 0; i < n; i++) {\n arr[i] = next();\n }\n return arr;\n }\n }\n\n static void swap(int[] arr, int i, int j) {\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "fd9a602f1efd8d7ea1197dee76b39000", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var t = readInt()\n var countOfL = 0\n var countOfR = 0\n\n var s = readLine()!!\n\n for (i in s){\n if (i=='L') countOfL++\n else countOfR++\n }\n println(countOfL+countOfR+1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "7a8bd3683b5745f54ed16743a3c5c268", "src_uid": "098ade88ed90664da279fe8a5a54b5ba", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "\npackage main\n\nimport java.util.Scanner\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n var n = scanner.nextInt()\n var s = scanner.nextLine()\n var c: Int = 0\n var z: Int = 0\n while (c) {\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": "b44310935e42a7bef8cef903c5b73469", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun 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": true, "code_uid": "962ebde9a1c000f9f828454bbd4a2cfb", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n\npublic class YourAProfessional {\n public static void main(String[] args) {\n Scanner sc =new Scanner(System.in);\n int f = sc.nextInt();\n int I = sc.nextInt();\n int t = sc.nextInt();\n sc.nextLine();\n char[][] arr = new char[f][I];\n for(int i =0; i < f; i++){\n char[] nl = sc.nextLine().toCharArray();\n for (int j = 0; j < I; j++) {\n arr[i][j] = nl[j];\n }\n }\n int ans = 0;\n for (int i = 0; i < I; i++) {\n int count = 0;\n for (int j = 0; j < f; j++) {\n if(arr[j][i] == 'Y'){\n count++;\n }\n }\n if(count>=t){\n ans++;\n }\n }\n System.out.println(ans);\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "70e29da25091435409fc6e0623035f83", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "package codeforces\n\nimport codeforces.kotlinheroes4.readInt\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(readInt()))\n\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "48e7e0ec02a834016cf2047689e5cadc", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "class 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": "f7005102fcc011001ad82ece7daf7bb3", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.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 n = readInt()\n println(simpleFac(n) / n / (n / 2))\n}\n\nfun simpleFac(n: Int): Long {\n var f = 1L\n for (i in 2..n) {\n f *= i\n }\n\n return f\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f17e787f846eece4aca97dcfdc56fec2", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun getComb(n: Int): Long {\n var u: Long = 1\n var d: Long = 1\n for (i in n downTo (n/2+1)) {\n u *= i.toLong()\n }\n for (i in 1..n/2) {\n d *= i.toLong()\n }\n return u/d\n}\n\nfun getPSq(n: Int): Long {\n var ans: Long = 1\n for (i in 1..n) {\n ans *= i.toLong()\n }\n return ans * ans\n}\n\nfun main() {\n val reader = BufferedReader(InputStreamReader(System.`in`))\n val writer = BufferedWriter(OutputStreamWriter(System.out))\n\n val t = reader.readLine().toInt()\n\n val c = getComb(t) / 2\n val p = getPSq(t/2-1)\n val ans = c*p\n writer.write(\"$ans\\n\")\n //tct/2\n \n writer.flush()\n reader.close()\n writer.close()\n return\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7b6141bdecec718849847f847203327a", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun pow(a : Long, b : Long) : Long{\n return if(b == 0L) 1\n else if(b % 2 == 1L) pow(a, b - 1) * a\n else pow(a, b / 2) * pow(a, b / 2)\n}\n\n\nfun factorial(a : Long) : Long{\n return if(a == 1L) 1\n else factorial(a - 1) * a\n}\n\n\nfun main(){\n val n = readLine()!!.toLong()\n val f = factorial(n)\n val e = pow((n / 2), 2) * 2\n print(f / e)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "17415e2a3e9c09996e5c3f30be4ac234", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readInt()\n\n val k = n/2\n var factorial = 1L\n for (i in 1..n) factorial *= i\n\n println(factorial/(2 * k * k))\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dbbfcb142eecd095159df8b784bd98b3", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.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 var a = sc.nextInt()\n var b = 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": "658618df88693d6a9ff737cd2a809558", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (k, p) = readLine()!!.split(\" \").map(String::toLong)\n var result = 0L\n for (i in 1..k) {\n result += (i.toString() + i.toString().reversed()).toLong()\n result %= p\n }\n print(result)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "00051203245bdb0626225f6b4ff073e6", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val n = r.readLine()!!.split(\" \").map { it.toInt() }\n val n = r.readLine()!!.toInt()\n val min = n/7*2 + if (n%7==6) 1 else 0\n val max = n/7*2+ minOf(2, n%7)\n println(\"$min $max\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "85adcb1f0914b0e6fc87f1f07ce302f1", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\n \nclass InputReader(stream: InputStream) {\n \n private var r = BufferedReader(InputStreamReader(stream), 32768)\n private var t = StringTokenizer(\"\")\n private fun next(): String {\n while (!t.hasMoreTokens()) t = StringTokenizer(r.readLine())\n return t.nextToken()\n }\n \n fun nextInt() = java.lang.Integer.parseInt(next())\n fun nextLong() = java.lang.Long.parseLong(next())\n fun nextDouble() = java.lang.Double.parseDouble(next())\n fun nextLine() = r.readLine()!!\n fun nextIntArray(n: Int): ArrayList {\n val v = ArrayList()\n for (i in 0 until n) v.add(nextInt())\n return v\n }\n}\n \nvar cin: InputReader = InputReader(System.`in`)\nvar cout: PrintWriter = PrintWriter(System.`out`)\n \nfun main() {\n solve()\n cout.close()\n}\n \nfun solve() {\n val k = cin.nextInt()\n val n = cin.nextLine().toCharArray()\n \n if (n.take(k / 2).sumBy { it.toInt() } == n.takeLast(k - k / 2).sumBy { it.toInt() }\n && n.all { it == '4' || it == '7' })\n cout.print(\"YES\")\n else \n cout.print(\"NO\")\n \n \n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9be99c6d9f5b2425b7eb651e76e4889d", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.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 N = S.length\n var ans = 0\n\n for (num in 0 until 100_000_000) {\n if (num % 25 != 0) continue\n val numStr = num.toString()\n if (numStr.length != N) continue // 0\u3092\u542b\u3080leading0\u304c\u306a\u3044\u6570\u5024\n\n var x = -1\n var ok = true\n for (i in numStr.indices) {\n when(S[i]) {\n '_' -> {}\n 'X' -> {\n if (x == -1) {\n x = numStr[i] - '0'\n } else {\n ok = ok && numStr[i] - '0' == x\n }\n }\n else -> ok = ok && numStr[i] == S[i]\n }\n }\n if (ok) ans++\n }\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 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": "1f9252c1e9d6c793548c4dc4717f88e8", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main(args: Array) {\n var (n, k, x) = readLine()!!.split(\" \").map(String::toInt)\n val arr = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n if(n == 1) {\n println(0)\n return\n }\n var i = 0\n\n var maxCount = 0\n while (i < n){\n if(arr[i] == x && arr[i+1] == x) {\n var count = 2\n var l = 1\n var r = 1\n while (i-l>0 && i+r+1 < n) {\n if(arr[i-l] == arr[i+r+1]) {\n if(i-l-1 >= 0) {\n if(i+r+2 < n) {\n if(arr[i-l] == arr[i-l-1] && arr[i+r+1] == arr[i+r+2]) {\n count+=4\n l+=2\n r+=2\n } else if(arr[i-l] == arr[i-l-1]) {\n count+=3\n l+=2\n r++\n } else if(arr[i+r+1] == arr[i+r+2]) {\n count+=3\n l++\n r+=2\n } else {\n break\n }\n } else {\n if(arr[i-l] == arr[i-l-1]) {\n count+=3\n l+=2\n r++\n } else {\n break\n }\n }\n } else {\n if(i+r+2 < n) {\n if(arr[i+r+1] == arr[i+r+2]) {\n count+=3\n l++\n r+=2\n }\n } else {\n break\n }\n }\n } else {\n break\n }\n }\n if (maxCount < count) maxCount = count\n i++\n }\n i++\n }\n println(maxCount)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4fcf74cf78290c6136cf946f48694eb6", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main(args: Array) {\n var (n, k, x) = readLine()!!.split(\" \").map(String::toInt)\n val arr = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n if(n == 1) {\n println(0)\n return\n }\n var i = 0\n\n var maxCount = 0\n while (i < n){\n if(arr[i] == x && arr[i+1] == x) {\n var count = 2\n var l = 1\n var r = 1\n while (i-l>0 && i+1+r < n) {\n if(arr[i-l] == arr[i+r+1]) {\n when {\n arr[i-l] == arr[i-l-1] && arr[i+r+1] == arr[i+r+2] -> {\n count+=4\n l-=2\n r+=2\n }\n arr[i-l] == arr[i-l-1] -> {\n count+=3\n l-=2\n r++\n }\n arr[i+r+1] == arr[i+r+2] -> {\n count+=3\n l--\n r+=2\n }\n }\n }\n }\n if (maxCount < count) maxCount = count\n i++\n }\n i++\n }\n println(maxCount)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0fe5c5d3d78716d33b74fcaa99a70ea0", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main(args: Array) {\n var (n, k, x) = readLine()!!.split(\" \").map(String::toInt)\n val arr = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n if(n == 1) {\n println(0)\n return\n }\n var i = 0\n\n var maxCount = 0\n while (i < n){\n if(arr[i] == x && arr[i+1] == x) {\n var count = 2\n var l = 1\n var r = 1\n while (i-l>0 && i+r+1 < n) {\n if(arr[i-l] == arr[i+r+1]) {\n if(i-l-1 >= 0) {\n if(i+r+2 < n) {\n if(arr[i-l] == arr[i-l-1] && arr[i+r+1] == arr[i+r+2]) {\n count+=4\n l-=2\n r+=2\n } else if(arr[i-l] == arr[i-l-1]) {\n count+=3\n l-=2\n r++\n } else if(arr[i+r+1] == arr[i+r+2]) {\n count+=3\n l--\n r+=2\n }\n } else {\n if(arr[i-l] == arr[i-l-1]) {\n count+=3\n l-=2\n r++\n }\n }\n } else {\n if(i+r+2 < n) {\n if(arr[i+r+1] == arr[i+r+2]) {\n count+=3\n l--\n r+=2\n }\n }\n }\n }\n }\n if (maxCount < count) maxCount = count\n i++\n }\n i++\n }\n println(maxCount)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "df9930ff080b7f4829730b5f91eb343c", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner;\n\nfun main(args: Array) {\n var scan = Scanner(System.`in`);\n\n var n = scan.nextInt();\n var s = IntArray(n);\n for (i in 0 until n) {\n s[i] = scan.nextInt();\n }\n\n var other = IntArray(n);\n var best = IntArray(n);\n best[n-1] = s[n-1];\n other[n-1] = 0;\n for (i in (n-2) downTo 0) {\n var takethis = s[i] + other[i+1];\n var givethis = best[i+1];\n if (takethis > givethis) {\n best[i] = takethis;\n other[i] = givethis;\n } else {\n best[i] = givethis;\n other[i] = takethis;\n }\n }\n System.out.printf(\"%d %d\\n\", other[0], best[0]);\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9ed9cac7b495b23277050b2ecedf7d9e", "src_uid": "414540223db9d4cfcec6a973179a0216", "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.lang.StringBuilder\nimport java.util.PriorityQueue\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 percent = ModInt(100).inverse()\n\n val n = readInt()\n val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }\n\n val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))\n\n tree.build { i ->\n Seg(\n ll = pipes[i].p.not(),\n lr = ModInt(0),\n rl = ModInt(0),\n rr = pipes[i].p,\n ban = NONE\n )\n }\n\n val cols = ArrayList(2*n)\n\n for(i in 0 until n-1) {\n val a = pipes[i]\n val b = pipes[i+1]\n\n val d = b.x - a.x\n cols.add(Collision(i, RL, d, a.v + b.v))\n if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))\n else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))\n }\n\n cols.sortWith(Collision.comparator)\n\n var currProb = ModInt(1)\n var ans = ModInt(0)\n for((a, t, d, v) in cols) {\n tree[a] = tree[a]!!.copy(ban = t)\n val prob = tree[0, tree.size]!!.sum\n ans += (currProb - prob) * d / v\n currProb = prob\n }\n\n println(ans.int)\n}\n\ninline fun ModInt.not() = ModInt(1) - this\n\ndata class Pipe(val x: Int, val v: Int, val p: ModInt)\ndata class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {\n companion object {\n val comparator = Comparator { a, b ->\n (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)\n }\n }\n\n inline val b get() = a + 1\n}\n\ninline class CollisionType(val i: Int)\ninline val NONE get() = CollisionType(0)\ninline val LL get() = CollisionType(1)\ninline val RL get() = CollisionType(2)\ninline val RR get() = CollisionType(3)\n\ndata class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {\n val sum get() = ll + lr + rl + rr\n\n operator fun plus(b: Seg): Seg {\n // LR never banned\n var cll = ll * b.rl\n var clr = ll * b.rr\n var crl = rl * b.rl\n var crr = rl * b.rr\n\n // any ban implies RL banned\n if(ban == NONE) {\n cll += lr * b.ll\n clr += lr * b.lr\n crl += rr * b.ll\n crr += rr * b.lr\n }\n\n if(ban != LL) {\n cll += ll * b.ll\n clr += ll * b.lr\n crl += rl * b.ll\n crr += rl * b.lr\n }\n\n if(ban != RR) {\n cll += lr * b.rl\n clr += lr * b.rr\n crl += rr * b.rl\n crr += rr * b.rr\n }\n\n return Seg(cll, clr, crl, crr, b.ban)\n }\n}\n\nclass SegmentTree(\n val size: Int,\n val identityValue: T,\n val combiner: (T, T) -> T) {\n\n /* degenericization helpers\n val identityValue: T = TODO()\n fun combiner(a: T, b: T): T = TODO()\n */\n\n @Suppress(\"UNCHECKED_CAST\")\n private val array = Array(2 * size) { identityValue } as Array\n\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n val asList: List by lazy {\n object : AbstractList() {\n override val size: Int get() = this@SegmentTree.size\n override fun get(index: Int): T = this@SegmentTree[index]\n }\n }\n\n fun build(generator: (Int) -> T) {\n for(i in 0 until size) {\n array[i + size] = generator(i)\n }\n for(i in size-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** instantiates values from an iterable, O(n) time */\n fun copyFrom(iterable: Iterable) {\n run {\n iterable.forEachIndexed { i, t ->\n if(i > lastIndex) return@run\n array[i + size] = t\n }\n }\n for(i in size-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Updates a value, O(log n) time */\n operator fun set(index: Int, value: T) {\n require(index in 0 until size)\n var i = index + size\n array[i] = value\n while(true) {\n i = i shr 1\n if(i <= 0) break\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Gets a value by its index, O(1) time */\n operator fun get(index: Int): T {\n require(index in 0 until size)\n return array[index + size]\n }\n\n /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */\n operator fun get(start: Int, endExclusive: Int): T {\n var l = maxOf(start, 0) + size\n var r = minOf(endExclusive, size) + size\n\n // two accumulators to support non-commutative monoids\n var lAcc = identityValue\n var rAcc = identityValue\n\n while(l < r) {\n if(l and 1 == 1) {\n lAcc = combiner(lAcc, array[l++])\n }\n if(r and 1 == 1) {\n rAcc = combiner(array[--r], rAcc)\n }\n\n l = l shr 1\n r = r shr 1\n }\n\n return combiner(lAcc, rAcc)\n }\n\n operator fun get(range: IntRange) = get(range.first, range.last + 1)\n}\n\n/** Converts a semigroup to a monoid by using null as the identity value. */\ninline fun nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->\n when {\n a == null -> b\n b == null -> a\n else -> combiner(a, b)\n }\n}\n\nconst val MOD = 998244353\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 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": "4e1727da66e331709891c181ae871082", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.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 percent = ModInt(100).inverse()\n\n val n = readInt()\n val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }\n val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))\n\n tree.build { i ->\n Seg(\n ll = pipes[i].p.not(),\n lr = ModInt(0),\n rl = ModInt(0),\n rr = pipes[i].p,\n ban = NONE\n )\n }\n\n val cols = ArrayList(n-1 shl 1)\n\n for(i in 0 until n-1) {\n val a = pipes[i]\n val b = pipes[i+1]\n\n val d = b.x - a.x\n cols.add(Collision(i, RL, d, a.v + b.v))\n if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))\n else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))\n }\n\n cols.sortWith(Collision.comparator)\n\n val vi = ModIntArray(cols.size) { ModInt(cols[it].v) }.inverseOfEach()\n var currProb = ModInt(1)\n var ans = ModInt(0)\n for(i in cols.indices) {\n val (a, t, d) = cols[i]\n tree[a] = tree[a]!!.copy(ban = t)\n val prob = tree.root!!.sum\n ans += (currProb - prob) * d * vi[i]\n currProb = prob\n }\n\n println(ans.int)\n}\n\ninline fun ModInt.not() = ModInt(1) - this\n\ndata class Pipe(val x: Int, val v: Int, val p: ModInt)\ndata class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {\n companion object {\n val comparator = Comparator { a, b ->\n (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)\n }\n }\n\n inline val b get() = a + 1\n}\n\ntypealias CollisionType = Byte\nconst val NONE: CollisionType = 0\nconst val LL: CollisionType = 1\nconst val RL: CollisionType = 2\nconst val RR: CollisionType = 3\n\ndata class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {\n val sum get() = ll + lr + rl + rr\n\n operator fun plus(b: Seg): Seg {\n // LR never banned\n var cll = ll * b.rl\n var clr = ll * b.rr\n var crl = rl * b.rl\n var crr = rl * b.rr\n\n // any ban implies RL banned\n if(ban == NONE) {\n cll += lr * b.ll\n clr += lr * b.lr\n crl += rr * b.ll\n crr += rr * b.lr\n }\n\n if(ban != LL) {\n cll += ll * b.ll\n clr += ll * b.lr\n crl += rl * b.ll\n crr += rl * b.lr\n }\n\n if(ban != RR) {\n cll += lr * b.rl\n clr += lr * b.rr\n crl += rr * b.rl\n crr += rr * b.rr\n }\n\n return Seg(cll, clr, crl, crr, b.ban)\n }\n}\n\nclass SegmentTree(\n val size: Int,\n val identityValue: T,\n val combiner: (T, T) -> T) {\n\n private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1\n\n /* degenericization helpers\n val identityValue: T = TODO()\n fun combiner(a: T, b: T): T = TODO()\n */\n\n @Suppress(\"UNCHECKED_CAST\")\n private val array = Array(tsize shl 1) { identityValue } as Array\n\n val root get() = array[1]\n\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n val asList: List by lazy {\n object : AbstractList() {\n override val size: Int get() = this@SegmentTree.size\n override fun get(index: Int): T = this@SegmentTree[index]\n }\n }\n\n fun build(generator: (Int) -> T) {\n for(i in 0 until size) {\n array[i + tsize] = generator(i)\n }\n for(i in tsize-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** instantiates values from an iterable, O(n) time */\n fun copyFrom(iterable: Iterable) {\n run {\n iterable.forEachIndexed { i, t ->\n if(i > lastIndex) return@run\n array[i + tsize] = t\n }\n }\n for(i in tsize-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Updates a value, O(log n) time */\n operator fun set(index: Int, value: T) {\n require(index in 0 until size)\n var i = index + tsize\n array[i] = value\n while(true) {\n i = i shr 1\n if(i <= 0) break\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Gets a value by its index, O(1) time */\n operator fun get(index: Int): T {\n require(index in 0 until size)\n return array[index + tsize]\n }\n\n /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */\n operator fun get(start: Int, endExclusive: Int): T {\n var l = maxOf(start, 0) + tsize\n var r = minOf(endExclusive, size) + tsize\n\n // two accumulators to support non-commutative monoids\n var lAcc = identityValue\n var rAcc = identityValue\n\n while(l < r) {\n if(l and 1 == 1) {\n lAcc = combiner(lAcc, array[l++])\n }\n if(r and 1 == 1) {\n rAcc = combiner(array[--r], rAcc)\n }\n\n l = l shr 1\n r = r shr 1\n }\n\n return combiner(lAcc, rAcc)\n }\n\n operator fun get(range: IntRange) = get(range.first, range.last + 1)\n}\n\n/** Converts a semigroup to a monoid by using null as the identity value. */\ninline fun nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->\n when {\n a == null -> b\n b == null -> a\n else -> combiner(a, b)\n }\n}\n\nfun ModIntArray.inverseOfEach(): ModIntArray {\n if(isEmpty()) return this\n var acc = ModInt(1)\n val res = ModIntArray(size) { i ->\n acc *= this[i]\n acc\n }\n acc = res[lastIndex].inv_unmemoized()\n for(i in lastIndex downTo 1) {\n res[i] = acc * res[i-1]\n acc *= this[i]\n }\n res[0] = acc\n\n return res\n}\n\nconst val MOD = 998244353\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": "233729b1a72d1fed659e804a03b4094e", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.PriorityQueue\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 percent = ModInt(100).inverse()\n\n val n = readInt()\n val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }\n val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))\n\n tree.build { i ->\n Seg(\n ll = pipes[i].p.not(),\n lr = ModInt(0),\n rl = ModInt(0),\n rr = pipes[i].p,\n ban = NONE\n )\n }\n\n val cols = ArrayList(2*n)\n\n for(i in 0 until n-1) {\n val a = pipes[i]\n val b = pipes[i+1]\n\n val d = b.x - a.x\n cols.add(Collision(i, RL, d, a.v + b.v))\n if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))\n else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))\n }\n\n cols.sortWith(Collision.comparator)\n\n var currProb = ModInt(1)\n var ans = ModInt(0)\n for((a, t, d, v) in cols) {\n tree[a] = tree[a]!!.copy(ban = t)\n val prob = tree.root!!.sum\n ans += (currProb - prob) * d / v\n currProb = prob\n }\n\n println(ans.int)\n}\n\ninline fun ModInt.not() = ModInt(1) - this\n\ndata class Pipe(val x: Int, val v: Int, val p: ModInt)\ndata class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {\n companion object {\n val comparator = Comparator { a, b ->\n (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)\n }\n }\n\n inline val b get() = a + 1\n}\n\ninline class CollisionType(val i: Int)\ninline val NONE get() = CollisionType(0)\ninline val LL get() = CollisionType(1)\ninline val RL get() = CollisionType(2)\ninline val RR get() = CollisionType(3)\n\ndata class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {\n val sum get() = ll + lr + rl + rr\n\n operator fun plus(b: Seg): Seg {\n // LR never banned\n var cll = ll * b.rl\n var clr = ll * b.rr\n var crl = rl * b.rl\n var crr = rl * b.rr\n\n // any ban implies RL banned\n if(ban.i == NONE.i) {\n cll += lr * b.ll\n clr += lr * b.lr\n crl += rr * b.ll\n crr += rr * b.lr\n }\n\n if(ban.i != LL.i) {\n cll += ll * b.ll\n clr += ll * b.lr\n crl += rl * b.ll\n crr += rl * b.lr\n }\n\n if(ban.i != RR.i) {\n cll += lr * b.rl\n clr += lr * b.rr\n crl += rr * b.rl\n crr += rr * b.rr\n }\n\n return Seg(cll, clr, crl, crr, b.ban)\n }\n}\n\nclass SegmentTree(\n val size: Int,\n val identityValue: T,\n val combiner: (T, T) -> T) {\n\n private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1\n\n /* degenericization helpers\n val identityValue: T = TODO()\n fun combiner(a: T, b: T): T = TODO()\n */\n\n @Suppress(\"UNCHECKED_CAST\")\n private val array = Array(2 * tsize) { identityValue } as Array\n\n val root get() = array[1]\n\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n val asList: List by lazy {\n object : AbstractList() {\n override val size: Int get() = this@SegmentTree.size\n override fun get(index: Int): T = this@SegmentTree[index]\n }\n }\n\n fun build(generator: (Int) -> T) {\n for(i in 0 until size) {\n array[i + tsize] = generator(i)\n }\n for(i in tsize-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** instantiates values from an iterable, O(n) time */\n fun copyFrom(iterable: Iterable) {\n run {\n iterable.forEachIndexed { i, t ->\n if(i > lastIndex) return@run\n array[i + tsize] = t\n }\n }\n for(i in tsize-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Updates a value, O(log n) time */\n operator fun set(index: Int, value: T) {\n require(index in 0 until size)\n var i = index + tsize\n array[i] = value\n while(true) {\n i = i shr 1\n if(i <= 0) break\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Gets a value by its index, O(1) time */\n operator fun get(index: Int): T {\n require(index in 0 until size)\n return array[index + tsize]\n }\n\n /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */\n operator fun get(start: Int, endExclusive: Int): T {\n var l = maxOf(start, 0) + tsize\n var r = minOf(endExclusive, size) + tsize\n\n // two accumulators to support non-commutative monoids\n var lAcc = identityValue\n var rAcc = identityValue\n\n while(l < r) {\n if(l and 1 == 1) {\n lAcc = combiner(lAcc, array[l++])\n }\n if(r and 1 == 1) {\n rAcc = combiner(array[--r], rAcc)\n }\n\n l = l shr 1\n r = r shr 1\n }\n\n return combiner(lAcc, rAcc)\n }\n\n operator fun get(range: IntRange) = get(range.first, range.last + 1)\n}\n\n/** Converts a semigroup to a monoid by using null as the identity value. */\ninline fun nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->\n when {\n a == null -> b\n b == null -> a\n else -> combiner(a, b)\n }\n}\n\nconst val MOD = 998244353\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 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": "0ebcaed6f0d8976d62a83117d1cf8b73", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0} {"lang": "Kotlin", "source_code": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.PriorityQueue\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 percent = ModInt(100).inverse()\n\n val n = readInt()\n val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }\n\n val tree = SegmentTree(n-1, null, nullIdentityCombiner(Seg::plus))\n\n tree.build { i ->\n Seg(\n ll = pipes[i].p.not() * pipes[i+1].p.not(),\n lr = pipes[i].p.not() * pipes[i+1].p,\n rl = pipes[i].p * pipes[i+1].p.not(),\n rr = pipes[i].p * pipes[i+1].p\n )\n }\n\n val cols = ArrayList(2*n)\n\n for(i in 0 until n-1) {\n val a = pipes[i]\n val b = pipes[i+1]\n\n val d = b.x - a.x\n cols.add(Collision(i, RL, d, a.v + b.v))\n if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))\n else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))\n }\n\n cols.sortWith(Collision.comparator)\n\n var currProb = ModInt(1)\n var ans = ModInt(0)\n for((a, t, d, v) in cols) {\n tree[a] = tree[a]!!.ban(t)\n val prob = tree[0, tree.size]!!.sum\n ans += (currProb - prob) * d / v\n currProb = prob\n }\n\n println(ans.int)\n}\n\ninline fun ModInt.not() = ModInt(1) - this\n\ndata class Pipe(val x: Int, val v: Int, val p: ModInt)\ndata class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {\n companion object {\n val comparator = Comparator { a, b ->\n (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)\n }\n }\n\n inline val b get() = a + 1\n}\n\ninline class CollisionType(val i: Int)\ninline val LL get() = CollisionType(0)\ninline val LR get() = CollisionType(1)\ninline val RL get() = CollisionType(2)\ninline val RR get() = CollisionType(3)\n\nclass Seg(private val values: IntArray) {\n constructor(ll: ModInt, lr: ModInt, rl: ModInt, rr: ModInt): this(intArrayOf(ll.int, lr.int, rl.int, rr.int))\n\n operator fun get(collisionType: CollisionType) = ModInt(values[collisionType.i])\n val ll get() = ModInt(values[0])\n val lr get() = ModInt(values[1])\n val rl get() = ModInt(values[2])\n val rr get() = ModInt(values[3])\n\n operator fun plus(b: Seg): Seg {\n val al = ll + lr\n val ar = rl + rr\n val bl = b.ll + b.rl\n val br = b.lr + b.rr\n\n return Seg(\n ll = al * bl,\n lr = al * br,\n rl = ar * bl,\n rr = ar * br\n )\n }\n\n val sum get() = ModIntArray(values).sum()\n\n fun ban(collisionType: CollisionType) = Seg(values.copyOf().also { it[collisionType.i] = 0 })\n}\n\nclass SegmentTree(\n val size: Int,\n val identityValue: T,\n val combiner: (T, T) -> T) {\n\n /* degenericization helpers\n val identityValue: T = TODO()\n fun combiner(a: T, b: T): T = TODO()\n */\n\n @Suppress(\"UNCHECKED_CAST\")\n private val array = Array(2 * size) { identityValue } as Array\n\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n val asList: List by lazy {\n object : AbstractList() {\n override val size: Int get() = this@SegmentTree.size\n override fun get(index: Int): T = this@SegmentTree[index]\n }\n }\n\n fun build(generator: (Int) -> T) {\n for(i in 0 until size) {\n array[i + size] = generator(i)\n }\n for(i in size-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** instantiates values from an iterable, O(n) time */\n fun copyFrom(iterable: Iterable) {\n run {\n iterable.forEachIndexed { i, t ->\n if(i > lastIndex) return@run\n array[i + size] = t\n }\n }\n for(i in size-1 downTo 1) {\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Updates a value, O(log n) time */\n operator fun set(index: Int, value: T) {\n require(index in 0 until size)\n var i = index + size\n array[i] = value\n while(true) {\n i = i shr 1\n if(i <= 0) break\n array[i] = combiner(array[i shl 1], array[i shl 1 or 1])\n }\n }\n\n /** Gets a value by its index, O(1) time */\n operator fun get(index: Int): T {\n require(index in 0 until size)\n return array[index + size]\n }\n\n /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */\n operator fun get(start: Int, endExclusive: Int): T {\n var l = maxOf(start, 0) + size\n var r = minOf(endExclusive, size) + size\n\n // two accumulators to support non-commutative monoids\n var lAcc = identityValue\n var rAcc = identityValue\n\n while(l < r) {\n if(l and 1 == 1) {\n lAcc = combiner(lAcc, array[l++])\n }\n if(r and 1 == 1) {\n rAcc = combiner(array[--r], rAcc)\n }\n\n l = l shr 1\n r = r shr 1\n }\n\n return combiner(lAcc, rAcc)\n }\n\n operator fun get(range: IntRange) = get(range.first, range.last + 1)\n}\n\n/** Converts a semigroup to a monoid by using null as the identity value. */\ninline fun nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->\n when {\n a == null -> b\n b == null -> a\n else -> combiner(a, b)\n }\n}\n\nconst val MOD = 998244353\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 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": "86bf7e75c77c8544ea85920b8ca2811c", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.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_007\nclass SegmentTree(n: Int) {\n private val N =\n if (Integer.highestOneBit(n) == n) n\n else Integer.highestOneBit(n) shl 1\n\n private val zero = 0\n\n private val dat = IntArray(2 * N){zero}\n\n private inline fun f(a: Int, b: Int) = run{max(a, b)}\n\n fun update(i: Int, a: Int) {\n var ix = i + N\n dat[ix] = a\n while(ix > 1) {\n dat[ix shr 1] = f(dat[ix], dat[ix xor 1])\n ix = ix shr 1\n }\n }\n\n /**\n * [a, b)\n */\n fun query(a: Int, b: Int): Int {\n var res: Int = zero\n var left = a + N\n var right = b - 1 + N\n\n while(left <= right) {\n if ((left and 1) == 1) res = f(res, dat[left])\n if ((right and 1) == 0) res = f(res, dat[right])\n left = (left + 1) shr 1 // \u53f3\u306e\u5b50\u4f9b\u306a\u3089\u53f3\u306e\u89aa\u306b\u79fb\u52d5\n right = (right - 1) shr 1 // \u5de6\u306e\u5b50\u4f9b\u306a\u3089\u5de6\u306e\u89aa\u306b\u79fb\u52d5\n }\n\n return res\n }\n\n // \u6761\u4ef6\u3092\u6e80\u305f\u3059\u304b\u3002max\u306a\u3089 '>' min\u306a\u3089 '<' \u304c\u4f7f\u3048\u308b\n private inline fun contains(a: Int, x: Int): Boolean = a < x\n /**\n * @param x \u5de6\u53f3\u3069\u3061\u3089\u304b\u3089\u304b\u6700\u521d\u306b a < x \u306b\u306a\u308b\u5834\u6240\u3092\u63a2\u3059\n * @param [a, b) \u8abf\u3079\u308b\u7bc4\u56f2\n * @return -1\n */\n fun find(x: Int, a: Int = 0, b: Int = N, k: Int = 1, l: Int = 0, r: Int = N): Int {\n if (a >= r || l >= b) return -1// \u30ce\u30fc\u30c9\u304c\u7bc4\u56f2\u304b\u3089\u306f\u305a\u308c\u3066\u308b\n if (!contains(dat[k], x)) return -1\n if (l + 1 == r) return l // 0-indexed\n\n val m = (l + r) / 2\n val lft = k * 2\n val rgt = lft + 1\n\n // \u5de6\u304b\u3089\u63a2\u3059\u3002\u53f3\u304b\u3089\u63a2\u3057\u305f\u3044\u5834\u5408\u306f\u5de6\u53f3\u3092\u9006\u306b\u3059\u308c\u3070\u3044\u3044\n val ans = find(x, a, b, lft, l, m)\n if (ans != -1) return ans\n return find(x, a, b, rgt, m, r)\n }\n}\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val T = ni()\n val (A, M) = run {\n val A = na(N)\n val B = A.distinct() as MutableList\n B.sort()\n Pair(A.map{B.indexOf(it)}.toIntArray(), B.size)\n }\n\n debug(A)\n debug{\"M:$M\"}\n\n fun simulate(t: Int, s: Int): IntArray {\n debug{\"simulate($t $s)\"}\n val dp = SegmentTree(M - s)\n for (times in 0 until t) {\n for (a in A) {\n if (a < s) continue\n dp.update(a - s, dp.query(0, a - s + 1) + 1)\n }\n }\n val res = IntArray(M)\n for (i in 0 until M - s) {\n res[i + s] = dp.query(i, i + 1)\n }\n return res\n }\n\n val SIM_LEN = 1000\n var ans = 0L\n if (T <= SIM_LEN * 2) {\n ans = simulate(T, 0).max()!!.toLong()\n } else {\n val pre = simulate(SIM_LEN, 0)\n for (i in 0 until M) {\n val med = A.count{it == i} * (T - SIM_LEN * 2).toLong()\n val post = simulate(SIM_LEN, i)\n debug(pre)\n debug(post)\n ans = max(ans, pre[i] + med + post.max()!!)\n }\n }\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() + 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": "b84772c6bbb7ff8d7d57cb8f1e5c5c11", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.system.exitProcess\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n var a = sc.nextInt()\n var b = sc.nextInt()\n var c = sc.nextInt()\n a *= 10\n for(i in 1..100000) {\n if(c == (a / b) % 10) {\n println(i)\n exitProcess(0)\n }\n a *= 10\n }\n println(-1)\n}\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "157968046bf5ea9f761e26dc4ad2f448", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun getMaxTotalCost(a: Int, b: Int, c: Int, d: Int,\n firstTypeCost: Int, secondTypeCost: Int): Int {\n var firstCost = 0\n var secondCost = 0\n\n if (a>0 && d>0) {\n firstCost = firstTypeCost + getMaxTotalCost(a-1, b, c, d-1,\n firstTypeCost, secondTypeCost)\n }\n\n if (b>0 && c>0 && d>0) {\n secondCost = secondTypeCost + getMaxTotalCost(a, b-1, c-1, d-1,\n firstTypeCost, secondTypeCost)\n }\n\n return max(firstCost, secondCost)\n}\n\nfun main() {\n val a = readLine()!!.toInt()\n val b = readLine()!!.toInt()\n val c = readLine()!!.toInt()\n val d = readLine()!!.toInt()\n val firstTypeCost = readLine()!!.toInt()\n val secondTypeCost = readLine()!!.toInt()\n\n val res = getMaxTotalCost(a, b, c, d, firstTypeCost, secondTypeCost)\n println(res)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "07d43d18bc96771db98e400034ccf164", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main() {\n var a = readLine()!!.toInt()\n var b = readLine()!!.toInt()\n var c = readLine()!!.toInt()\n var d = readLine()!!.toInt()\n var e = readLine()!!.toInt()\n var f = readLine()!!.toInt()\n\n var ans = 0\n for (i in 0..d) {\n val sum = min(a, i) * e + min(min(b, c), d - i) * f\n ans = max(ans, sum)\n }\n\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f613557bba07cd490b324e67cdc5a089", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n\n val scanner = Scanner(System.`in`)\n\n val n = scanner.nextInt()\n\n val list = mutableSetOf()\n\n for (i in 0..n - 1) {\n val tmp = scanner.nextInt()\n list.add(tmp)\n }\n\n if (list.size != 2)\n println(\"NO\")\n\n val llist = list.toList()\n val f = llist[0]\n val s = llist[1]\n if (f == s) {\n println(\"YES\")\n println(\"${llist[0]} ${llist[1]}\")\n\n } else {\n println(\"NO\")\n }\n\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a74ecbf7616f0c0c014dfc0587d1f5ad", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.system.exitProcess\n\nfun main(){\n var n = readLine()!!.toInt()\n var mp = mutableMapOf()\n for(i in 1..n){\n var a = readLine()!!.toInt()\n if(mp.contains(a)) mp.set(a, mp[a]!! + 1)\n else mp.set(a, 1)\n }\n if(mp.size == 2){\n var s = mp.values.toList()\n if(s[0] == s[1]){\n println(\"YES\")\n s = mp.keys.toList()\n print(\"${s[0]} ${s[1]}\");\n exitProcess(0)\n }\n }\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2f94505a0166f21809128e089e31676c", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n\n val scanner = Scanner(System.`in`)\n\n val n = scanner.nextInt()\n\n val list = ArrayList>()\n\n for (i in 0..200) {\n list.add(i to 0)\n }\n\n for (i in 0 until n) {\n val tmp = scanner.nextInt()\n list[tmp] = list[tmp].first to list[tmp].second + 1\n }\n\n val nonnull = list\n .filter { it.second != 0 }\n .sortedByDescending { it.second }\n\n if (nonnull.size!=2) {\n println(\"NO\")\n }\n\n if (nonnull[0].second == nonnull[1].second) {\n println(\"YES\")\n println(\"${nonnull[0].first} ${nonnull[1].first}\")\n } else {\n println(\"NO\")\n }\n\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "73d52dc7507fb421edef5445f50ef730", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n\n val lemons = readInt()\n val apples = readInt()\n val pears = readInt()\n val lemonsSol = min(lemons, min(apples / 2, pears / 4))\n print(7 * lemonsSol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d9001194da37efea386ef0d04aa4880e", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n val a = r.readLine()!!.toInt()\n val b = r.readLine()!!.toInt()\n val c = r.readLine()!!.toInt()\n println(minOf(a, b/2, c/4))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "969332b340f03959b66962253f1f30b7", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.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 if (a != b)\n ans.add(b)\n print(\"\" + ans.size + \" \" + ans.joinToString(\" \") + \"\\n\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d61482604dc9ebfe9179624bf3f6bef8", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.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 = na(3)\n A.sort()\n var ans = 0\n while(A[2] - A[0] >= 2) {\n val v = min(A[1], (A[2] - A[0]) / 2)\n if (v == 0) break\n A[2] -= v * 2\n A[1] -= v\n ans += v\n A.sort()\n }\n ans += A[0]\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": "0fddc784d4666d11b5f7818891cc241e", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.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.higher(r)!!)\n\n\n\n\n\n }\n done()\n}\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "34cced0e0c01d1c2e2a78e8088936b1a", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "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-----------------------\nprivate fun solve() {\n val r=readInt()\n val a=IntArray(9)\n a[0]=1200\n a[1]=1400\n a[2]=1600\n a[3]=1900\n a[4]=2100\n a[5]=2300\n a[6]=2400\n a[7]=2600\n a[8]=3000\n for(i in a.indices){\n if(r 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 true) && (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) > 0", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "12ffdbe51ccf3eb5ba3c389c999356e1", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.09.02 at 15:52:32 BST\r\nimport java.io.BufferedInputStream\r\nimport java.io.File\r\nimport java.io.PrintWriter\r\nimport kotlin.math.ln\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\ninfix fun Int.modMinus(b:Int):Int{ val ans = this - b;return if(ans < 0) ans + pI else ans }\r\nfun Int.inverse():Int = intPow(this,pI-2,pI)\r\ninfix fun Int.modDivide(b:Int):Int{ return this modM (b.inverse()) }\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\nobject sieve{\r\n\r\n const val sieveMx = 200005\r\n val primeOf = IntArray(sieveMx + 1)\r\n var primeCounter = 0\r\n val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)\r\n val primes = IntArray(primeUpperBound)\r\n var sieveCalculated = false\r\n val nextPrime = IntArray(sieveMx+1)\r\n val nextPrimePower = IntArray(sieveMx+1)\r\n val afterPrimePowerDivison = IntArray(sieveMx+1)\r\n var mobius = IntArray(0)\r\n\r\n var factors:List> = mutableListOf()\r\n\r\n fun calculateSieveFast(){\r\n if(sieveCalculated){\r\n return\r\n }\r\n sieveCalculated = true\r\n for(i in 2..sieveMx){\r\n if(primeOf[i] == 0 ){\r\n primeOf[i] = i\r\n primes[primeCounter] = i\r\n primeCounter += 1\r\n }\r\n for(j in 0 until primeCounter){\r\n val p = primes[j]\r\n val pd = p * i\r\n if(p <= i && pd <= sieveMx){\r\n primeOf[pd] = p\r\n }else{\r\n break\r\n }\r\n }\r\n }\r\n }\r\n fun preparePrimePower(){\r\n nextPrime[1] = -1\r\n nextPrimePower[1] = -1\r\n afterPrimePowerDivison[1] = 1\r\n for(i in 2..sieveMx){\r\n val p = primeOf[i]\r\n val new = i / p\r\n nextPrime[i] = p\r\n if(nextPrime[new] == p){\r\n nextPrimePower[i] = nextPrimePower[new]\r\n afterPrimePowerDivison[i] = afterPrimePowerDivison[new]\r\n }else{\r\n afterPrimePowerDivison[i] = new\r\n }\r\n nextPrimePower[i] += 1\r\n }\r\n }\r\n fun primeID():Pair{\r\n assert(sieveCalculated)\r\n var now =0\r\n val primes = IntArray(primeCounter)\r\n val id = IntArray(sieveMx) {\r\n if (it > 0 && primeOf[it] == it) {\r\n primes[now] = it\r\n return@IntArray now++\r\n } else -1}\r\n return Pair(primes,id)\r\n }\r\n fun prepareFactors(){\r\n // 700ms in 1M\r\n // shoudl not be used for 1M\r\n // 200ms codeforces for 200k\r\n factors = List(sieveMx + 1){ mutableListOf()}\r\n factors[1].add(1)\r\n\r\n for(i in 2..sieveMx){\r\n val p = nextPrime[i]\r\n val a = nextPrimePower[i]\r\n val old = afterPrimePowerDivison[i]\r\n\r\n var here = 1\r\n repeat(a+1){\r\n for(c in factors[old]){\r\n factors[i].add(c * here )\r\n }\r\n here *= p\r\n }\r\n// factors[1].ad\r\n// factors[i].addAll(i.factors())\r\n }\r\n }\r\n fun calculateMobius(){\r\n assert(sieveCalculated)\r\n mobius = IntArray(sieveMx + 1)\r\n mobius[1] = 1\r\n for(i in 2..sieveMx){\r\n val p = primeOf[i]\r\n if(p == primeOf[i/p]){\r\n mobius[i] = 0\r\n }else{\r\n mobius[i] = -1 * mobius[i/p]\r\n }\r\n }\r\n }\r\n}\r\ninline fun Int.eachPrimePower(act:(Int,Int)->Unit){\r\n assert(sieve.sieveCalculated)\r\n var here = this\r\n while(here > 1){\r\n act(sieve.nextPrime[here], sieve.nextPrimePower[here])\r\n here = sieve.afterPrimePowerDivison[here]\r\n }\r\n}\r\nfun Int.factors():List{\r\n val ret = mutableListOf(1)\r\n this.eachPrimePower { p, e ->\r\n val s = ret.toList()\r\n var now = 1\r\n repeat(e){\r\n now *= p\r\n ret.addAll(s.map{it * now})\r\n }\r\n }\r\n return ret\r\n}\r\nfun totient(a:Int):Int{\r\n var ret = a\r\n a.eachPrimePower{\r\n p, _ ->\r\n ret /= p\r\n ret *= (p-1)\r\n }\r\n return ret\r\n}\r\nfun Int.numOfDivisors():Int{\r\n var ret = 1\r\n this.eachPrimePower { _, e -> ret *= (e+1) }\r\n return ret\r\n}\r\nfun Int.factorLook():List{\r\n return sieve.factors[this]\r\n}\r\n\r\n\r\n\r\n\r\ntailrec fun gcd(a: Int, b: Int): Int {\r\n if(b == 0) return a\r\n return if (a % b == 0) Math.abs(b) else gcd(b, a % b)\r\n}\r\ntailrec fun gcd(a: Long, b: Long): Long {\r\n if(b == 0L) return a\r\n return if (a % b == 0L) Math.abs(b) else gcd(b, a % b)\r\n}\r\n\r\nfun lcm(a:Long, b:Long):Long{\r\n return a * b / (gcd(a,b))\r\n}\r\nconst val singleCase = true\r\nfun main(){\r\n sieve.calculateSieveFast()\r\n sieve.preparePrimePower()\r\n sieve.prepareFactors()\r\n solve.cases{\r\n val n = getint\r\n\r\n val phi = IntArray(n+1){if(it == 0) 0 else totient(it)}\r\n\r\n\r\n var ret = 0\r\n for(c in 1..n-2){\r\n val ab = n - c\r\n for(f in ab.factorLook()){\r\n if(f == ab) continue\r\n val options = phi[ab / f]\r\n\r\n// ab dei \"$f $options\"\r\n val extra = (lcm(c.toLong(),f.toLong()) % pI).toInt()\r\n ret = ret modPlus (extra modM options)\r\n }\r\n }\r\n\r\n put(ret)\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n\r\n\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3effec2d57d1b397eff34071601ff7bc", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numHouses, numHouse) = readInts()\n print(if (numHouse and 1 == 1) (numHouse + 1) / 2 else 1 + (numHouses - numHouse) / 2)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "44eab3742ef0788492c77828204dc34c", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (_, x) = readInts()\n val numsSet = readInts().toSet()\n var sol = 0\n for (num in 0 until x) if (num !in numsSet) sol++\n if (x in numsSet) sol++\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4bb0477bac8c2808b28d15371fc73275", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import 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}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a43feb3ead7414c785d908d4926e4f34", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.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.hashCode()-c2.hashCode() !in hash) {\n hash += c1.hashCode()-c2.hashCode()\n } else {\n ans = -1\n break\n }\n }\n val win = if (c1.size==0) 2 else 1\n println(if (c1.size*c2.size!=0) -1 else \"$ans $win\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eef02fdf6bc3c6a214f6f93ac2974650", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "\n\nfun main() {\n\n val k = readLine()\n var i = 1\n\n var generateSequence = generateSequence{i++}.takeWhile { i<=10000 }\n print(generateSequence.elementAt(k!!.toInt()-1))\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cadb3e259f8eccc487b2b6662683bad0", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val sb = StringBuilder()\n for (i in 1 until 2780) sb.append(i)\n print(sb[readInt() - 1])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cd7533b97344fcb7d9ada1ea6a1e8a43", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun readLn() = readLine()!!\n\nfun main() {\n\tvar k = readLn().toLong();\n\tvar (p, np, numD) = listOf(1L, 10L, 1);\n\tk--;\n\twhile (true) {\n\t\tval x = minOf(k/numD, np-p);\n\n\t\tk -= x*numD;\n\n\t\tif (x < np-p) {\n\t\t\tprintln((p+x).toString()[k.toInt()]);\n\t\t\tbreak;\n\t\t}\n\n\t\tnumD++;\n\t\tp = np;\n\t\tnp *= 10;\n\t}\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b5a25e1ba78b23cf977cc5c226b95fbd", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun readLn() = readLine()!!\n\nfun main() {\n\tvar k = readLn().toLong();\n\tvar (p, np, numD) = listOf(1L, 10L, 1);\n\tk--;\n\twhile (true) {\n\t\tval x = minOf(k/numD, np-p);\n\n\t\tk -= x*numD;\n\n\t\tif (x < np-p) {\n\t\t\tprintln((p+x).toString()[k.toInt()]);\n\t\t\tbreak;\n\t\t}\n\n\t\tnumD++;\n\t\tp = np;\n\t\tnp *= 10;\n\t}\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "29f16d62728a6192991a153e0aa5dd51", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "fun main(){\n\n var k = readLine()!!.toInt()\n\n //9 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b\n //90 \u0434\u0432\u0443\u0437\u043d\u0430\u0447\u043d\u044b\u0445\n //900 \u0442\u0440\u0435\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0445\n //9000 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0445\n //\u0447\u0438\u0441\u043b\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0435\n var p = 1\n for (i in 1..4){\n val s=i*9*p\n if (k<=s){\n //\u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0438\u0441\u043b\u043e i \u0437\u043d\u0430\u0447\u043d\u043e\u0435\n //\u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u043e\u043d\u043e \u043f\u043e \u0441\u0447\u0435\u0442\u0443 \u0441\u0440\u0435\u0434\u0438 i \u0437\u043d\u0430\u0447\u043d\u044b\u0445\n val pos = if(k%i==0){\n k/i\n }else{\n k/i+1\n }\n val num = p-1+pos//\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043f\u0430\u043b\u0438\n //\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0446\u0438\u0444\u0440\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430\n val n = (k-1)%i\n println(num.toString()[n])\n break\n }else{\n k-=s\n p*=10\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5f16305bc25b890b0404c4dc601e2735", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(\" \").map(String::toInt)\n val ys = readLine()!!.split(\" \").map(String::toInt)\n\n var cnt = 0\n for (i in 0 until xs.size) {\n val xor_ret = xs[i] xor ys[i]\n if (xor_ret in setOf(xs[i], ys[i])) {\n //if (xs[i].xor(ys[i])) {\n cnt += 1\n }\n }\n\n if (cnt % 2 == 0) {\n println(\"Karen\")\n } else {\n println(\"Koyomi\")\n }\n \n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e70b8a753c1b384f4076bd420314fc46", "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 (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": "9c00682d5831452f8fbd05fdc50e466a", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.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": "712e44ddae91e20aefd5070c6e715425", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main(){\n val r = readLine()!!.toLong()\n\n var x = 1L\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)==0L){\n println(\"$x ${y/(2*x)}\")\n break\n }\n\n x++\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fdbebf0439a2a7f5f93e05d97f246025", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = readLong()\n\n val ans = run {\n if(r % 2 == 0L) return@run \"NO\"\n val y = (r - 3) / 2\n if(y <= 0) \"NO\" else \"1 $y\"\n }\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 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": "099df54b0f9990507036e3ebbb9e9838", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = readInt()\n\n val ans = run {\n if(r % 2 == 0) return@run \"NO\"\n val y = (r - 3) / 2\n if(y <= 0) \"NO\" else \"1 $y\"\n }.also { println(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": "f151f4ba3d5d225382d19a79a11f1e2b", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.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()\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 isMul(a: Int, b: Int, c: Int, d: Int): Boolean {\n if (a == 0 && b == 0) return true\n if (c == 0 && d == 0) return false\n if (a.toLong()*d != b.toLong()*c) return false\n if (c != 0) {\n if (a%c != 0 || a/c < 0) return false\n } else {\n if (b%d != 0 || b/d < 0) return false\n }\n return true\n}\n\nfun solve() {\n val (a,b) = nextInts()\n val s = next()\n var (x,y) = arrayOf(0,0)\n for (c in s) {\n if (c == 'U') {\n y ++\n }\n if (c == 'D') {\n y --\n }\n if (c == 'L') {\n x --\n }\n if (c == 'R') {\n x ++\n }\n }\n var (X,Y) = arrayOf(0,0)\n for (c in s) {\n var (difx,dify) = arrayOf(a-X,b-Y)\n if (isMul(difx,dify,x,y)) {\n println(\"Yes\")\n System.exit(0)\n }\n if (c == 'U') {\n Y ++\n }\n if (c == 'D') {\n Y --\n }\n if (c == 'L') {\n X --\n }\n if (c == 'R') {\n X ++\n }\n }\n println(\"No\")\n}\n\nfun main(args: Array) {\n solve()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c77836f414b0f71cb86266e67a7857a7", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n var a = readLine()!!.toInt()\n if (a >= 0) {\n print(a)\n return\n }\n val s = (-a).toString()\n println((0 until s.length)\n .map { s.removeRange(it..it) }\n .map { it.toInt() }\n .filter { it.toString().length == s.length - 1 }\n .map { -it }\n .max())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "7800d04a8e3de8ffeae5c5f3872a718d", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.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, m, a, b) = r.readLine()!!.split(\" \").map { it.toInt() }\n\n var act = r.readLine()!!\n when{\n act[0] != '-' -> println(act.toInt())\n else -> {\n act = act.removeRange(0..0)\n val size = act.length\n val last = act[size-1]\n val second = act[size-1]\n if (last>=second) {\n act = act.removeRange(size-1..size-1)\n } else{\n act = act.removeRange(size-2..size-2)\n }\n s.append(\"-\")\n s.append(act.toInt())\n println(s)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6ad5f8846f874c6804d29c97ce0bdca1", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n var n = readLine()!!.toInt()\n var answer = n\n if (n / 10 > answer) answer = n / 10\n val opt1 = (n % 10) + (n / 100) * 10\n if (opt1 > answer) answer = opt1\n println(answer)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2aed1940194a6113bd3cc2742b305530", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, a, b, c, d) = readLine()!!.split(\" \").map(String::toInt)\n var sol = 0L\n for (x1 in 1..n) {\n if (x1 + b - c in 1..n &&\n x1 + a - d in 1..n &&\n x1 + a + b - c - d in 1..n\n )\n sol++\n }\n print(sol * n)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3e4ce0fd6cb728c2c7554896099cc5ec", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\nfun main(args: Array) {\n if (args.size > 0) {\n input = FileInputStream(args[0])\n }\n var str = nextString()\n var tokens = str!!.split(\"VK\")\n var ans = tokens.size - 1 + if (tokens.filter { it.length > 1 && it != \"KV\" }.isNotEmpty()) 1 else 0\n println(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\nfun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\nfun nextInts(n: Int) = IntArray(n) { nextInt() }\nfun nextLongs(n: Int) = LongArray(n) { nextLong() }\nfun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\nfun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\nfun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\nfun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\nfun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\nfun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\nfun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\nfun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\nfun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\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": "e32d7f5e65050245a617ea85eb94b92a", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.StringTokenizer\nimport java.io.PrintWriter\n\nfun main() {\n for(t in 1..1) {\n val s = readString().toCharArray()\n val l = s.size\n var c = 0\n var f = false\n for (i in 1..l - 1) {\n if (s[i] == 'K' && s[i - 1] == 'V') c++\n else if (!f && s[i] == 'V' && s[i - 1] == 'V') {\n if((i < l - 1 && s[i + 1] != 'K') || (i == l - 1)) {\n c++\n s[i] = 'K'\n f = true\n }\n }\n else if (!f && s[i] == 'K' && s[i - 1] == 'K') {\n if((i >= 2 && s[i - 2] == 'K') || (i == 1)) {\n c++\n s[i - 1] = 'V'\n f = true\n }\n }\n }\n// wr(s.joinToString(\"\"))\n if(l == 2 && s[0] == 'K' && s[1] == 'K') wr(1)\n else if (l > 1) wr(c)\n else wr(0)\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": "115cdab149e669c19b1113c2f4c9ce9b", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.FileInputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\n\nfun main(args: Array) {\n if (args.size > 0) {\n input = FileInputStream(args[0])\n }\n var str = nextLine()\n var tokens = str!!.split(\"VK\")\n var ans = tokens.size - 1 + if (tokens.filter { it.length > 1 && it != \"KV\" }.isNotEmpty()) 1 else 0\n println(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\nfun nextStrings(n: Int) = Array(n) { nextString() ?: \"\" }\nfun nextInts(n: Int) = IntArray(n) { nextInt() }\nfun nextLongs(n: Int) = LongArray(n) { nextLong() }\nfun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\nfun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\nfun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\nfun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }\nfun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\nfun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\nfun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\nfun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\nfun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\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": "9c3bb7902ae44cffc37ee44ee11acec1", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun model(n: Long, k: Long): Long {\n var rem = n\n var ans = 0L\n\n while (rem > 0) {\n val vasyaCount = Math.min(rem, k)\n ans += vasyaCount\n rem -= vasyaCount\n rem -= rem / 10\n }\n\n return ans\n}\n\nfun check(vasyaCount: Long, n: Long) = vasyaCount > n / 2\n\nfun main(args: Array) {\n val n = readLine()!!.toLong()\n\n var a = 1L\n var b = n\n\n while (b - a > 1) {\n val c = (a + b) / 2\n if (check(model(n, c), n)) {\n b = c\n } else {\n a = c\n }\n }\n\n if (check(a, n)) {\n println(a)\n } else {\n println(b)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cfc96e758918da74461a06f4502bba03", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun model(n: Long, k: Long): Long {\n var rem = n\n var ans = 0L\n\n while (rem > 0) {\n val vasyaCount = Math.min(rem, k)\n ans += vasyaCount\n rem -= vasyaCount\n rem -= rem / 10\n }\n\n return ans\n}\n\nfun check(vasyaCount: Long, n: Long) = 2 * model(n, vasyaCount) >= n\n\nconst val LIMIT = 100_000\n\nfun main(args: Array) {\n val n = readLine()!!.toLong()\n\n var a = 1L\n var b = n\n\n while (b - a > 1) {\n val c = (a + b) / 2\n if (check(model(n, c), n)) {\n b = c\n } else {\n a = c\n }\n }\n\n a = Math.max(a - LIMIT / 2, 1L)\n b = a + LIMIT / 2\n\n for (k in a..b) {\n if (check(k, n)) {\n println(k)\n break\n }\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b46282bd44359a337a9547c87261a517", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "//package codeForces.c491_2\n\nfun tryEat(n: Long, c: Long): Boolean {\n var remains = n\n var eaten = 0L\n\n while (remains > c) {\n remains -= c\n eaten += c\n\n remains -= remains / 10\n }\n eaten += remains\n\n return eaten >= n / 2\n}\n\nfun main(args: Array) {\n val n = readLine()!!.toLong()\n\n var left = 0L\n var right = n\n var lastSuccess = -1L\n\n while (left <= right) {\n val c = (left + right) / 2\n\n if (tryEat(n, c)) {\n lastSuccess = c\n right = c - 1\n } else {\n left = c + 1\n }\n }\n\n println(lastSuccess)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3c414e54dc2d1601153d18b3d1d571db", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "\n\nfun main(){\n var l = readLine()!!.split(\" \")\n val p1 = l[0].toInt()\n val p2 = l[1].toInt()\n\n\n if (p1 == p2) {\n println(\"0 6 0\")\n return\n }\n\n var diff = p1 - p2\n if (diff < 0 ) diff++\n else diff--\n\n\n var likt = 0\n if (diff % 2 != 0) {\n likt = 1\n }\n diff /= 2\n\n var w1 = 0\n var w2 = 0\n\n\n\n if (p1 > p2) {\n w1 = 6 - (p1 - diff - 1)\n }else{\n w1 = p1 - diff\n }\n w2 = 6 - likt - w1\n\n\n println(\"$w1 $likt $w2\")\n\n}\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "254216f076c4f31005e7085df5543050", "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))win++\n else lose++\n }\n println(\"$win $draw $lose\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a737a50ca0f659fe7278d8ed504b2caf", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\nfun main(){\n \tval reader=Scanner(System.`in`) \n var a:Int=reader.nextInt()\n var b:Int=reader.nextInt()\n var c=0\n while(b>0){\n c=c*10+(b%10)\n b/=10\n }\n print(a+c)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b10570050e094391293dad3b42736ac5", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main(args : Array) {\n var list1: MutableList = mutableListOf()\n for (i in 0..7) {\n list1.add(readLine()!!)\n }\n\n var row = 0\n var a = 0\n for (i in 0..7) {\n var col = 0\n for (char in list1[i]) {\n if (char == 'B') {\n col++\n }\n if (col == 8) {\n row++\n }\n }\n a = col\n }\n\n var c = row + a\n if (c==16){ println(8) }\n else { println(c)}\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "27e2a2451a0eed9c1c5ea03aec531cd3", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.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 when {\n char0Count > char1Count -> return print(\"NO\")\n char0Count < char1Count -> return if (char1Count % char0Count == 0) print(\"YES\") else print(\"NO\")\n char0Count == char1Count -> return print(\"YES\")\n else -> {\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "63baaf369f797840ae4943738275f974", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.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 == 0) println(\"YES\") else println(\"NO\")\n\t\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "08697f2f76dfb4710ab76c99b3c9ac67", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val a = readLine()!!\n val b = a.count{it=='o'}\n val n = a.count{it=='-'}\n // --o--o--o\n if(n == 0 || b == 0) {\n print(\"YES\")\n } else print(\n if(n % b == 0) \"YES\" else \"NO\"\n )\n}\n\n\n\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ca306ce586af99bbd6ccfe8d9d1b3e55", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (links, pearls) = readLine()!!.partition { it == '-' }\n if (pearls.isEmpty()) {\n println(\"YES\")\n } else {\n println(if (links.length % pearls.length == 0) \"YES\" else \"NO\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9c0d18fc3ef9826f15512283e8848588", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.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 l = r.readLine()!!.split(\" \").map { it.toInt() }\n //val n = r.readLine()!!.toInt()\n val (n, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n when{\n n>2*m -> println(m)\n m>2*n -> println(n)\n else -> println((m+n)/3)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e1eb64e612c66d563774221647f3417e", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import com.sun.javafx.binding.SelectBinding\n\n// contest/65/A Harry Potter and Three Spells train\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\nfun main() {\n val abcdef = readInts()\n val a = abcdef[0]\n val b = abcdef[1]\n val c = abcdef[2]\n val d = abcdef[3]\n val e = abcdef[4]\n val f = abcdef[5]\n var ace : Long\n var bdf : Long\n var canInf = false\n\n var coef = 1.0\n if (d==0) {\n // no gold\n canInf = false\n } else if (c!=0 && b==0) {\n // no lead\n canInf = false\n } else if (a != 0 && f==0) {\n // no sand\n canInf = false\n } else if (d!=0 && c==0) {\n canInf = true // unlimited gold\n } else if (d!=0 && c==0) {\n canInf = true // unlimited gold\n } else if (b!=0 && d != 0 && a==0) {\n canInf = true // unlimited lead\n } else if (b!=0 && d != 0 && f!=0 && e==0) {\n canInf = true // unlimited sand\n } else {\n ace = a.toLong()*c*e\n bdf = b.toLong() *d*f\n canInf = bdf > ace\n }\n\n println(if (canInf) \"Ron\" else \"Hermione\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8cc59d51e6a973e963cd4c263f26ec61", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "\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 = 0\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": "9ed028833924fe399f3ffdbc4cfe4bed", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main(arg: Array){\n\tvar s = readLine()!!\n\tvar m = readLine()!!.toLong()\n\tvar l = s.length\n\tvar now = 0.toLong()\n\tvar Q = 1.toLong()\n\tfor(i in 0..l-1){\n\t\tnow = (now * 10 + (s[i].toInt() - 48))%m\n\t\tQ = Q * 10 % m\n\t}\n\tvar res = now\n\tfor(i in 0..l-1){\n\t\tvar x = s[i].toInt() - 48\n\t\tnow = (now * 10 + x - x * Q % m + m)%m\n\t\tif(now < res)res = now\n\t}\n\tprintln(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "96680bcc16acbbfd3216df1ac75b36bb", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val line = readLine()!!.toCharArray()\n\n (1 until line.size).forEach {\n if (line[it] < line[it - 1]){\n println(\"NO\")\n return\n }\n }\n val sorted = line.toSet().sorted()\n\n if (sorted.size > 26){\n println(\"NO\")\n return\n }\n\n\n (1 until sorted.size).forEach {\n if (sorted[it] - sorted[it-1] != 1){\n println(\"NO\")\n return\n }\n }\n println(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "430072e8c4b966b5a6cdaa3481abaff0", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\n/**\n * Created by tux on 31.12.16.\n */\n\nfun main(args: Array) {\n val T = readLine()!!\n\n var nextChar = 'a'\n var ret = true\n for (c in T) {\n if (c == nextChar) {\n nextChar = (nextChar.toInt() + 1).toChar()\n \n } else if (c > nextChar) {\n ret = false\n break\n } else if (nextChar > 'z') {\n ret = false\n break\n }\n }\n\n println(if (ret) \"YES\" else \"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cad3e1231adb6f47388843fdd110a19d", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n var next = 'a'\n for (c in readLine()!!)\n when {\n c == next -> next++\n c > next -> return print(\"NO\")\n }\n print(\"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f85aff7efff2a717e90914f62f8bd0fd", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n val (c, d) = readLine()!!.split(\" \").map(String::toInt)\n\n var ans = -1\n\n loop@ for (x in 0..99) {\n for (y in 0..99) {\n val t1 = b + x * a\n val t2 = d + y * c\n if (t1 == t2) {\n ans = t1\n break@loop\n }\n }\n }\n\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f7d6c15eff5a8b61aef89c281a562c3", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n\ntailrec fun gcd(a: Int, b: Int): Int {\n if (a != 0 && b != 0) {\n if (a > b) return gcd(a % b, b)\n else return gcd(b % a, a)\n }\n\n return a + b\n}\n\nfun gcde(a: Int, b: Int): Triple {\n if (a == 0) {\n return Triple(b, 0, 1)\n }\n\n val (d, x1, y1) = gcde(b % a, a)\n\n return Triple(d, y1 - (b / a) * x1, x1)\n}\n\nfun DataReader.solve(out: PrintWriter) {\n val b = nextInt()\n val a = nextInt()\n val d = nextInt()\n val c = nextInt()\n\n val q = c - a\n val (g) = gcde(b, -d)\n\n if (q % g != 0) {\n out.println(-1)\n return\n }\n\n for (i in 0..100000000) {\n val w = a + i * b - c\n\n if (w >= 0 && w % d == 0) {\n out.println(w + c)\n return\n }\n }\n\n//\n// val p = q / g\n//\n// val (g1, x, y) = gcde(b / g, -d / g)\n//\n// val (xr, yr) = x * p to y * p\n\n\n\n throw RuntimeException(\":(\")\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 readLongArray(n: Int) : LongArray {\n val result = LongArray(n)\n result.indices.forEach { i -> result[i] = nextLong() }\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": "7a318c45dce93abdd65d7b1f658a62d7", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n\nfun DataReader.solve(out: PrintWriter) {\n val b = nextInt()\n val a = nextInt()\n val d = nextInt()\n val c = nextInt()\n\n for (i in 1..1000000) {\n val q = a + i * b - c\n\n if (q >= 0 && q % d == 0) {\n out.println(q + c)\n return\n }\n }\n\n out.println(-1)\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 readLongArray(n: Int) : LongArray {\n val result = LongArray(n)\n result.indices.forEach { i -> result[i] = nextLong() }\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": "fde36bb646db0a3af07c2847b84546c6", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import ds.*\nimport nt.*\nimport java.io.*\nimport java.util.*\nimport java.math.*\n\n//val inp = BufferedReader(FileReader ( \"input.txt\" ) )\nval inp = BufferedReader(InputStreamReader(System.`in`))\n\n\nfun solve() : Int {\n\tval a = ( inp.readLine() ?: return 1 ).split(\" \").map{ it.toInt() }\n\tval b = ( inp.readLine() ?: return 1 ).split(\" \").map{ it.toInt() }\n\tvar curA = a[1]\n\tvar curB = b[1]\n\tfor ( i in 1..1000000 ) {\n\t\tif ( curA == curB ) {\n\t\t\tprintln ( \"\" + curA )\n\t\t\treturn 0\n\t\t}\n\t\tif ( curA < curB ) curA += a[0]\n\t\telse curB += b[0]\n\t}\n\tprintln ( \"-1\" )\n\treturn 0\n}\n\nfun main ( args : Array ) {\n\twhile (solve()==0);\n}\n", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "05ae9859fdeefcd702c50f4afda1dd55", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n println(countWays(n, k))\n}\n\nfun countWays(n: Long, k: Long): Long {\n if (k <= 1 || k > 2 * n - 1) return 0\n val m1 = k / 2\n val m2 = k - m1\n return min(n - m2 + 1, m1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "815778307aa34b4a4ac9391697e6f1fc", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "Kotlin 1.6", "source_code": "\r\nimport java.io.OutputStream\r\nimport java.io.PrintWriter\r\n\r\n// @author: noisegain\r\n\r\nfun main() = withFastOut(times = readInt()) {\r\n val s = Array(2) { readInts(2) }\r\n if (s.all { it == listOf(1, 1) }) {\r\n println(2)\r\n } else if (s.any { it.contains(1) }) {\r\n println(1)\r\n } else {\r\n println(0)\r\n }\r\n}\r\n/* Utilities */\r\nclass MyMap(\r\n private val back: MutableMap = mutableMapOf(),\r\n private val default: (K) -> V\r\n) : MutableMap by back {\r\n\r\n override tailrec fun get(key: K): V = if (key in back) back[key]!! else {\r\n put(key, default(key))\r\n get(key)\r\n }\r\n\r\n override fun equals(other: Any?) = back == other\r\n\r\n override fun hashCode() = back.hashCode()\r\n\r\n override fun toString() = back.toString()\r\n}\r\n\r\nfun , T2 : Comparable> pairCmp(): Comparator> = Comparator { a, b ->\r\n val res = a.first.compareTo(b.first)\r\n if (res == 0) a.second.compareTo(b.second) else res\r\n}\r\n\r\nfun Boolean.toInt() = if (this) 1 else 0\r\n\r\n/* Output */\r\ninline fun withFastOut(\r\n out: OutputStream = System.out,\r\n times: Int = 1,\r\n fn: PrintWriter.() -> Unit\r\n) = PrintWriter(out).use { writer ->\r\n repeat(times) { fn(writer) }\r\n}\r\n\r\nfun PrintWriter.printVar(vararg x: Any?, sep: String = \" \") = println(x.joinToString(sep))\r\n\r\n/* Input */\r\nval INPUT = System.`in`\r\nconst val BUFFER_SIZE = 1 shl 16\r\nval buffer = ByteArray(BUFFER_SIZE)\r\nvar bufferPt = 0\r\nvar bytesRead = 0\r\n\r\ntailrec fun readChar(): Char {\r\n if (bufferPt == bytesRead) {\r\n bufferPt = 0\r\n bytesRead = INPUT.read(buffer, 0, BUFFER_SIZE)\r\n }\r\n return if (bytesRead < 0) Char.MIN_VALUE\r\n else {\r\n val c = buffer[bufferPt++].toChar()\r\n if (c == '\\r') readChar()\r\n else c\r\n }\r\n}\r\n\r\n\r\nfun readLine(): String? {\r\n var c = readChar()\r\n return if (c == Char.MIN_VALUE) null\r\n else buildString {\r\n while (true) {\r\n when (c) {\r\n '\\n', Char.MIN_VALUE -> return@buildString\r\n else -> {\r\n append(c)\r\n c = readChar()\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nfun readLn() = readLine()!!\r\n\r\nfun read() = buildString {\r\n var c = readChar()\r\n while (c <= ' ') {\r\n if (c == Char.MIN_VALUE) return@buildString\r\n c = readChar()\r\n }\r\n do {\r\n append(c)\r\n c = readChar()\r\n } while (c > ' ')\r\n}\r\n\r\nfun readInt() = read().toInt()\r\nfun readLong() = read().toLong()\r\nfun readInts(n: Int) = List(n) { readInt() }\r\nfun readLongs(n: Int) = List(n) { readLong() }\r\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8d392f4a26220ec724ef171659952944", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "fun main()\r\n{\r\n val limit = readln().toInt()\r\n for (i in 1..limit)\r\n {\r\n val firstRow = readln().split(\" \")\r\n val secondRow = readln().split(\" \")\r\n val one = firstRow[0].toInt()\r\n val two = firstRow[1].toInt()\r\n val three = secondRow[0].toInt()\r\n val four = secondRow[1].toInt()\r\n if (one == 0 && two == 0 && three == 0 && four == 0)\r\n {\r\n println(\"0\")\r\n }\r\n else if (one == 1 && two == 1 && three == 1 && four == 1)\r\n {\r\n println(\"2\")\r\n }\r\n else println(\"1\")\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eb4fc2bb81e1594c33c0fc7233044dd7", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "fun main() {\r\n repeat(readln().toInt()) {\r\n val grid = Array(2) { readln().split(\" \").map { it.toInt() } }\r\n\r\n if(grid.flatMap { it }.all { it == 1 }) println(2)\r\n else if (grid.flatMap { it }.all { it == 0 }) println(0)\r\n else println(1)\r\n }\r\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3b406f9bde911957447253919f159737", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Kotlin 1.6", "source_code": "fun readInt() = readln().toInt()\nfun readStrings() = readln().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\n\nfun main() {\n repeat(readInt()) {\n val a = listOf(readInts(), readInts())\n output(solve(a))\n }\n}\n\nfun solve(a: List>): Int {\n val cnt = a[0][0] + a[0][1] + a[1][0] + a[1][1]\n if (cnt == 0) return 0\n if (cnt == 4) return 2\n return 1\n}\n\nfun output(res: Int) {\n println(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b254090d3b6f8bc5c264ee15253b86a3", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Kotlin 1.5", "source_code": "import java.io.PrintWriter\r\nimport java.util.StringTokenizer\r\nimport java.io.BufferedWriter\r\nimport java.io.OutputStreamWriter\r\nimport kotlin.math.*\r\nimport kotlin.random.*\r\nimport kotlin.collections.*\r\n\r\nprivate val INPUT = System.`in`\r\nprivate val OUTPUT = System.out\r\n\r\nprivate val bufferedReader = INPUT.bufferedReader()\r\nprivate val outputWriter = BufferedWriter( OutputStreamWriter(OUTPUT));\r\nprivate fun readLn() = bufferedReader.readLine()!!\r\n\r\nprivate fun readList() = readLn().split(' ')\r\nprivate var tokenizer = StringTokenizer(\"\")\r\nprivate fun read(): String {\r\n while(tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), \" \")\r\n return tokenizer.nextToken()\r\n}\r\n\r\nprivate fun readInt() = read().toInt()\r\nprivate fun readLong() = read().toLong()\r\nprivate fun readDouble() = read().toDouble()\r\n\r\nprivate fun readIntList() = readList().map { it.toInt() }\r\nprivate fun readLongList() = readList().map { it.toLong() }\r\nprivate fun readDoubleList() = readList().map { it.toDouble() }\r\n\r\nprivate fun readIntArray(n: Int = 0) =\r\n if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }\r\n\r\nprivate fun readLongArray(n: Int = 0) =\r\n if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }\r\n\r\nprivate fun readDoubleArray(n: Int = 0) =\r\n if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }\r\n\r\n\r\nprivate fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)\r\n\r\n\r\n\r\nfun main() {\r\n var cases = readInt()\r\n repeat(cases) {\r\n var sum = 0\r\n for(i in 0 until 4) {\r\n sum += readInt()\r\n }\r\n if(sum == 0) {\r\n println(0)\r\n } else if(sum == 4) {\r\n println(2)\r\n } else {\r\n println(1)\r\n }\r\n }\r\n outputWriter.close()\r\n}\r\n\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3cb7e8e3bc47e68ba55b1be6d02033b9", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.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(12*edge)\n } else{\n val x = gcd(b, c)\n val y = b/x\n val z = c/x\n println(4*(x+y+z))\n }\n}\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "83c5bb29f114b45fa13e8edd91d4d22d", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "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.toDouble() }\n val x = sqrt(a*b/c).toInt()\n val y = sqrt(a*c/b).toInt()\n val z = sqrt(b*c/a).toInt()\n println(4*(x+y+z))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "564f66fa54e0483118aeaab929acda4b", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n println(readLine()!!.toInt()/2 + 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f9495ef4bcbf18f8414706ea35e1fa1f", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "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 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 - a > b) continue\n ++res\n }\n io.println(res)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "76798eb33c919ecb2dc8a6b6ad96761e", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.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 long get(long l, long r) {\n if (l == r) return 0;\n\n long x = 1;\n while (x * 2 <= r) x *= 2;\n if (l < x) return x * 2 - 1;\n return get(l - x, r - x);\n }\n\n static void solve(int tc) throws Exception {\n long l = in.nlong(), r = in.nlong();\n\n out.println(get(l, r));\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": "48e4a395365e5eb970a96de9688aa67f", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "fun main() {\n val line = readLine()!!\n val six = line.indexOf(' ')\n val l = line.substring(0, six).toLong()\n val r = line.substring(six + 1).toLong()\n for (e in 60 downTo 0) {\n val b = 1L shl e\n if ((l and b) != (r and b)) {\n println((2L * b) - 1L)\n return\n }\n }\n println(0L)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dac481ebcbc077343083c9540d96e367", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.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\ndata 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 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 = MInt(maxWas - minWas + 1).pow(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": false, "code_uid": "23f8fc034b6b7bedc5cd3b44e48690d5", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.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": "b737fa830181473a991eb14095a993e9", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Kotlin", "source_code": " import java.util.*\n\n data class Row(var left: Int = -1, var right: Int = -1, var length: Int = 0)\n\n fun main(args: Array){\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n if (n==1){\n println(0)\n return\n }\n var even = n/2 + n%2\n var odd = n/2\n val rows = arrayListOf()\n var left = -1\n var right = -1\n var answer = 0\n var length = 0\n for (i in 0 until n){\n var a = scanner.nextInt()\n if (a==0){\n length++\n continue\n }\n\n if (length==0){\n a%=2\n if (a!=left && left!=-1){\n answer++\n }\n left=a\n if (a==0){\n odd--\n }\n else{\n even--\n }\n }\n else{\n right = a%2\n rows.add(Row(left, right, length))\n left = right\n right=-1\n length=0\n if (a%2==0){\n odd--\n }\n else{\n even--\n }\n }\n }\n if (length!=0){\n rows.add(Row(left, right, length))\n }\n rows.sortBy { it.length }\n for (row in rows){\n if (row.left ==-1 && row.right==-1){\n answer+=1\n continue\n }\n if (row.left ==-1 || row.right==-1){\n if (row.left+row.right+1==0){\n if (row.length<=odd){\n odd-=row.length\n }\n else{\n answer+=1\n }\n }\n else{\n if (row.length<=even){\n even-=row.length\n }\n else{\n answer+=1\n }\n }\n continue\n }\n\n if (row.left!=row.right){\n answer++\n }\n else{\n if (row.left==0){\n if (row.length<=odd){\n odd-=row.length\n }\n else{\n answer+=2\n }\n }\n else{\n if (row.length<=even){\n even-=row.length\n }\n else{\n answer+=2\n }\n }\n }\n }\n println(answer)\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d052abe8fb44f7f11d448e6a27c24a9e", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "package contest612\n\n\nvar n: Int = 0\nvar lights = emptyList()\n\n\nvar save = Array(102) { Array(102) { Array(102) { IntArray(2) { -1 } } } }\nfun dp(index: Int, odd: Int, even: Int, isOdd: Boolean): Int {\n if (index >= lights.size) {\n return 0\n }\n val oddIndex: Int = if (isOdd) 0 else 1\n if (save[index][odd][even][oddIndex] != -1) return save[index][odd][even][oddIndex]\n var min = Int.MAX_VALUE\n if (lights[index] == 0) {\n if (odd > 0) {\n min = Math.min(min, getCom(isOdd, true) + dp(index + 1, odd - 1, even, true))\n }\n if (even > 0) {\n min = Math.min(min, getCom(isOdd, false) + dp(index + 1, odd, even - 1, false))\n }\n } else {\n val curIsOdd = lights[index] % 2 != 1\n min = getCom(isOdd, curIsOdd) + dp(index + 1, odd, even, curIsOdd)\n }\n save[index][odd][even][oddIndex] = min\n return min\n}\n\nfun getCom(odd: Boolean, odd2: Boolean): Int {\n return if (odd == odd2) {\n 0\n } else {\n 1\n }\n}\n\n\nfun main(args: Array) {\n n = readLine()!!.toInt()\n lights = readLine()!!.split(' ').map { it.toInt() }\n var odd = (n + 1) / 2\n var even = n / 2\n lights.forEach {\n if (it != 0) {\n if(it%2==0)even--\n else odd --\n }\n }\n val ans = Math.min(\n dp(0,odd, even, true),\n dp(0,odd, even, false)\n )\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": true, "code_uid": "ed200396771551cebf45619c4b54e626", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": " import java.util.*\n\n data class Row(var left: Int = -1, var right: Int = -1, var length: Int = 0)\n\n fun main(args: Array){\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n if (n==1){\n println(0)\n return\n }\n var even = n/2 + n%2\n var odd = n/2\n val rows = arrayListOf()\n val rowsW = arrayListOf()\n var left = -1\n var right = -1\n var answer = 0\n var length = 0\n for (i in 0 until n){\n var a = scanner.nextInt()\n if (a==0){\n length++\n continue\n }\n\n if (length==0){\n a%=2\n if (a!=left && left!=-1){\n answer++\n }\n left=a\n if (a==0){\n odd--\n }\n else{\n even--\n }\n }\n else{\n right = a%2\n rows.add(Row(left, right, length))\n left = right\n right=-1\n length=0\n if (a%2==0){\n odd--\n }\n else{\n even--\n }\n }\n }\n if (length!=0){\n rows.add(Row(left, right, length))\n }\n rows.sortBy { it.length }\n for (row in rows){\n if (row.left ==-1 && row.right==-1){\n answer+=1\n continue\n }\n if (row.left ==-1 || row.right==-1){\n rowsW.add(row)\n continue\n }\n\n if (row.left!=row.right){\n answer++\n }\n else{\n if (row.left==0){\n if (row.length<=odd){\n odd-=row.length\n }\n else{\n answer+=2\n }\n }\n else{\n if (row.length<=even){\n even-=row.length\n }\n else{\n answer+=2\n }\n }\n }\n }\n for (row in rowsW){\n if (row.left+row.right+1==0){\n if (row.length<=odd){\n odd-=row.length\n }\n else{\n answer+=1\n }\n }\n else{\n if (row.length<=even){\n even-=row.length\n }\n else{\n answer+=1\n }\n }\n }\n println(answer)\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "20c154a6cacd40079fd24dbadb28ea56", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n/**\n * \u0422\u043e\u0447\u043a\u0438 \u043d\u0430 \u043f\u0440\u044f\u043c\u043e\u0439\n */\nfun taskA() {\n val s = Scanner(System.`in`)\n val n = s.nextInt()\n val desiredDiameter = s.nextInt()\n val numbers = Array(n, { _ -> 0 })\n\n for (i in 0..n-1) {\n numbers[i] = s.nextInt()\n }\n\n numbers.sort()\n\n var from = 0\n var to = 0\n var optimalRemoved = Int.MAX_VALUE\n while (to <= numbers.lastIndex) {\n val d = numbers[to] - numbers[from]\n\n if (d <= desiredDiameter) {\n optimalRemoved = minOf(from + (numbers.size - to - 1), optimalRemoved)\n }\n\n if (d <= desiredDiameter) {\n to++\n } else {\n from++\n }\n }\n\n println(optimalRemoved)\n}\n\n/**\n * \u041d\u0430\u0448\u0430 \u0422\u0430\u043d\u044f \u0433\u0440\u043e\u043c\u043a\u043e \u043f\u043b\u0430\u0447\u0435\u0442\n */\nfun taskB() {\n val s = Scanner(System.`in`)\n val n = s.nextInt()\n val k = s.nextInt()\n val subPrice = s.nextInt()\n val divPrice = s.nextInt()\n\n var curN = n\n var totalPrice = 0\n while (curN != 1) {\n val r = curN % k\n when (r) {\n 0 -> {\n val subTotal = subPrice * (curN/k) * (k-1)\n if (subTotal < divPrice) {\n totalPrice += subTotal\n } else {\n totalPrice += divPrice\n }\n curN /= k\n }\n else -> {\n totalPrice += subPrice * r\n curN -= r\n\n // ugly check if curN under k so we could get zero\n if (curN == 0) {\n curN = 1\n totalPrice -= subPrice\n }\n }\n }\n }\n println(totalPrice)\n}\n\nfun main(args: Array) {\n taskB()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d1a01c87242c6c537750d73ffa899b2b", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main(args:Array) {\n val (n,k,A,B) = (1..4).map{ readLine()!!.toLong() }\n \n // 1\u3067\u5168\u90e8\u6d88\u5316\u3059\u308b\u3068\u304d\u306e\u30b3\u30b9\u30c8\n val step1 = (n-1)*A\n\n // deviable\u306e\u6642\u3001\u7a4d\u6975\u7684\u306b\u5272\u3063\u3066\u3044\u304f\u30a2\u30d7\u30ed\u30fc\u30c1\n \n // k\u306e\u500d\u6570\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3001\u30b8\u30e3\u30f3\u30d7\u8a08\u7b97\u3092\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\n\n var minus1 = 0L\n var devides1 = 0L\n var start = n \n while(true) {\n start = start/k \n //println(\"a $start\")\n devides1 ++\n minus1 += start%k\n if( start < k ) {\n //minus1 += start - 1\n break\n }\n }\n //println( \"${minus1} ${devides1}\" )\n val step2 = (minus1)*A + (devides1)*B\n println( listOf(step1, step2).min())\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f9fd618522c86f63d8f99c20fcb38ea3", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\nfun main() {\n val scan = Scanner(System.`in`)\n val cats = scan.nextInt()\n val leftCats = scan.nextInt()\n\n if(cats == leftCats){\n println(0)\n } else if (leftCats == 0){\n println(0)\n } else {\n val catDiff = cats - leftCats\n if (catDiff > leftCats) {\n println(leftCats)\n } else {\n println(catDiff)\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6a84a8a75ecf277d0f22e15a70767d26", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "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.Arrays\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 object {\n val n = readInt()\n val k = readInt()\n val fft = ModFFT(k*2)\n\n val D = HashMap()\n val F = HashMap()\n\n fun getF(i: Int) = F.getOrPut(i) { fft(D[i]!!, false) }\n\n fun makeD(a: Int, b: Int) {\n val c = a + b\n if(D.containsKey(c)) return\n\n val fa = getF(a)\n val fb = getF(b)\n val fa1 = getF(a-1)\n val fb1 = getF(b-1)\n\n val p = ModIntArray(fa.size) { fa[it] * fb[it] }\n fft.inPlace(p, true)\n val q = ModIntArray(fa.size) { fa1[it] * fb1[it] }\n fft.inPlace(q, true)\n\n D[c] = p.copyOf(k+1).also { d ->\n for(i in 1..k) d[i] += q[i-1]\n }\n }\n\n fun solve() {\n D[0] = ModIntArray(k+1).also { it[0] = ModInt(1) }\n D[1] = ModIntArray(k+1).also { it[0] = ModInt(1); it[1] = ModInt(1) }\n\n var bit = 1\n while(bit shl 1 <= n) {\n makeD(bit, bit)\n makeD(bit, bit-1)\n makeD(bit-1, bit-1)\n bit = bit shl 1\n }\n\n var a = n\n var b = 0\n while(a > 0) {\n bit = a and -a\n makeD(bit, b)\n makeD(bit-1, b)\n b += bit\n a -= bit\n }\n\n val d = D[n]!!\n val ans = (1..k).joinToString(\" \") { d[it].toString() }\n\n println(ans)\n }\n }.solve()\n}\n\ninline val PRIMITIVE_ROOT get() = ModInt(3)\nclass ModFFT(maxDeg: Int) {\n val n = getArrSize(maxDeg)\n private val ninv = ModInt(n).inv_unmemoized()\n\n private fun getArrSize(deg: Int) = Integer.highestOneBit(deg shl 1 or 1)\n fun prepare(arr: ModIntArray, deg: Int) = arr.copyOf(getArrSize(deg))\n\n // w[1] represents n-th root of unity e^(i * tau/n), w[k] = w[1]^k\n val w = PRIMITIVE_ROOT.pow(TOTIENT / n).powArray(n)\n\n // rev[i] is reversal of bits in i\n private val rev = IntArray(n).also { rev ->\n var bit = 1\n var rbit = n shr 1\n while(bit < n) {\n for(i in 0 until bit) {\n rev[i or bit] = rbit or rev[i]\n }\n bit = bit shl 1\n rbit = rbit shr 1\n }\n }\n\n operator fun invoke(a: ModIntArray, invert: Boolean): ModIntArray {\n val res = a.copyOf(n)\n inPlace(res, invert)\n return res\n }\n\n // in-place FFT. Precondition: a.size <= n, and a.size is a power of 2\n fun inPlace(a: ModIntArray, invert: Boolean) {\n val sz = a.size\n if(sz <= 1) return\n require(sz <= n && sz and -sz == sz) { \"Array size $sz must be less than $n and a power of 2\" }\n val st = n / sz\n for(i in 0 until sz) {\n val j = rev[i * st]\n if(i < j) a[i] = a[j].also { a[j] = a[i] }\n }\n\n var len = 2\n var ang = n shr 1 // = n / len, representing the angle tau / len\n if(invert) ang = -ang\n while(len <= sz) {\n for(i in 0 until sz step len) {\n var k = 0\n for(j in i until i+len.shr(1)) {\n val u = a[j]\n val v = a[j+len.shr(1)] * w[k]\n a[j] = u + v\n a[j+len.shr(1)] = u - v\n k = k + ang and n-1\n }\n }\n\n len = len shl 1\n ang = ang shr 1\n }\n\n if(invert) {\n val szinv = ninv * st\n for(i in 0 until sz) a[i] *= szinv\n }\n }\n\n fun mul(a: ModIntArray, b: ModIntArray): ModIntArray {\n val deg = a.lastIndex + b.lastIndex\n require(deg < n) { \"FFT capacity $n too small for polynomial of degree $deg\" }\n val a1 = prepare(a, deg)\n val b1 = prepare(b, deg)\n inPlace(a1, false)\n inPlace(b1, false)\n for(i in a1.indices) a1[i] *= b1[i]\n inPlace(a1, true)\n return a1//.copyOf(deg+1)\n }\n}\n\nclass ArrayModCombinatorics(val maxn: Int) {\n val factorial = ModIntArray(maxn + 1).also {\n it[0] = ModInt(1)\n for(i in 1 .. maxn) {\n it[i] = it[i-1] * i\n }\n }\n\n val invf = ModIntArray(maxn + 1).also {\n it[maxn] = factorial[maxn].inv_unmemoized()\n for(i in maxn downTo 1) {\n it[i-1] = it[i] * i\n }\n }\n\n fun P(n: Int, k: Int) = if(k > n) ModInt(0) else factorial[n] * invf[n-k]\n fun C(n: Int, k: Int) = if(k > n) ModInt(0) else factorial[n] * invf[k] * invf[n-k]\n}\n\nconst val MOD = 998244353\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\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.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 _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`() {\n iprintln(max(1, 2))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a05aa8c67f5cb723371392b60cb2102b", "src_uid": "266cc96acf6287f92a3bb0f8eccc5cf1", "difficulty": 3200.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (n, l) = readInts()\n val aes = readInts()\n val bs = readInts()\n val aDeltas = IntArray(n)\n val bDeltas = IntArray(n)\n for (pos in 0 until n - 1) {\n aDeltas[pos] = aes[pos + 1] - aes[pos]\n bDeltas[pos] = bs[pos + 1] - bs[pos]\n }\n aDeltas[n - 1] = l - aes.last() + aes.first()\n bDeltas[n - 1] = l - bs.last() + bs.first()\n loop@ for (start in 0 until n) {\n for (pos in 0 until n) {\n if (aDeltas[pos] != bDeltas[(start + pos) % n]) continue@loop\n }\n print(\"YES\")\n return\n }\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "78053f7bfd2ff025b7caa738f9ad22d5", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.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 var ok = true\n for(i in 1..8){\n val row: String = scanner.next()\n ok = ok and isGood(row)\n if(!ok) break\n }\n\n if(ok) print(\"YES\")\n else print(\"NO\")\n\n}\n\nfun isGood(str: String): Boolean{\n var cur = 'X'\n for(c in str){\n if(cur == c) return false\n cur = c\n }\n return true\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "61121712bcf65430573a901065598542", "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 var res1 = 0\n var res2 = 0\n for (j in str) {\n if (j == 'W')\n res1++\n else\n res2++\n }\n if (res1 != res2) {\n println(\"NO\")\n return\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": "78b9e0b3115f5365c169ee5eb19cddaf", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport java.lang.System.err\n\nprivate const val localFileName = \"test\"\nprivate lateinit var out: PrintWriter\nprivate lateinit var bf: BufferedReader\nprivate var stok = StringTokenizer(\"\")\nprivate fun read(): String {\n while (!stok.hasMoreTokens()) stok = StringTokenizer(bf.readLine())\n return stok.nextToken()\n}\n\nprivate fun solve() {\n val mod = 998244353L\n val maxn = 201010\n fun Long.sqr() = this * this\n fun Long.mpow(exp: Long): Long = when {\n exp == 0L -> 1L\n (exp and 1L) == 1L -> this * this.mpow(exp - 1) % mod\n else -> this.mpow(exp / 2).sqr() % mod\n }\n\n val inv_2 = 2L.mpow(mod - 2)\n\n val fac = LongArray(maxn)\n val inv_fac = LongArray(maxn)\n fac[0] = 1\n for (i in 1 until maxn) fac[i] = (fac[i - 1] * i) % mod\n for (i in 0 until maxn) inv_fac[i] = fac[i].mpow(mod - 2)\n\n val pow2 = LongArray(maxn)\n pow2[0] = 1\n for (i in 1 until maxn) pow2[i] = pow2[i - 1] * 2L % mod\n\n fun comb(n: Int, k: Int) = fac[n] * inv_fac[k] % mod * inv_fac[n - k] % mod\n\n val n = read().toInt()\n val k = read().toLong()\n if (k == 1L) {\n out.println(0)\n return\n }\n val a = List(n) { read().toInt() }.distinct().toMutableList()\n if (a[0] == a.last())\n a.removeAt(a.lastIndex)\n\n var ans = 0L\n\n for (cnt0 in 0 until a.size) {\n var cur_ans = pow2[a.size - cnt0]\n if ((a.size - cnt0) % 2 == 0)\n cur_ans = (cur_ans + mod - comb(a.size - cnt0, (a.size - cnt0) / 2)) % mod\n cur_ans = (cur_ans * inv_2) % mod\n cur_ans = cur_ans * comb(a.size, cnt0) % mod * (k - 2).mpow(cnt0.toLong()) % mod\n ans = (ans + cur_ans) % mod\n }\n ans = ans * k.mpow((n - a.size).toLong()) % mod\n out.println(ans)\n}\n\nfun main() {\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n assert(localFileName != \"\")\n System.setIn(FileInputStream(File(\"$localFileName.inp\")))\n System.setOut(PrintStream(File(\"$localFileName.out\")))\n }\n\n out = PrintWriter(System.out!!, false)\n bf = BufferedReader(InputStreamReader(System.`in`))\n\n solve()\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "71651731a06cf81fe5ba90ff4d13f3fc", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport java.lang.System.err\n\nprivate const val localFileName = \"test\"\nprivate lateinit var out: PrintWriter\nprivate lateinit var bf: BufferedReader\nprivate var stok = StringTokenizer(\"\")\nprivate fun read(): String {\n while (!stok.hasMoreTokens()) stok = StringTokenizer(bf.readLine())\n return stok.nextToken()\n}\n\nprivate fun solve() {\n val mod = 998244353L\n val maxn = 201010\n fun Long.sqr() = this * this\n fun Long.mpow(exp: Long): Long = when {\n exp == 0L -> 1L\n (exp and 1L) == 1L -> this * this.mpow(exp - 1) % mod\n else -> this.mpow(exp / 2).sqr() % mod\n }\n\n val inv_2 = 2L.mpow(mod - 2)\n\n val fac = LongArray(maxn)\n val inv_fac = LongArray(maxn)\n fac[0] = 1\n for (i in 1 until maxn) fac[i] = (fac[i - 1] * i) % mod\n for (i in 0 until maxn) inv_fac[i] = fac[i].mpow(mod - 2)\n\n val pow2 = LongArray(maxn)\n pow2[0] = 1\n for (i in 1 until maxn) pow2[i] = pow2[i - 1] * 2L % mod\n\n fun comb(n: Int, k: Int) = fac[n] * inv_fac[k] % mod * inv_fac[n - k] % mod\n\n val n = read().toInt()\n val k = read().toLong()\n if (k == 1L) {\n out.println(0)\n return\n }\n val a = List(n) { read().toInt() }.distinct().toMutableList()\n if (a[0] == a.last())\n a.removeAt(a.lastIndex)\n\n var ans = 0L\n\n for (cnt0 in 0 until a.size) {\n var cur_ans = pow2[a.size - cnt0]\n if ((a.size - cnt0) % 2 == 0)\n cur_ans = (cur_ans + mod - comb(a.size - cnt0, (a.size - cnt0) / 2)) % mod\n cur_ans = (cur_ans * inv_2) % mod\n cur_ans = cur_ans * comb(a.size, cnt0) % mod * (k - 2).mpow(cnt0.toLong()) % mod\n ans = (ans + cur_ans) % mod\n }\n ans = ans * k.mpow((n - a.size).toLong())\n out.println(ans)\n}\n\nfun main() {\n if (System.getProperty(\"ONLINE_JUDGE\") == null) {\n assert(localFileName != \"\")\n System.setIn(FileInputStream(File(\"$localFileName.inp\")))\n System.setOut(PrintStream(File(\"$localFileName.out\")))\n }\n\n out = PrintWriter(System.out!!, false)\n bf = BufferedReader(InputStreamReader(System.`in`))\n\n solve()\n out.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d00ed4de0f2c31cbfbe63206e8bb774f", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.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\nfun String.words() = split(\" \")\n\nfun String.toInts() = split(\" \").map { it.toInt() }\nfun String.toLongs() = split(\" \").map { it.toLong() }\n\nprivate fun solve(input: BufferedReader, output: PrintWriter) {\n val s = input.readLine()\n\n fun Char.toIndex() = this - 'A'\n\n val letterCount = IntArray(26)\n var wildcardsCount = 0\n var missingLetters = 26\n\n for (i in 0..s.lastIndex) {\n val c = s[i]\n when (c) {\n '?' -> ++wildcardsCount\n else -> {\n if (letterCount[c.toIndex()] == 0)\n --missingLetters\n ++letterCount[c.toIndex()]\n }\n }\n\n if (i >= 26) {\n val q = s[i - 26]\n when (q) {\n '?' -> --wildcardsCount\n else -> {\n if (letterCount[c.toIndex()] == 1)\n ++missingLetters\n --letterCount[c.toIndex()]\n }\n }\n }\n\n if (i >= 25 && missingLetters <= wildcardsCount) {\n val missingLettersList = letterCount.indices.filter { letterCount[it] == 0 }\n var currentMissingLetterIndex = 0\n val answer = s.toCharArray()\n for (j in answer.indices) {\n if (answer[j] == '?') {\n answer[j] = 'A' + missingLettersList.getOrElse(currentMissingLetterIndex) { 0 }\n ++currentMissingLetterIndex\n }\n }\n output.println(String(answer))\n return\n }\n }\n\n output.println(\"-1\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4bf8f07563ec7203df88237e151d1a3c", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numSongs, duration) = readInts()\n val songsDurations = readInts().sum()\n print(if ((numSongs - 1) * 10 + songsDurations > duration) -1 else (duration - songsDurations) / 5)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a22cd1c29f0464ae8fd76c132b6da48a", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n scanner.nextLine()\n\n val ns: List = scanner.nextLine().split(\" \").map { it.toInt() }\n val ms: List = scanner.nextLine().split(\" \").map { it.toInt() }\n\n val nMin: Int = ns.min()!!\n val mMin: Int = ms.min()!!\n val min: String = when {\n nMin == mMin -> \"$mMin\"\n nMin < mMin -> \"$nMin$mMin\"\n else -> \"$mMin$nMin\"\n }\n println(min)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f57c325e3fc92379e1a3348839204183", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "//package a870\n\nimport java.util.*\nimport kotlin.math.max\nimport kotlin.math.min\n\nfun main(a:Array){\n val input=Scanner(System.`in`)\n val n1=input.nextInt()\n val n2=input.nextInt()\n\n val set1 = mutableSetOf()\n val set2 = mutableSetOf()\n (1..n1).forEach { set1.add(input.nextInt()) }\n (1..n2).forEach { set2.add(input.nextInt()) }\n if (set1.intersect(set2).isNotEmpty()){\n println(set1.intersect(set2).min())\n } else {\n println(min(set1.min()!!, set2.min()!!)*10+ max(set1.min()!!, set2.min()!!))\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cc7dda7043c4d3545ca5f118ed81e429", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\nval reader = Scanner(System.`in`)\nfun main(args: Array){\n val k = reader.nextBigInteger()\n val l = reader.nextBigInteger()\n\n var i = 1\n var po = k.pow(i)\n\n while (po < l)\n {\n po = k.pow(++i)\n if(po == l)\n {\n println(\"YES\")\n print(i-1)\n return\n }\n }\n\n print(\"NO\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "847d080b03d7210ed432f5bf08d7d21d", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (n, m) = readInts()\n\n // Kx[y] = # of arrays of x 1s and y -1s such that max prefix sum = 0\n var K = ModIntArray(m) { ModInt(1) }\n // Dx[y] = answer for n=x and m=y\n var D = ModIntArray(m+1)\n\n for(x in 1..n) {\n val Kx = ModIntArray(m)\n for(y in x until m) {\n Kx[y] = K[y] + Kx[y-1]\n }\n\n val Dx = ModIntArray(m+1)\n Dx[0] = ModInt(x)\n for(y in 1..m) {\n val nn = x + y - 1\n Dx[y] = C(nn, y) + D[y] + Dx[y-1] - C(nn, x) + Kx[y-1]\n }\n\n K = Kx\n D = Dx\n }\n\n val ans = D[m]\n\n println(ans)\n}\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\nfun C(n: Int, k: Int) = n.factorial() / k.factorial() / (n-k).factorial()\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 = 998244853\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() = pow(MODBASE - 2) // assumes MODBASE is prime\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(ModInt(1), ModInt::times)\nfun Sequence.product() = fold(ModInt(1), ModInt::times)\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": "4dc0839a2119e1d31078c3ea51454422", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numHooks, fine) = readInts()\n val prices = readInts().sorted()\n val numGuests = readInt()\n print(\n if (numGuests <= numHooks) prices.subList(0, numGuests).sum()\n else prices.sum() - fine * (numGuests - numHooks)\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8df4622f0290790b2fcdc7d7ff8b2c08", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nval sc = java.util.Scanner(System.`in`)\nfun main(args: Array) {\n\tval n = sc.nextInt()\n\tvar ans = 6\n\tfor (i in 0..999999)\n\t\tif (islucky(i))\n\t\t\tans = min(ans, different(n, i))\n\tprintln(ans)\n}\n\nfun islucky(x: Int) =\n\t\tx % 10 + x / 10 % 10 + x / 100 % 10 ==\n\t\t\t\tx / 1000 % 10 + x / 10000 % 10 + x / 100000\n\nfun different(x: Int, y: Int): Int {\n\tvar ans = 0\n\tvar a = x\n\tvar b = y\n\tfor (i in 1..6) {\n\t\tif (a % 10 != b % 10)\n\t\t\tans++\n\t\ta /= 10\n\t\tb /= 10\n\t}\n\treturn ans;\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ee510d586b8fc88dab8e116f511ff384", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main(args: Array) {\n val digits = readLine()!!.toCharArray().map { Character.getNumericValue(it) }\n\n val left = digits.take(3).toMutableList()\n val right = digits.takeLast(3).toMutableList()\n\n println(solve(left, right))\n}\n\ntailrec fun solve(left: MutableList, right: MutableList, steps: Int = 0): Int {\n val leftSum = left.sum()\n val rightSum = right.sum()\n if (leftSum == rightSum) return steps\n\n val delta = leftSum - rightSum\n var larger = if (delta>0) left else right\n val smaller = if (delta>0) right else left\n\n val largerDecreases = larger.sortedDescending()\n val smallerIncreases = smaller.map { 9-it }\n\n val maxDecrease = largerDecreases.max()!!\n val maxIncrease = smallerIncreases.max()!!\n\n if(Math.max(maxDecrease, maxIncrease) >= Math.abs(delta)) {\n return steps+1\n }\n\n fun getIndex(list: List, number: Int?): Int = if (number == null) 0 else list.indexOf(number)\n\n if (maxIncrease>maxDecrease) {\n smaller[getIndex(smaller, smaller.min())] = 9\n return solve(smaller, larger, steps+1)\n }\n larger[getIndex(larger, larger.max())] = 0\n return solve(smaller, larger, steps+1)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3d96218dd3e3a9a1098a2e73bf212af0", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "\nimport java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\n\nclass TaskB : Solver() {\n override fun solve() {\n val n = scanner.nextInt()\n val x = scanner.getIntArray(n)\n var max = -1\n for (i in 0 until n){\n if (x[i] > max + 1){\n System.out.print(i + 1)\n return\n }\n max = Math.max(max, x[i])\n\n }\n System.out.print(-1)\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 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] + 3*t[2]\n if (walk< lift){\n System.out.println(\"NO\")\n } else{\n System.out.println(\"YES\")\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9022866cc7cc654619592643ee91ba74", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.Locale\n\n\nval filename = \"a\"\n\nfun solve() {\n val x = iread()\n val y = iread()\n val z = iread()\n val t1 = iread()\n val t2 = iread()\n val t3 = iread()\n\n val res1 = (Math.abs(x-y) + Math.abs(z-x))*t2 + t3*2;\n val res2 = Math.abs(x-y) * t1;\n\n if (res1 <= res2) {\n out.write(\"YES\\n\")\n }\n else\n out.write(\"NO\\n\")\n}\n\nfun iread() = readword().toInt()\n\nfun dread() = readword().toDouble()\n\nfun lread() = readword().toLong()\n\nfun readword(): String {\n val b = StringBuilder()\n var c: Int\n val space = ' '.toInt()\n c = `in`.read()\n while (c in 0..space)\n c = `in`.read()\n if (c < 0)\n return \"\"\n while (c > space.toInt()) {\n b.append(c.toChar())\n c = `in`.read()\n }\n return b.toString()\n}\n\nval `in`: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\nval out: BufferedWriter = BufferedWriter(OutputStreamWriter(System.out))\n//val `in` = BufferedReader(FileReader(filename+\".in\"));\n//val out = BufferedWriter(FileWriter(filename+\".out\"));\n\nfun run() {\n try {\n// var ntests = iread()\n// for (test in 0 until ntests) {\n solve()\n// }\n out.flush()\n } catch (e: Exception) {\n e.printStackTrace()\n System.exit(1)\n }\n}\n\nfun main(args: Array) {\n try {\n Locale.setDefault(Locale.US)\n } catch (e: Exception) {\n\n }\n Thread(null, { run() }, \"1\", (1 shl 25).toLong()).start()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c3a81345c69601885a175f2027ca2968", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun main(args: Array) {\n val xyzt1t2t3 = readLine()!!.split(\" \").map{it.toInt()}\n val (x,y,z) = xyzt1t2t3.subList(0, 3)\n val (t1,t2,t3) = xyzt1t2t3.subList(3,6)\n println(if (abs(x-y)*t1 < abs(x-z)*t2+2*t3+abs(x-y)*t2) \"NO\" else \"YES\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "54783f17e68a2286f7eccf6102e66d5a", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.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 = MutableList(2, { 0 })\n\n fib[0] = 1\n fib[1] = 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": "2c90427a34bc933aa0ed5890d3edeff4", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.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) {\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], dp[i][j])\n }\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 }\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": "949a76a1f395919dce8f04ae80d26007", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.10.17 at 15:49:09 BST\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\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.mm(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }\r\ninfix fun Int.mp(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }\r\ninfix fun Int.ms(b:Int):Int{ val ans = this - b;return if(ans < 0) ans + pI else ans }\r\nfun Int.inverse():Int = intPow(this,pI-2,pI)\r\ninfix fun Int.modDivide(b:Int):Int{ return this mm (b.inverse()) }\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 eat(){ val st1 = TreeSet(); val st2 = TreeMap()}\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\nconst val 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\nconst val singleCase = true\r\nfun main(){\r\n solve.cases{\r\n\r\n val p1 = getint\r\n val t1 = getlong\r\n\r\n val p2 = getint\r\n val t2 = getlong\r\n\r\n val h = getint\r\n val s = getint\r\n\r\n val pack = LongArray(h+1){phuge }\r\n val finish = LongArray(h+1){phuge }\r\n pack[0] = 0\r\n\r\n finish[h] = 0L\r\n fun pack(damage:Int, cost:Long){\r\n\r\n// just dei \"$damage $cost\"\r\n for(i in 0..h){\r\n val next = minOf(damage + i,h)\r\n val cost = pack[i] + cost\r\n pack[next ]= minOf(pack[next], cost)\r\n }\r\n// just dei pack\r\n }\r\n\r\n var tnow = 0L\r\n var CD1 = t1\r\n var CD2 = t2\r\n var damagenow = 0\r\n\r\n while(true){\r\n val totalmove = maxOf(CD1,CD2)\r\n val tt = tnow + totalmove\r\n val dt = damagenow + (p1 + p2 - s)\r\n pack(dt, tt)\r\n\r\n if(damagenow > h)\r\n break\r\n\r\n\r\n val tmove = minOf(CD1,CD2)\r\n tnow += tmove\r\n CD1 -= tmove\r\n CD2 -= tmove\r\n if(CD1 == 0L && CD2 != 0L){\r\n CD1 = t1\r\n damagenow += p1 -s\r\n }else if(CD2 == 0L && CD1 != 0L){\r\n CD2 = t2\r\n damagenow += p2 - s\r\n }else if(CD1 == 0L && CD2 == 0L){\r\n CD1 = t1\r\n CD2 = t2\r\n damagenow += (p1 + p2 - s)\r\n }\r\n finish[maxOf(0,h-damagenow)] = minOf(finish[maxOf(0,h-damagenow)], tnow)\r\n }\r\n\r\n// just dei finish\r\n\r\n for(i in 0 until h){\r\n finish[i+1] = minOf(finish[i+1], finish[i])\r\n }\r\n// just dei finish\r\n// just dei pack\r\n\r\n var ret = phuge\r\n\r\n for(i in 0..h){\r\n ret = minOf(ret, finish[i] + pack[i])\r\n }\r\n put(ret)\r\n\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", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1813d67dac5e406c9f56b8a9a9b9f63e", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val sibice : MutableList> = MutableList(m) { Par(0,0) }\n for(i in 0 until m) {\n val (f, s) = readLine()!!.split(\" \").map(String::toInt)\n sibice[i] = Par(f,s)\n }\n sibice.sortBy { -it.second }\n var sum = 0L\n while(n > 0) {\n if(sibice[0].first > 0) {\n sum += sibice[0].second\n sibice[0].first--\n n--\n } else {\n sibice.removeAt(0)\n if(sibice.isEmpty()) break\n }\n }\n println(sum)\n}\n\nclass Par constructor(var first : T1, var second : T2)\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6e771c661f3212b0959eb756e568d364", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n var (n, m) = readLine()!!.split(\" \").map(String::toLong)\n val sibice : MutableList> = MutableList(0) { Par(0L,0L) }\n for(i in 0 until m) {\n val (f, s) = readLine()!!.split(\" \").map(String::toLong)\n sibice.add(Par(f, s))\n }\n\n sibice.sortBy { -it.second }\n\n var sum = 0L\n var i = 0\n while(n > 0) {\n if(sibice[i].first > 0) {\n sum += sibice[i].second\n sibice[i].first--\n n--\n } else {\n sibice.removeAt(i)\n if(sibice.isEmpty()) break\n else i++\n }\n }\n\n println(sum)\n}\n\nclass Par constructor(var first : T1, var second : T2)\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2865f8e7ffe007068e0e38b762e38924", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val list = readLine()!!.split(' ').map { it.toInt() }.toMutableList()\n\n\n\n for (i in 0 until list.size){\n if (!list.check()) {\n println(\"NO\")\n return\n }\n val max = list.max()\n list.removeAt(list.indexOfFirst { it == max })\n }\n println(\"YES\")\n}\n\nfun List.check():Boolean{\n if (this.size <= 1) return true\n return (1 until this.size).none { Math.abs(this[it] - this[it -1]) >=2 }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "19e5af02d97c3dc9ccbd903185ee6316", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n var (n, b, p) = readInts()\n\n val noOfTowelRequired = p * n\n\n var totalBottlesRequired = 0\n while (n > 1) {\n\n var m = 1\n\n for (i in 0..n) {\n val result = m * 2\n if (result > n) {\n break\n } else {\n m = result\n }\n }\n totalBottlesRequired += (b * m) + (m / 2)\n n -= m / 2\n }\n println(\"$totalBottlesRequired $noOfTowelRequired\")\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": "a5083b2750869f5ddc84290e9e12fb2a", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val x = readLine()!!\n val y = readLine()!!\n for (pos in x.indices) if (x[pos] < y[pos]) return print(-1)\n print(y)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "892b2c04a16a833d5ae31e073f4f63da", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport java.util.StringTokenizer\n\nfun main() {\n output {\n val n = readInt()\n\n var ans = ModInt(0)\n\n var pd = ModInt(1)\n\n for(i in 0..2*n) {\n ans += pd\n if(i >= n) pd -= C(i, n)\n pd *= 2\n }\n\n println(ans)\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\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\ninline fun Int.toModInt() = ModInt(this umod MODINT_BASE)\ninline fun Long.toModInt() = ModInt((this umod MODINT_BASE).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 @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": false, "code_uid": "8d89fbe1c29ed7ae5e83c8d71f83513b", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n//tutorial\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval n = f.readLine().toInt()\n\tval array = f.readLine().toCharArray()\n\n\tval dp = Array(n){IntArray(n){Int.MAX_VALUE}}\n\n\tfun calc(l : Int, r : Int) : Int{\n\n\t\tif(r < l) return 0\n\t\tif(l == r){\n\t\t\tdp[l][r] = 1\n\t\t\treturn 1\n\t\t}\n\t\tif(dp[l][r] != Int.MAX_VALUE) return dp[l][r]\n\n\t\tvar min = 1 + calc(l,r-1)\n\t\tfor(k in l until r){\n\t\t\tif(array[k] == array[r]){\n\t\t\t\tmin = min(min,calc(l,k) + calc(k+1,r-1))\n\t\t\t}\n\t\t}\n\n\t\tdp[l][r] = min\n\t\treturn dp[l][r]\n\t}\n\n\n\n\n\tval answer = calc(0,n-1)\n\t/*\n\tfor(k in 0 until n){\n\t\tprintln(dp[k].joinToString(\" \"))\n\t}*/\n\tprintln(answer)\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b92ce2ae44e987ef52c8e84f31501085", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.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 r1 : Int = ir.nextInt()\n val c1 : Int = ir.nextInt()\n val r2 : Int = ir.nextInt()\n val c2 : Int = ir.nextInt()\n val dis1 : Int = Math.abs(r1 - r2)\n val dis2 : Int = Math.abs(c1 - c2)\n val rest : Int = Math.abs(dis1 - dis2)\n\n if (r1 != r2 && c1 != c2)\n pw.print(\"2 \")\n else if (r1 != r2 || c1 != c2)\n pw.print(\"1 \")\n else\n pw.print(\"0 \")\n\n if (dis1 % 2 == dis2 % 2) {\n when {\n dis1 != dis2 -> pw.print(\"2 \")\n else -> pw.print(\"1 \")\n }\n } else\n pw.print(\"0 \")\n\n if (dis1 >= dis2)\n pw.print(\"${dis2 + rest}\")\n else\n pw.print(\"${dis1 + rest}\")\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": "fbc451afc8becfe1f05e794b91d707dc", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n var i = 0\n var x = 0\n while(i < n){\n x++\n if (isSum10(x)) i++\n }\n println(x)\n}\n\nfun isSum10(x: Int): Boolean{\n var t = x\n var sum = 0\n while(t > 0) {\n sum += t%10\n t /= 10\n }\n return sum == 10\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c8bd86438296fd4da10fe8df9cf0f85a", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n var n = r.readLine()!!.toInt()\n //val (n, time) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val v = r.readLine()!!.split(\" \").map { it.toInt() }\n fun f(i:Long):Boolean = i.toString().split(\"\").filter { it.length>0 }.map { it.toInt() }.sum()==10\n var ans = 1L\n while (n>0){\n ans+=9\n if (f(ans)) n--\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "189b3274050ba6f89088f3b8bd00ed58", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun isOdd(x:Int) :Boolean\n{\n if (x%2 == 0)\n return false\n else\n return true\n}\n\nfun isValid(x:Int,y:Int):Boolean\n{\n if (x>=0 && x<=2 && y>=0 && y<=2)\n return true\n else\n return false\n}\n\nval reader = Scanner(System.`in`)\nvar arr = arrayOf>()\nvar ans = arrayOf>()\nval dx = intArrayOf(0,0, 0,1,-1)\nval dy = intArrayOf(0,1,-1,0, 0)\n\nfun main(args: Array) {\n for (x in 0..2)\n {\n val row = Array(3,{i -> reader.nextInt()})\n val reset = Array(3,{i -> 1})\n arr+=row\n ans+=reset\n }\n\n for (i in 0..2)\n for (j in 0..2)\n if (isOdd(arr[i][j]))\n for (k in 0..4)\n if (isValid(i+dx[k],j+dy[k]))\n ans[i+dx[k]][j+dy[k]] = ans[i+dx[k]][j+dy[k]] xor 1\n\n\n for (row in ans)\n {\n for (value in row)\n print(value)\n println()\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cf67b925942a3ecf04b16ecff57d1548", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import kotlin.math.min\nimport kotlin.math.sign\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 arr = Array(4) { IntArray(4) }\n for (i in 1..3) {\n val s = readInts()\n for (j in 1..3) {\n arr[i][j] = s[j - 1]\n }\n }\n for (i in 1..3) {\n for (j in 1..3) {\n val sum = arr[i][j] + arr[i - 1][j] + arr[i + 1][j] + arr[i][j - 1] + arr[i][j + 1]\n print(if (sum % 2 == 0) 1 else 0)\n }\n println()\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "734b3651c9bc071c4777564ecef85fe3", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "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": "1b4be0f702ef5c867b43dba37d4d08c4", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "//package com.happypeople.codeforces.c1099\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n C().run()\n } catch (e: Throwable) {\n C.log(\"\" + e)\n }\n}\n\n// worst code ever :/\nclass C {\n fun run() {\n val sc = Scanner(systemIn())\n var str = sc.next()!!.trim()\n val k = sc.nextInt()\n\n val specialCount = str.filter { it == '*' || it == '?' }.count()\n val minLen = str.length - (2 * specialCount)\n if (k < minLen) {\n println(\"Impossible\")\n return\n }\n\n var len = str.length - (specialCount * 2) // len if all removed\n //log(\"before, len=$len k=$k : $str\")\n while (len < k) {\n val idx = str.indexOf('?')\n if (idx > 0) {\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"?\"\n val repl2 = \"\" + repl\n str = str.replaceFirst(repl1, repl2)\n len++\n } else\n break\n }\n //log(\"after1: $str\")\n\n if (len < k) { // replace first * by as much as needed chars\n val idx = str.indexOf('*')\n // idx allways >=0\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"*\"\n val repl2 = buildString(repl, k - len)\n //log(\"seconds repl2: $repl2\")\n str = str.replaceFirst(repl1, repl2)\n }\n //log(\"after2: $str\")\n\n while (str.contains(\"*\")) {\n val idx = str.indexOf('*')\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"*\"\n str = str.replace(repl1, \"\")\n }\n //log(\"removed *: $str\")\n while (str.contains(\"?\")) {\n val idx = str.indexOf('?')\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"?\"\n str = str.replace(repl1, \"\")\n }\n //log(\"len result: ${str.length}\")\n\n println(\"$str\")\n }\n\n fun buildString(c: Char, len: Int): String {\n var s = \"\" + c\n while (s.length < len)\n s = s + c\n return s\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": "2ac1f66ee43bfb83895f5f49167e3fa6", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "//package com.happypeople.codeforces.c1099\n\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\nimport java.util.*\n\nfun main(args: Array) {\n try {\n C().run()\n } catch (e: Throwable) {\n C.log(\"\" + e)\n }\n}\n\n// worst code ever :/\nclass C {\n fun run() {\n val sc = Scanner(systemIn())\n var str = sc.next()!!.trim()\n val k = sc.nextInt()\n\n val specialCount = str.filter { it == '*' || it == '?' }.count()\n val minLen = str.length - (2 * specialCount)\n if (k < minLen) {\n println(\"Impossible\")\n return\n }\n\n var len = str.length - (specialCount * 2) // len if all removed\n //log(\"before, len=$len k=$k\")\n while (len < k) {\n val idx = str.indexOf('?')\n if (idx > 0) {\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"?\"\n val repl2 = \"\" + repl\n str = str.replace(repl1, repl2)\n len++\n } else\n break\n }\n //log(\"after1: $str\")\n\n if (len < k) { // replace first * by as much as needed chars\n val idx = str.indexOf('*')\n // idx allways >=0\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"*\"\n val repl2 = buildString(repl, k - len)\n //log(\"seconds repl2: $repl2\")\n str = str.replaceFirst(repl1, repl2)\n }\n //log(\"after2: $str\")\n\n\n //str=str.replace(\"[a-z]*\", \"\")\n //str=str.replace(\"[a-z]?\", \"\")\n while (str.contains(\"*\")) {\n val idx = str.indexOf('*')\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"*\"\n str = str.replace(repl1, \"\")\n }\n while (str.contains(\"?\")) {\n val idx = str.indexOf('?')\n val repl = str[idx - 1]\n val repl1 = \"\" + repl + \"?\"\n str = str.replace(repl1, \"\")\n }\n\n println(\"$str\")\n }\n\n fun buildString(c: Char, len: Int): String {\n var s = \"\" + c\n while (s.length < len)\n s = s + c\n return s\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": "0c3ad6c6cd09c782cf16e1e8afd076e9", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.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, null))\n val closed = BooleanArray(201 * 201 * 201)\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 val hash = hash(ni, nj, nbal)\n if (closed[hash]) continue\n closed[hash] = true\n open.add(Entry(ni, nj, nbal, path + c))\n }\n }\n \"\"\n }\n\n println(ans)\n }\n}\n\nfun hash(i: Int, j: Int, bal: Int) = i.times(201).plus(j).times(201).plus(bal)\ndata class Entry(val i: Int, val j: Int, val bal: Int, val path: CharPathNode?)\n\nclass CharPathNode(val data: Char, val parent: CharPathNode? = null) {\n 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\noperator fun CharPathNode?.plus(childData: Char) = CharPathNode(childData, this)\nfun CharPathNode?.toString() = this?.toString().orEmpty()\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": false, "code_uid": "a8757ff99190052869fdb13d499c477a", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.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, cost, 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 < 0) 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, cost + 1, path + c))\n }\n }\n }\n \"\"\n }\n\n println(ans)\n }\n}\n\ndata class State(val i: Int, val j: Int, val bal: Int) {\n override fun hashCode(): Int = i.times(201).plus(j).times(401).plus(bal).hash()\n}\ndata class Entry(val i: Int, val j: Int, val bal: Int, val cost: Int, val path: CharPathNode?)\n\nclass CharPathNode(val data: Char, val parent: CharPathNode? = null) {\n 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\noperator 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": false, "code_uid": "8457900a0a97d785029c903caedbe009", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.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'] && pos < numGuests - 1) {\n closed[door - 'A'] = true\n 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": "1b7e5d8c0013d4ee52a97cdf43093681", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "class C {\n fun run() {\n val sourceLine = readLine()!!\n val alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n var alphabetIndex = 0\n val result = StringBuilder()\n for (letter in sourceLine) {\n if(alphabetIndex < alphabet.length) {\n result.append(if (letter <= alphabet[alphabetIndex]) {\n alphabet[alphabetIndex++]\n } else letter)\n } else result.append(letter)\n }\n println(if(alphabetIndex < alphabet.length) \"-1\" else result.toString())\n }\n}\n\nfun main(args: Array) {\n C().run()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1437d5baa76fc845763d69397b05a85f", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import kotlin.math.ceil\n\nfun main() {\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val numGrades = readInt()\n val grades = readInts().sorted()\n var necessary = ceil(4.5 * numGrades - grades.sum())\n var sol = 0\n for (grade in grades)\n if (necessary <= 0) break else {\n sol++\n necessary -= 5 - grade\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a003051150b8336650d8432d29faafe7", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b, n) = readLine()!!.split(\" \").map { it.toInt() }\n if (a % 2 != 0 && b % 2 != 0 && n % 2 != 0) println(0)\n else if (a % 10 == 0 && b % 10 == 0 && n %10 == 0) println(0)\n else println(1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "fe6718c1b79dea2f6732cb2b197b4052", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "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}\n\ntailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5affaf21edf01d9f0e07806bea9ebb37", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b, n) = readLine()!!.split(\" \").map { it.toInt() }\n var s = true\n while (n >= 0) {\n n -= gcd(if (s) a else b, n)\n s = !s\n }\n println(if (s) 0 else 1)\n}\n\nfun gcd(n1: Int, n2: Int): Int = if (n2 != 0) gcd(n2, n1 % n2) else n1", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5c03454deff0eb9fcde9cc510353ce45", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main() {\n val solver = Solver(System.`in`, System.out)\n solver.solve()\n solver.clear()\n}\n\nclass Solver(input: InputStream, output: OutputStream) {\n\n companion object {\n private const val MAX_N = (1e6 + 10).toInt()\n private const val INF = (1e9 + 7).toInt()\n private const val MOD = (1e9 + 7).toInt()\n private const val INF_F = 1e-6\n }\n\n private val reader = Reader(input)\n private val writer = Writer(output)\n\n fun solve() {\n val n = reader.next()\n val a = IntArray(125) { 8 * it }\n a.find { check(n, it.toString()) }?.let {\n writer.println(\"YES\")\n writer.println(it)\n } ?: writer.println(\"NO\")\n }\n\n private fun check(n: String, x: String): Boolean {\n var i = 0\n var j = 0\n while (i < n.length && j < x.length) {\n if (n[i] == x[j]) j++\n i++\n }\n return j == x.length\n }\n\n fun clear() {\n writer.close()\n }\n}\n\nprivate fun IntArray.gcd(): Int {\n var g = first()\n forEach { g = gcd(g, it) }\n return g\n}\n\nprivate fun LongArray.gcd(): Long {\n var g = first()\n forEach { g = gcd(g, it) }\n return g\n}\n\nprivate fun gcd(a: Int, b: Int): Int {\n return if (b == 0) a else gcd(b, a % b)\n}\n\nprivate fun gcd(a: Long, b: Long): Long {\n return if (b == 0L) a else gcd(b, a % b)\n}\n\nclass Reader(input: InputStream) {\n private val reader = BufferedReader(InputStreamReader(BufferedInputStream(input)), 32768)\n private var tokenizer: StringTokenizer? = null\n\n 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() = next().toInt()\n\n fun nextLong() = next().toLong()\n\n fun nextStringArray(count: Int): Array {\n return Array(count) { 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 fun nextIntPair(): Pair {\n val x = nextInt()\n val y = nextInt()\n return x to y\n }\n}\n\nclass Writer(output: OutputStream) {\n private val writer = PrintWriter(BufferedOutputStream(output))\n\n fun print(t: T) = writer.print(t)\n fun println() = writer.println()\n fun println(t: T) = writer.println(t)\n\n fun printBooleanArray(array: BooleanArray) = printIntArray(array.map { if (it) 1 else 0 }.toIntArray())\n fun printIntArray(array: IntArray) = array.joinToString(\" \").let(writer::println)\n fun printLongArray(array: LongArray) = array.joinToString(\" \").let(writer::println)\n fun printCharArray(array: CharArray) = array.joinToString(\"\").let(writer::println)\n\n fun close() = writer.close()\n fun flush() = writer.flush()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "877d654481052e33577746983c0566b9", "src_uid": "0a2a5927d24c70aca24fc17aa686499e", "difficulty": 1500.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\nfun main() {\n\n\n\n var a:String = readLine()!!\n\n for (i in 0..a.length-1){\n\n for (l in (i+1)..a.length-1){\n\n for (k in (l+1)..a.length-1){\n var t:String =a[i].toString()+a[l].toString()+a[k].toString();\n if (Integer.parseInt(t)%8==0){\n print(\"YES\\n$t\")\n return\n }\n }\n }\n }\n print(\"NO\")\n}\n\n\n\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "98d73fed35a00d8cd6bfcaf05d92ab01", "src_uid": "0a2a5927d24c70aca24fc17aa686499e", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun main(args: Array) {\n val inp = InputReader(System.`in`)\n val out = PrintWriter(System.out)\n TaskA().solve(inp, out)\n out.close()\n}\n\nclass TaskA {\n fun solve(inp: InputReader, out: PrintWriter) {\n val n = inp.nextInt()\n val ar = Array(n) { Pair(0, 0) }\n for (i in 0 until n)\n ar[i] = Pair(inp.nextInt(), inp.nextInt())\n if (n == 1)\n out.println(\"-1\")\n else {\n Arrays.sort(ar) { o1, o2 ->\n if (o1.first != o2.first)\n o1.first.compareTo(o2.first)\n else\n o1.second.compareTo(o2.second)\n }\n var s = 0\n val x1 = ar[0].first\n val y1 = ar[0].second\n val x2 = ar[1].first\n val y2 = ar[1].second\n when (n) {\n 2 -> {\n s = if (x1 == x2 || y1 == y2)\n -1\n else\n (x2 - x1) * Math.abs(y1 - y2)\n }\n 3 -> {\n val x3 = ar[2].first\n val y3 = ar[2].second\n s = if (x1 == x2)\n (y2 - y1) * (x3 - x1)\n else\n (x2 - x1) * (y3 - y2)\n }\n 4 -> {\n val x3 = ar[2].first\n s = (x3 - x1) * (y2 - y1)\n }\n }\n out.println(s)\n }\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": false, "code_uid": "e9b25fcebc70692444fc4eb9e47a5b7f", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "\nfun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val arr = readLine()!!.split(' ').map(String::toInt)\n\n var m = arr.max()!!\n\n var s1 = 0;\n var s2 = 0;\n\n arr.forEach { s1 += it }\n arr.forEach { s2 += (m!! - it) }\n\n\n while(s2 <= s1){\n s2 += arr.size\n m += 1;\n }\n\n print(m)\n}\n\nvar arr = arrayOfNulls(size = 1000)\n\nfun check(str: String , right: Int , left: Int): Boolean {\n val n = (left - right)\n\n for (i in 0..arr.size - 1) {\n arr[i] = 0;\n }\n\n\n for (i in left..right - 1) {\n val ch = str[i];\n arr[ch.toInt()] = arr[ch.toInt()]!! + 1;\n if (arr[ch.toInt()]!! > n / 2) {\n return false;\n }\n }\n\n return true;\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c38a59ce838103a13f382807fc65bbe3", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.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.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.nextLong()\n var res = n\n var emaxx = 0L\n for (i in n downTo 1)\n emaxx = max(emaxx, nok(res, i))\n res = emaxx\n for (i in n downTo 1)\n emaxx = max(emaxx, nok(res, i))\n println(emaxx)\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}\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)\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "51dd17e073a3bf5ea56afdce7cffb86b", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.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.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.nextLong()\n if (n < 3)\n println(n)\n else if (n % 2 == 1L)\n println(n * (n - 1) * (n - 2))\n else {\n var emaxx = (n - 1) * (n - 2) * (n - 3)\n for (i in max(n-5, 1)..n - 2)\n emaxx = max(nok(nok(i, n), n - 1), emaxx)\n println(emaxx)\n }\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}\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": "12da382dc84e135609185e22c641ce32", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.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)\n\n val init = Array>(m) { Array(1) {1} }\n\n val result = multiplyMatrices(finar, init, m, m, 1)\n\n print(result[0][0])\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "314499d415f196250d6f40477de8be15", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInt() = readLine()!!.toInt()\n\n val options = listOf(\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\")\n val length = readInt()\n val hint = readLine()!!\n nextOption@ for (option in options) {\n if (option.length != length) continue\n for (pos in option.indices) if (hint[pos] != '.' && hint[pos] != option[pos]) continue@nextOption\n return print(option)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5d772ffe2753e85b41a69f49c067584e", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var (a, b) = readLine()!!.split(\" \").map(String::toLong)\n var sol = 0L\n while (b != 0L) {\n sol+= a/b\n val c = a % b\n a = b\n b = c\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "57504313339765c1fd00bbc0b9bd2d26", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.util.NoSuchElementException\nimport java.io.IOException\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport java.util.Arrays\nimport java.util.ArrayList\n\n\nvar sc = FastScanner()\nvar pw = PrintWriter(System.out)\n\nfun main(args: Array) {\n var H = sc.nextInt()\n var W = sc.nextInt()\n var A = Array>(H, {i -> Array(W, {j -> sc.nextInt()})})\n\n var solver = MinCostFlow(H*W+2)\n var s = H * W\n var t = H * W + 1\n\n var dx = arrayOf(0, 1)\n var dy = arrayOf(1, 0)\n\n for(y in 0 until H) for(x in 0 until W) for(i in 0 until 2) {\n var xx = x + dx[i]\n var yy = y + dy[i]\n if(xx < 0 || W <= xx || yy < 0 || H <= yy) continue\n\n var cost = 0\n if(A[y][x] != A[yy][xx]) cost = 1\n\n var a = y * W + x\n var b = yy * W + xx\n if((y + x) % 2 == 1) {\n var t = a\n a = b\n b = t\n }\n\n solver.addEdge(a, b, 1, cost)\n }\n\n for(y in 0 until H) for(x in 0 until W) {\n var a = y * W + x\n if((y + x) % 2 == 0) solver.addEdge(s, a, 1, 0)\n else solver.addEdge(a, t, 1, 0)\n }\n\n var ans = solver.minCostFlow(s, t, H * W / 2)\n println(ans)\n}\n\n\n\n\n\n\n\n\n\ninternal class MinCostFlow(var N: Int// \u9802\u70b9\u6570\n) {\n val INF = 1 shl 29\n var graph: ArrayList>\n\n init {\n this.graph = ArrayList>()\n for (i in 0..N - 1) {\n graph.add(ArrayList())\n }\n }\n\n fun addEdge(from: Int, to: Int, cap: Int, cost: Int) {\n graph[from].add(Edge(to, cap, cost, graph[to].size))\n graph[to].add(Edge(from, 0, -cost, graph[from].size - 1))\n }\n\n fun minCostFlow(start: Int, goal: Int, flow: Int): Int {\n var flow = flow\n val prevNode = IntArray(N)\n val prevEdge = IntArray(N)\n val potential = IntArray(N)// \u30dd\u30c6\u30f3\u30b7\u30e3\u30eb\uff08\u65e2\u306b\u304b\u304b\u3063\u305f\u30b3\u30b9\u30c8\uff09\n var totalCost = 0\n while (flow > 0) {\n val dist = IntArray(N)\n Arrays.fill(dist, INF)\n dist[start] = 0\n\n val priorityQueue = PriorityQueue()\n priorityQueue.offer(Node(0, start))\n while (!priorityQueue.isEmpty()) {\n // \u30ad\u30e5\u30fc\u304b\u30891\u756a\u8ddd\u96e2\u306e\u8fd1\u3044\u30ce\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3059\n val node = priorityQueue.poll()\n val v = node.id\n if (dist[v] < node.dist) {\n // \u66ab\u5b9a\u306e\u6700\u77ed\u8ddd\u96e2\u3088\u308a\u3082\u9060\u304b\u3063\u305f\u3089\u30b9\u30eb\u30fc\n continue\n }\n\n for (i in 0..graph[v].size - 1) {\n val e = graph[v][i]\n\n if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + potential[v] - potential[e.to]) {\n dist[e.to] = dist[v] + e.cost + potential[v] - potential[e.to]\n priorityQueue.add(Node(dist[e.to], e.to))\n\n // \u76f4\u524d\u306e\u7d4c\u8def\u3092\u8a18\u61b6\u3057\u3066\u304a\u304f\n prevNode[e.to] = v\n prevEdge[e.to] = i\n }\n }\n }\n\n // \u305d\u3082\u305d\u3082\u30b4\u30fc\u30eb\u307e\u3067\u8fbf\u308a\u3064\u3051\u306a\u3044\u5834\u5408\u306f\u3069\u3046\u3057\u3088\u3046\u3082\u306a\u3044\n if (dist[goal] == INF) {\n return -1\n }\n\n // \u4eca\u56de\u304b\u304b\u3063\u305f\u30b3\u30b9\u30c8\u3092\u30e1\u30e2\u3057\u3066\u304a\u304f\n for (v in 0..N - 1) {\n potential[v] += dist[v]\n }\n\n // start\u304b\u3089goal\u307e\u3067\u6d41\u305b\u308b\u3060\u3051\u6d41\u3059\n var minFlow = flow\n run {\n var now = goal\n while (now != start) {\n minFlow = Math.min(minFlow, graph[prevNode[now]][prevEdge[now]].cap)\n now = prevNode[now]\n }\n }\n flow -= minFlow\n totalCost += minFlow * potential[goal]\n\n var now = goal\n while (now != start) {\n val edge = graph[prevNode[now]][prevEdge[now]]\n edge.cap -= minFlow\n graph[now][edge.rev].cap += minFlow\n now = prevNode[now]\n }\n }\n return totalCost\n }\n\n internal inner class Node(var dist: Int, var id: Int) : Comparable {\n\n override fun compareTo(o: Node): Int {\n return this.dist - o.dist\n }\n }\n\n internal inner class Edge(var to: Int, var cap: Int, var cost: Int, var rev: Int)\n}\n\n\n\n\n\n\n\nclass FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var bufferLength = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < bufferLength) {\n return true\n } else {\n ptr = 0\n try {\n bufferLength = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (bufferLength <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n if (hasNextByte())\n return buffer[ptr++].toInt()\n else\n return -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n internal operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n internal fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n internal fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n internal fun nextDoubleArray(n: Int): DoubleArray {\n val array = DoubleArray(n)\n for (i in 0..n - 1) {\n array[i] = nextDouble()\n }\n return array\n }\n\n internal fun nextDoubleMap(n: Int, m: Int): Array {\n val map = arrayOfNulls(n)\n for (i in 0..n - 1) {\n map[i] = nextDoubleArray(m)\n }\n return map\n }\n\n fun nextInt(): Int {\n return nextLong().toInt()\n }\n\n fun nextIntArray(n: Int): IntArray {\n val array = IntArray(n)\n for (i in 0..n - 1) {\n array[i] = nextInt()\n }\n return array\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "178a6640b42db839128f958d7964d5c5", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.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-2\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": "865f62924f93665e910e932d38cde932", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main() {\n val s = Scanner(System.`in`)\n val a=s.nextLong()\n val b=s.nextLong();\n println(if(b-a==1L)-1 else \"$a ${a+1} $b\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6bb87964f1e7a4b0dc5c2187d9dfb046", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun gcd (a: Long, b: Long): Long =\n if (a == 0L) b\n else gcd(a % b, a)\n\nfun isCoprime (a: Long, b: Long) = gcd(a, b) == 1L\n\nfun main() {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (l, r) = br.readLine().split(\" \").map { it.toLong() }\n var found = false\n for (i in l .. r) {\n for (j in l .. r){\n for (w in l .. r) {\n if (isCoprime(i, j) && isCoprime(j, w)) {\n if (!isCoprime(i, w)){\n val counterExample = listOf(i, j, w).sorted()\n println(counterExample.joinToString(\" \"))\n found = true\n break\n }\n }\n }\n if (found) break\n }\n if (found) break\n }\n if (!found) println(-1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2ded3397177d78f1e244a88f95bb38fb", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nfun main() {\n val s = Scanner(System.`in`)\n val a=s.nextLong()\n val b=s.nextLong();\n println(if(b-a==1L)-1 else a+1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "dd9c0073e9fc91e05dd2a2358b2a099f", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.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) = if (down < 13) 1 to down else 0 to 12\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": "6a96fc736b14b9846b67999f56144feb", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "Kotlin 1.6", "source_code": "// 2022.07.21 at 23:03:42 HKT\r\nimport FFT.Companion.modplus\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 = 998244353L\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\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\nclass FFT {\r\n companion object{\r\n// val fftmod = 7340033\r\n// val root = 5\r\n// val root_1 = 4404020\r\n// val root_pw = 1 shl 20\r\n\r\n private const val maxPower = 19 // 262144\r\n private const val n = 1 shl maxPower\r\n public const val fftmod = 998244353\r\n private const val root = 15311432\r\n private const val root_1 = 469870224\r\n private const val root_level = 23\r\n private const val root_pw = 1 shl root_level\r\n\r\n const val FFTcut = 80\r\n\r\n\r\n private inline fun normalize(int: Int) = (int shr Int.SIZE_BITS - 1 and fftmod) + int\r\n infix fun Int.modm(other:Int) = (this.toLong() * other % fftmod).toInt()\r\n infix fun Int.modplus(other: Int) = normalize(this + other - fftmod) // overflow-safe even if MOD >= 2^30\r\n infix fun Int.modminus(other: Int) = normalize(this - other)\r\n\r\n val quickpower = Array(maxPower+1){p ->\r\n val base = intPow(root, 1 shl (root_level - p), fftmod)\r\n (0 until (1 shl p)).runningFold(1){a,b -> a modm base}.toIntArray()\r\n }\r\n\r\n\r\n private val rev = IntArray(n).also { rev ->\r\n var bit = 1\r\n var rbit = n shr 1\r\n while(bit < n) {\r\n for(i in 0 until bit) {\r\n rev[i or bit] = rbit or rev[i]\r\n }\r\n bit = bit shl 1\r\n rbit = rbit shr 1\r\n }\r\n }\r\n\r\n fun calculateRoot(){\r\n println(\"root :$root\")\r\n // intPow(3,7 * 17,fftmod)\r\n println(\"root_1 : $root_1\")\r\n // intPow(root,fftmod -2,fftmod)\r\n }\r\n\r\n fun fft(a:IntArray,invert:Boolean){\r\n val n = a.size\r\n kotlin.assert(n <= this.n)\r\n\r\n if(n <= 1) return\r\n val level = this.n.countTrailingZeroBits()\r\n val st = this.n / n\r\n for(i in 0 until n) {\r\n val j = rev[i * st]\r\n if(i < j) a[i] = a[j].also { a[j] = a[i] }\r\n }\r\n\r\n var len = 2\r\n var ang = 1 shl (level -1)\r\n if(invert) ang = -ang\r\n val pt = quickpower[level]\r\n while(len <= n){\r\n\r\n var i = 0\r\n val h = len shr 1\r\n while(i < n){\r\n var k = 0\r\n for(j in i until i+h){\r\n val u = a[j]\r\n val w = pt[k]\r\n val v = a[j+h] modm w\r\n a[j] = u modplus v\r\n a[j+h] = u modminus v\r\n k = k + ang and (1 shl level) - 1\r\n }\r\n i += len\r\n }\r\n len = len shl 1\r\n ang = ang shr 1\r\n }\r\n if(invert){\r\n val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())\r\n for((i,x) in a.withIndex()){\r\n a[i] = (x.toLong() * n_1 % fftmod).toInt()\r\n }\r\n }\r\n }\r\n fun fullconvolution(at:IntArray,bt:IntArray):IntArray{\r\n return fullconvolutionOpt(at,bt,at.size,bt.size)\r\n }\r\n fun brute(A:IntArray,B:IntArray):IntArray{\r\n val ret = IntArray(A.size + B.size -1)\r\n for(i in A.indices){\r\n for(j in B.indices){\r\n ret[i+j] = ret[i+j] modplus (A[i] modm B[j])\r\n }\r\n }\r\n return ret\r\n }\r\n\r\n fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{\r\n // 1 shl 18 done in 77 ms\r\n if(sizeA <= FFTcut || sizeB <= FFTcut){\r\n return brute(at,bt)\r\n }\r\n\r\n val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2\r\n kotlin.assert(maxSize <= (1 shl maxPower))\r\n val a = at.copyOf(maxSize)\r\n val b = bt.copyOf(maxSize)\r\n val expectedSize = at.size + bt.size - 1\r\n fft(a,false)\r\n fft(b,false)\r\n for(i in a.indices){\r\n a[i] = (a[i].toLong() * b[i] % fftmod).toInt()\r\n }\r\n fft(a,true)\r\n return a.copyOf(expectedSize)\r\n }\r\n }\r\n}\r\nclass rsqArrModded(val arr:IntArray){\r\n val ps = IntArray(arr.size + 1)\r\n init{\r\n for(i in 0 until arr.size){\r\n ps[i+1] = ps[i] modPlus arr[i]\r\n }\r\n }\r\n fun sumQuery(l:Int,r:Int): Int {\r\n val ll = maxOf(l,0)\r\n val rr = minOf(arr.lastIndex,r) + 1\r\n return ps[rr] modMinus ps[ll]\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 k = getint\r\n val f = getint\r\n\r\n var now = IntArray(f+2)\r\n for(i in 0..k){\r\n if(i in 0..f){\r\n now[i]++\r\n }else{\r\n now[f+1] ++\r\n }\r\n }\r\n\r\n// just dei now.sum()\r\n repeat(n-1){\r\n val extra = FFT.fullconvolution(now,now)\r\n val reduced = IntArray(f+2)\r\n for((i,v) in extra.withIndex()){\r\n if(i in 0..f){\r\n reduced[i] = reduced[i] modPlus v\r\n }else{\r\n reduced[f+1] = reduced[f+1] modPlus v\r\n }\r\n }\r\n// 1 dei reduced\r\n\r\n\r\n val QM = rsqArrModded(reduced)\r\n val new = IntArray(f+2)\r\n for(x in 0..k){\r\n if(x in 0..f){\r\n new[x] = new[x] modPlus QM.sumQuery(x,f+1)\r\n }else{\r\n new[f+1] = new[f+1] modPlus QM.sumQuery(minOf(f+1,x),f+1)\r\n }\r\n }\r\n for(x in 0..f){\r\n new[x] = new[x] modPlus (reduced[x] modM maxOf(0,k - x))\r\n }\r\n now = new\r\n// 3 dei new\r\n }\r\n val final = FFT.fullconvolution(now,now)\r\n put(final[f])\r\n\r\n\r\n\r\n\r\n }\r\n done()\r\n}\r\n\r\n/*\r\n\r\n\r\n3 2 1 3 2 1\r\n\r\n\r\n1 2\r\n */\r\n\r\n\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "970891723ff02b77df8177bab366c659", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readLongs() = readLine()!!.split(\" \").map(String::toLong)\n\n val (x, y, a, b) = readLongs()\n val (max, min) = if (x >= y) x to y else y to x\n\n var maxValue = max * (a / max) + if (a % max == 0L) 0L else max\n var minValue = min * (a / min) + if (a % min == 0L) 0L else min\n var sol = 0L\n while (maxValue <= b && minValue <= b) {\n when {\n maxValue == minValue -> {\n sol++\n maxValue += max\n minValue += min\n }\n maxValue < minValue -> maxValue += max\n else -> minValue += min\n }\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "1b276d1a47c423bee006ee5584fa9870", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\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 g = Array(5) { IntArray(5) }\n var max = 0\n\n for (i in 0..4)\n for (j in 0..4)\n g[i][j] = ir.nextInt()\n\n for (a in 0..4)\n for (b in 0..4)\n for (c in 0..4)\n for (d in 0..4)\n for (e in 0..4) {\n var count = 0\n val x = HashSet()\n x.add(a)\n x.add(b)\n x.add(c)\n x.add(d)\n x.add(e)\n if (x.size == 5)\n count = g[a][b] + g[b][a] + 2 * (g[c][d] + g[d][c]) + g[b][c] + g[c][b] + 2 * (g[d][e] + g[e][d])\n max = Math.max(max, count)\n }\n\n pw.print(max)\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 nextFloat(): Float {\n return java.lang.Float.parseFloat(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": "eab1245b61e82d3b5623eb1beb846612", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.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 m : Int = ir.nextInt()\n val c = IntArray(m)\n var first = 0\n var second = 0\n for (i in 0 until m) {\n c[i] = ir.nextInt()\n second += c[i]\n }\n val x : Int = ir.nextInt()\n val y : Int = ir.nextInt()\n\n for (i in 0 until m) {\n first += c[i]\n second -= c[i]\n\n if (first in x..y) {\n if (second in x..y) {\n pw.print(\"${i + 2}\")\n return\n }\n }\n }\n\n pw.print(0)\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": "4a573eedc48ed9486db620a6baa8c1ba", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.*\n\nfun main() {\n val fs = CodeForces.FastReader()\n var x = fs.nextInt()\n var y = fs.nextInt()\n var n = fs.nextInt()\n var a:Int=0\n var b:Int=0\n var min:Double = Double.MAX_VALUE\n for (i in n downTo 1) {\n for(j in x downTo 1)\n if (min > abs(x / y.toDouble() - (j / i.toDouble()))) {\n min = abs(x/y.toDouble() - (j/i.toDouble()))\n a=j\n b=i\n }\n }\n println(\"$a/$b\")\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": "c48c0b83f7e88a10fdbf9ee0f48ae37d", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.util.NoSuchElementException\nimport java.io.IOException\nimport java.io.PrintWriter\nimport java.math.BigInteger\nimport java.util.PriorityQueue\nimport java.util.Arrays\nimport java.util.ArrayList\n\n\nvar sc = FastScanner()\nvar pw = PrintWriter(System.out)\n\nfun main(args: Array) {\n var _X = sc.nextLong()\n var _Y = sc.nextLong()\n var _L = sc.nextLong()\n var _R = sc.nextLong()\n\n var X = BigInteger(_X.toString())\n var Y = BigInteger(_Y.toString())\n var L = BigInteger(_L.toString())\n var R = BigInteger(_R.toString())\n\n var set:MutableSet = mutableSetOf()\n var XX = BigInteger(\"1\")\n for(a in 0..64) {\n if(R < XX) break\n var YY = BigInteger(\"1\")\n for(b in 0..64) {\n if(R < XX) break\n if(L <= XX + YY && XX + YY <= R) {\n var x = (XX + YY).toLong()\n set.add(x)\n }\n YY *= Y\n }\n XX *= X\n }\n\n if(set.size == 0) {\n println(_R - _L + 1)\n return\n }\n\n set = set.toSortedSet()\n var ans = 0L\n var pre = -1L\n for(i in set.sorted()) {\n if(0 <= pre) ans = Math.max(ans, i - pre - 1)\n pre = i\n }\n ans = Math.max(ans, set.first() - _L)\n ans = Math.max(ans, _R - set.last())\n println(ans)\n}\n\n\n\n\n\nclass FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var bufferLength = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < bufferLength) {\n return true\n } else {\n ptr = 0\n try {\n bufferLength = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (bufferLength <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n if (hasNextByte())\n return buffer[ptr++].toInt()\n else\n return -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n internal operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n internal fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n internal fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n internal fun nextDoubleArray(n: Int): DoubleArray {\n val array = DoubleArray(n)\n for (i in 0..n - 1) {\n array[i] = nextDouble()\n }\n return array\n }\n\n internal fun nextDoubleMap(n: Int, m: Int): Array {\n val map = arrayOfNulls(n)\n for (i in 0..n - 1) {\n map[i] = nextDoubleArray(m)\n }\n return map\n }\n\n fun nextInt(): Int {\n return nextLong().toInt()\n }\n\n fun nextIntArray(n: Int): IntArray {\n val array = IntArray(n)\n for (i in 0..n - 1) {\n array[i] = nextInt()\n }\n return array\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cae1170057ea6f88eba8b6577f2f29d4", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport java.util.NoSuchElementException\nimport java.io.IOException\nimport java.io.PrintWriter\nimport java.math.BigInteger\nimport java.util.PriorityQueue\nimport java.util.Arrays\nimport java.util.ArrayList\n\n\nvar sc = FastScanner()\nvar pw = PrintWriter(System.out)\n\nfun main(args: Array) {\n var _X = sc.nextLong()\n var _Y = sc.nextLong()\n var _L = sc.nextLong()\n var _R = sc.nextLong()\n\n var X = BigInteger(_X.toString())\n var Y = BigInteger(_Y.toString())\n var L = BigInteger(_L.toString())\n var R = BigInteger(_R.toString())\n\n var set:MutableSet = mutableSetOf()\n var XX = BigInteger(\"1\")\n for(a in 0..64) {\n if(R < XX) break\n var YY = BigInteger(\"1\")\n for(b in 0..64) {\n if(R < XX) break\n if(L <= XX + YY && XX + YY <= R) {\n var x = (XX + YY).toLong()\n set.add(x)\n }\n YY *= Y\n }\n XX *= X\n }\n\n set = set.toSortedSet()\n var ans = 0L\n var pre = -1L\n for(i in set.sorted()) {\n if(0 <= pre) ans = Math.max(ans, i - pre - 1)\n pre = i\n }\n ans = Math.max(ans, set.first() - _L)\n ans = Math.max(ans, _R - set.last())\n println(ans)\n}\n\n\n\n\n\n\n\n\n\ninternal class MinCostFlow(var N: Int// \u9802\u70b9\u6570\n) {\n val INF = 1 shl 29\n var graph: ArrayList>\n\n init {\n this.graph = ArrayList>()\n for (i in 0..N - 1) {\n graph.add(ArrayList())\n }\n }\n\n fun addEdge(from: Int, to: Int, cap: Int, cost: Int) {\n graph[from].add(Edge(to, cap, cost, graph[to].size))\n graph[to].add(Edge(from, 0, -cost, graph[from].size - 1))\n }\n\n fun minCostFlow(start: Int, goal: Int, flow: Int): Int {\n var flow = flow\n val prevNode = IntArray(N)\n val prevEdge = IntArray(N)\n val potential = IntArray(N)// \u30dd\u30c6\u30f3\u30b7\u30e3\u30eb\uff08\u65e2\u306b\u304b\u304b\u3063\u305f\u30b3\u30b9\u30c8\uff09\n var totalCost = 0\n while (flow > 0) {\n val dist = IntArray(N)\n Arrays.fill(dist, INF)\n dist[start] = 0\n\n val priorityQueue = PriorityQueue()\n priorityQueue.offer(Node(0, start))\n while (!priorityQueue.isEmpty()) {\n // \u30ad\u30e5\u30fc\u304b\u30891\u756a\u8ddd\u96e2\u306e\u8fd1\u3044\u30ce\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3059\n val node = priorityQueue.poll()\n val v = node.id\n if (dist[v] < node.dist) {\n // \u66ab\u5b9a\u306e\u6700\u77ed\u8ddd\u96e2\u3088\u308a\u3082\u9060\u304b\u3063\u305f\u3089\u30b9\u30eb\u30fc\n continue\n }\n\n for (i in 0..graph[v].size - 1) {\n val e = graph[v][i]\n\n if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + potential[v] - potential[e.to]) {\n dist[e.to] = dist[v] + e.cost + potential[v] - potential[e.to]\n priorityQueue.add(Node(dist[e.to], e.to))\n\n // \u76f4\u524d\u306e\u7d4c\u8def\u3092\u8a18\u61b6\u3057\u3066\u304a\u304f\n prevNode[e.to] = v\n prevEdge[e.to] = i\n }\n }\n }\n\n // \u305d\u3082\u305d\u3082\u30b4\u30fc\u30eb\u307e\u3067\u8fbf\u308a\u3064\u3051\u306a\u3044\u5834\u5408\u306f\u3069\u3046\u3057\u3088\u3046\u3082\u306a\u3044\n if (dist[goal] == INF) {\n return -1\n }\n\n // \u4eca\u56de\u304b\u304b\u3063\u305f\u30b3\u30b9\u30c8\u3092\u30e1\u30e2\u3057\u3066\u304a\u304f\n for (v in 0..N - 1) {\n potential[v] += dist[v]\n }\n\n // start\u304b\u3089goal\u307e\u3067\u6d41\u305b\u308b\u3060\u3051\u6d41\u3059\n var minFlow = flow\n run {\n var now = goal\n while (now != start) {\n minFlow = Math.min(minFlow, graph[prevNode[now]][prevEdge[now]].cap)\n now = prevNode[now]\n }\n }\n flow -= minFlow\n totalCost += minFlow * potential[goal]\n\n var now = goal\n while (now != start) {\n val edge = graph[prevNode[now]][prevEdge[now]]\n edge.cap -= minFlow\n graph[now][edge.rev].cap += minFlow\n now = prevNode[now]\n }\n }\n return totalCost\n }\n\n internal inner class Node(var dist: Int, var id: Int) : Comparable {\n\n override fun compareTo(o: Node): Int {\n return this.dist - o.dist\n }\n }\n\n internal inner class Edge(var to: Int, var cap: Int, var cost: Int, var rev: Int)\n}\n\n\n\n\n\n\n\nclass FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var bufferLength = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < bufferLength) {\n return true\n } else {\n ptr = 0\n try {\n bufferLength = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (bufferLength <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n if (hasNextByte())\n return buffer[ptr++].toInt()\n else\n return -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n internal operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b)\n b = readByte()\n }\n return sb.toString()\n }\n\n internal fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toInt()) {\n minus = true\n b = readByte()\n }\n if (b < '0'.toInt() || '9'.toInt() < b) {\n throw NumberFormatException()\n }\n while (true) {\n if ('0'.toInt() <= b && b <= '9'.toInt()) {\n n *= 10\n n += (b - '0'.toInt()).toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n internal fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n internal fun nextDoubleArray(n: Int): DoubleArray {\n val array = DoubleArray(n)\n for (i in 0..n - 1) {\n array[i] = nextDouble()\n }\n return array\n }\n\n internal fun nextDoubleMap(n: Int, m: Int): Array {\n val map = arrayOfNulls(n)\n for (i in 0..n - 1) {\n map[i] = nextDoubleArray(m)\n }\n return map\n }\n\n fun nextInt(): Int {\n return nextLong().toInt()\n }\n\n fun nextIntArray(n: Int): IntArray {\n val array = IntArray(n)\n for (i in 0..n - 1) {\n array[i] = nextInt()\n }\n return array\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6cf5c920cda8e1069e35be177d575734", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.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\", \"fifteen\", \"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": "f1fb2facb211cf9376e53842f1b0dd85", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val password = readLine()!!\n val numWords = readLine()!!.toInt()\n val words = Array(numWords) { \"\" }\n for (pos in 0 until numWords) words[pos] = readLine()!!\n for (pos1 in 0 until numWords)\n for (pos2 in pos1 until numWords)\n if (password in (words[pos1] + words[pos2]) || password in (words[pos2] + words[pos1])) return print(\"YES\")\n print(\"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e202511899e964bd0eecd284c2f7637b", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.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 (vp, vd, t, f, c) = List(5){br.readLine().toDouble()}\n if (vp >= vd || vp*t == c) println(0)\n else {\n var cnt = 1\n var p = vd*(vp*t/(vd - vp))\n while (p < c) {\n p = vd*(vp*(f + p/vd) + p)/(vd - vp)\n cnt += if (p < c) 1 else 0\n }\n println(cnt)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0edd059d213c9f4b94f1acb813ab9e9e", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.collections.ArrayList\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 var n = ir.nextInt()\n val res = IntArray(3)\n val max = IntArray(3)\n\n for (i in 0..2) {\n res[i] = ir.nextInt()\n n -= res[i]\n max[i] = ir.nextInt()\n }\n\n for (i in 0..2)\n if (max[i] - res[i] <= n) {\n res[i] = max[i]\n n = n - max[i] + res[i]\n } else {\n res[i] += n\n break\n }\n\n for (i in 0..2)\n pw.print(\"${res[i]} \")\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 nextFloat(): Float {\n return java.lang.Float.parseFloat(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": "6b7d2c5e55898559588c3fa10f4fbda6", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import java.io.InputStream\n\nval input = FastScanner()\n\nfun main(args: Array) = input.run {\n val m = nextInt()\n val b = nextInt()\n\n var ans = 0L\n\n (0..b).forEach { y ->\n val x = (b - y) * m\n var acc = 0L\n (0..y).forEach { yy ->\n acc += (x + 1) * yy.toLong() + x * (x + 1L) / 2\n }\n ans = ans.coerceAtLeast(acc)\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": "f8823630df4ee153866125e4884dff3f", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.math.BigInteger\n\nfun main() {\n val n = readLine()!!.toInt()\n val x = BigInteger(\"2\").pow(n).minus(BigInteger(\"1\"))\n val b = BigInteger(readLine()!!.reversed().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": false, "code_uid": "ff5d43763d42ee4f4468d40e6435fb8a", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Kotlin", "source_code": "import java.util.*\n\n\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n\n var a1 = a / 3\n var a2 = a / 3\n var a3 = a / 3\n when (a.rem(3)) {\n 0 -> {}\n 1 -> a1++\n 2 -> {\n a1++\n a2++\n }\n }\n var b1 = b / 2\n var b2 = b / 2\n b1 += b.rem(2)\n var c1 = c / 2\n var c2 = c / 2\n c1 += c.rem(2)\n\n var res = 0\n res = Math.max(res, days(arrayOf(a1, b1, c1, a2, c2, b2, a3)))\n res = Math.max(res, days(arrayOf(b1, c1, a1, c2, b2, a2, a3)))\n res = Math.max(res, days(arrayOf(c1, a1, c2, b1, a2, a3, b2)))\n res = Math.max(res, days(arrayOf(a1, c1, b1, a2, a3, b2, c2)))\n res = Math.max(res, days(arrayOf(c1, b1, a1, a2, b2, c2, a3)))\n res = Math.max(res, days(arrayOf(b1, a1, a2, b2, c1, a3, c2)))\n res = Math.max(res, days(arrayOf(a1, a2, b1, c1, a3, c2, b2)))\n\n println(res)\n}\n\nfun days(week: Array): Int {\n val min = week.min()!!\n var days = min * 7\n var pos = 0\n while (pos < 7) {\n if (week[pos] > min) {\n days++\n } else {\n break\n }\n pos++\n }\n return days\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "94b58194d7eb56139dea1a545d32f6c3", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main() {\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 val longMap = IntArray(26)\n for (c in longer) longMap[c - 'a']++\n for (c in shorter) {\n if (longMap[c - 'a'] > 0) longMap[c - 'a']-- else {\n print(\"need tree\")\n return\n }\n }\n val automaton = longer.length != shorter.length\n var sPos = 0\n var lPos = 0\n while (sPos < shorter.length && lPos < longer.length) {\n if (shorter[sPos] == longer[lPos]) sPos++\n lPos++\n }\n print(\n when {\n automaton && sPos < shorter.length -> \"both\"\n automaton -> \"automaton\"\n else -> \"array\"\n }\n )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "04821649759ff4d37e878058fc47c6f7", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import kotlin.math.abs\n\nfun readLn() = readLine()!!\nfun readInt() = readLn().toInt()\nfun readStrings() = readLn().split(\" \")\nfun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n var (n, m, k, l) = readInts()\n if (n > m) print(\"First\") else print(\"Second\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f39348bb6748c7aa3d67c1c641d67a8c", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.ArrayList\n\n// 25 50 75 00\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextLine()\n val l = n.length\n val ref = ArrayList()\n\n var flag = false\n\n val _0 = n.count { it == '0' }\n val _2 = n.count { it == '2' }\n val _5 = n.count { it == '5' }\n val _7 = n.count { it == '7' }\n\n var leadingZeros = 0\n for (i in 1 until l) {\n if (n[i] == '0') {\n leadingZeros++\n } else {\n break\n }\n }\n\n if (_0 >= 2) { // ..00\n flag = true\n\n val i0a = n.lastIndexOf('0')\n val i0b = n.substring(0 until i0a).lastIndexOf('0')\n\n ref.add(2 * l - i0a - i0b - 3)\n }\n\n if (_2 >= 1 && _5 >= 1) if (leadingZeros != l - 2 || l == 2) { // ..25\n flag = true\n\n val i2 = n.lastIndexOf('2')\n val i5 = n.lastIndexOf('5')\n\n var r = 2 * l - i2 - i5 - 3\n if (i2 > i5) {\n if (i5 == 0) r += leadingZeros\n r += 1\n } else {\n if (i2 == 0) r += leadingZeros\n }\n\n ref.add(r)\n }\n\n if (_5 >= 1 && _0 >= 1) if (leadingZeros != l - 1 || l == 2) { // ..50\n flag = true\n var _leadingZeros = leadingZeros\n\n val i5 = n.lastIndexOf('5')\n val i0 = n.lastIndexOf('0')\n\n if (i0 == _leadingZeros) _leadingZeros--\n\n var r = 2 * l - i5 - i0 - 3\n if (i5 > i0) {\n r += 1\n } else {\n if (i5 == 0) r += _leadingZeros\n }\n\n ref.add(r)\n }\n\n if (_7 >= 1 && _5 >= 1) if (leadingZeros != l - 2 || l == 2) { // ..75\n flag = true\n\n val i7 = n.lastIndexOf('7')\n val i5 = n.lastIndexOf('5')\n\n var r = 2 * l - i7 - i5 - 3\n if (i7 > i5) {\n if (i5 == 0) r += leadingZeros\n r += 1\n } else {\n if (i7 == 0) r += leadingZeros\n }\n\n ref.add(r)\n }\n\n if (flag) {\n println(ref.min())\n } else {\n println(-1)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2c7ddb7ad98235df36fc56c6b9cb01a6", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "data class Point(val x:Int, val y:Int)\n\nfun constructPoint(p1:Point, p2:Point, p3:Point):Point {\n return Point(p3.x + p2.x - p1.x, p3.y + p2.y - p1.y)\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 set = mutableSetOf(\n constructPoint(p1, p2, p3),\n constructPoint(p1, p3, p2),\n constructPoint(p2, p1, p3),\n constructPoint(p2, p3, p1),\n constructPoint(p3, p1, p2),\n constructPoint(p3, p2, p1))\n\n println(set.size)\n for (p in set) {\n println(\"${p.x} ${p.y}\")\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6b80bbb0a851f1d2b582832f572c9e71", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "fun main() {\n val cmd = readLine()!!\n val direction = mutableMapOf(\n 'L' to Pair(-1, 0),\n 'R' to Pair(1, 0),\n 'U' to Pair(0, -1),\n 'D' to Pair(0, 1)\n )\n val path = mutableListOf(Pair(0, 0))\n var x = 0\n var y = 0\n var i = 0\n for (step in cmd) {\n x += direction[step]!!.first\n y += direction[step]!!.second\n i++\n if (path.contains(Pair(x, y))) {\n println(\"BUG\")\n return\n }\n path.add(Pair(x, y))\n }\n val bfs = mutableListOf(Pair(Pair(0, 0), 0))\n val visited = mutableSetOf>()\n while (bfs.isNotEmpty()) {\n val front = bfs.first()\n if (front.first == Pair(x, y) && front.second < cmd.length) {\n println(\"BUG\")\n return\n }\n bfs.removeAt(0)\n for (d in direction.values) {\n val nx = front.first.first + d.first\n val ny = front.first.second + d.second\n val cell = Pair(nx, ny)\n if (!visited.contains(cell) && path.contains(cell)) {\n val ns = front.second + 1\n visited.add(Pair(nx, ny))\n bfs.add(Pair(Pair(nx, ny), ns))\n }\n }\n }\n println(\"OK\")\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "622bdc78ddab3762ade26eb95fd4886e", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\n\nfun solve(cin: FastReader, out: PrintWriter) {\n var s = cin.int()\n var n = cin.int()\n out.println((n + s - 1) / s)\n}\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.close()\n}\n\nfun gcd(a: Int, b: Int): Int {\n if (a == 0)\n return b\n return gcd(b % a, a)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "a20262d6c5f2bdd57b84ef1567b08db2", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.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\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val MAX = if (isDebug) 100 else 100_000\n val flg = BooleanArray(MAX + 1){true}\n val primes = mutableListOf()\n flg[0] = false\n flg[1] = false\n\n for (i in 2 .. MAX) {\n if (!flg[i]) continue\n primes += i\n\n var j = i * 2\n while (j <= MAX) {\n flg[j] = false\n j += i\n }\n }\n\n fun isPrime(a: Int): Boolean {\n for (p in primes) {\n if (a <= p) return true\n if (a % p == 0) return false\n }\n return true\n }\n\n val N = ni()\n if (isPrime(N)) {\n out.println(1)\n out.println(\"$N\")\n return\n }\n\n var Pn = N - 2\n while(!isPrime(Pn)) {\n Pn--\n }\n\n val x = N - Pn\n if (isPrime(x)) {\n out.println(2)\n out.println(\"$Pn $x\")\n return\n }\n\n for (p in primes) {\n if (flg[x - p]) {\n out.println(3)\n out.println(\"$Pn $p ${x - p}\")\n return\n }\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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": "0b149707ac3f4c95d6d233bcedcbf75f", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun DataReader.solve(out: PrintWriter) {\n val n = nextInt()\n val next = readIntArray(n).map { it - 1 }\n val cycles = mutableListOf()\n\n val visited = BooleanArray(n)\n\n for (i in 0 until n) {\n if (visited[i]) continue\n var k = next[i]\n var l = 1\n while (k != i && !visited[k]) {\n visited[k] = true\n k = next[k]\n l++\n }\n\n if (k != i) {\n out.println(-1)\n return\n }\n\n val q = if (l % 2 == 0) l / 2 else l\n cycles.add(q.toLong())\n }\n\n out.println(cycles.fold(1L, ::lcm))\n}\n\nfun lcm(x: Long, y: Long) = x * y / gcd(x, y)\n\ntailrec fun gcd(x: Long, y: Long): Long {\n if (x == 0L || y == 0L) return x + y\n\n return if (x > y) gcd(x % y, y) else gcd(y % x, x)\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": "494991a1ce34ec6823adef4eaf11c461", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s1 = StringBuilder()\n //val (s, n) = r.readLine()!!.split(\" \").map { it.toInt() }\n //val n = r.readLine()!!.toInt()\n val (a, b, c) = r.readLine()!!.split(\" \").map { it.toLong() }\n if (c == 0L) println(\"NO\") else\n println(if ((b - a) % c == 0L) \"YES\" else \"NO\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "314380bfbda09539e9119c153fbfea5c", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Kotlin", "source_code": "import kotlin.math.max\n\nfun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (numDays, numKilos) = readInts()\n val prices = readInts()\n var best = 0\n for (day in 0 until numDays - 1)\n best = max(best, prices[day] - prices[day + 1] - numKilos)\n print(best)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0e024b6f4ed816250bcd0dcb735de07a", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val home = readLine()!!\n val flyes = (0 until n).map{ readLine()!!}\n\n println( if (flyes.count{it.startsWith(home)}.let { flyes.size - it >= it }) \"home\" else \"contest\" )\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eb7ff8597f9054967fd059d610a2d6bc", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval (n,m) = f.readLine().split(\" \").map{it.toInt()}\n\n\tvar answer = 2*n+1\n\tanswer += min(n+m-2,2*n-m-1)\n\n\tprintln(answer)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c8aef8fafbff8df21e8f6e8c97ab9ea5", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "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 = 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: Int = ir.nextInt()\n val k: Int = ir.nextInt()\n\n if (k == 1 || k == n)\n pw.print(n * 3)\n else if (k - 1 <= n - k)\n pw.print(\"${(n * 3) + k - 1}\")\n else\n pw.print(\"${(n * 4) - k}\")\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": "1f199d07a36435e255c3a9092196b079", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n var n = readLine()!!.toInt()\n var list = readLine()!!.split(' ').map { it.toInt() }.sum()\n var ans = 0\n for (i in 1..5) {\n if ((list + i) % (n + 1) != 1) {\n ans++\n }\n }\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "c001b7a62a0d30fe288c5c4f78cc8540", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nval reader = Scanner(System.`in`)\nvar c = 0\nvar ans = 0\nfun main(args: Array) {\n val n = reader.nextInt()\n for (i in 1..n)\n c+=reader.nextInt()\n for (i in 1..5)\n {\n if ((i+c)%(n+1) !=1)\n ans++\n }\n /*if ((c+1)%(n+1)==1)\n println(2)\n else\n println(3)*/\n println(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "de60792aa2a87875d084fd5125534683", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "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() - 1) {\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": "3c750e40a9d35fc6fe222d29692af34a", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.BufferedReader\nimport java.lang.System.out\nimport java.util.*\n\nclass Solver {\n private val inp = FastInputReader()\n\n fun solve() {\n System.getProperties().forEach {\n try {\n println(it)\n } catch (e: Exception) {\n }\n }\n// val a = inp.readIntTable(4, 4)\n// a.forEachIndexed { i, row ->\n// if (row[3] == 1) {\n// if (a[(i + 4 - 1) % 4][0] + a[(i + 1) % 4][2] + a[(i + 2) % 4][1] > 0) {\n// print(\"YES\")\n// return\n// }\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\nclass FastInputReader {\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(size, { readInt() })\n fun readLongArray(size: Int) = LongArray(size, { readLong() })\n fun readStringArray(size: Int) = Array(size, { next() })\n inline fun readTArray(size: Int, convert: (Int, String) -> T) = Array(size, { convert(it, next()) })\n\n fun readIntTable(rows: Int, cols: Int) = Array(rows, { readIntArray(cols) })\n fun readLongTable(rows: Int, cols: Int) = Array(rows, { readLongArray(cols) })\n fun readStringTable(rows: Int, cols: Int) = Array(rows, { readStringArray(cols) })\n inline fun readTTable(rows: Int, cols: Int, convert: (Int, Int, String) -> T) = Array(rows, { readTArray(cols, { col, s -> convert(it, col, s) }) })\n}\n\nfun main(args: Array) {\n// val millis = measureTimeMillis(Solver()::solve)\n// System.err.println(\"Time spent: $millis\")\n Solver().solve()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "854b6ea17edbab6ea03fe2a7ab2bfef8", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "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 N = 1e5.toInt()+5 //1e9.toInt() + 7\n\n\nfun main() {\n val (n,h,m) = readInts()\n val arr = Array(n+1,{h})\n repeat(m)\n {\n val (l,r,x) = readInts()\n for(i in l..r)\n {\n arr[i] = min(arr[i],x)\n }\n }\n var sum = 0\n for(i in 1..n)\n {\n sum += arr[i]*arr[i]\n }\n println(sum)\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ddd450aa1e90a5df4eff543226b7790a", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "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(\"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 == 0L && rem >= m || d != 0L && (d % 2 == 0L || 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": "3dd6cd971c7fbb8073b279ff689f7e24", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.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 val m = sc.nextInt()\n\n val vs = Array(n + 1) { i -> Vertex(i) }\n\n repeat(m) {\n val u = vs[sc.nextInt()]\n val v = vs[sc.nextInt()]\n u.edge.add(v)\n v.edge.add(u)\n }\n\n solve(n, vs, mutableListOf())\n println(max)\n}\n\n\nvar max = -1\n\nfun solve(n: Int, vs: Array, marked: MutableList) {\n if (marked.size == n) {\n val res: Int = check(n, vs, marked) ?: -1\n if (res == 21) {\n println(marked)\n readLine()\n }\n max = maxOf(max, res)\n return\n }\n\n for (j in 1..6) {\n marked.add(j)\n solve(n, vs, marked)\n marked.removeAt(marked.lastIndex)\n }\n}\n\nfun check(n: Int, vs: Array, marked: MutableList): Int? {\n val used = mutableSetOf()\n for (x in 1..n) {\n val v = vs[x]\n for (u in v.edge) {\n if (v.n >= u.n) continue\n used.add(Domino(minOf(marked[v.n - 1], marked[u.n - 1]), maxOf(marked[v.n - 1], marked[u.n - 1])))\n }\n }\n return used.size\n}\n\ndata class Domino(val x: Int, val y: Int)\n\n\ndata class Vertex(val n: Int) {\n val edge = mutableListOf()\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": "648a0a0d8c72fed08093175c29bb4ac6", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.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 val m = readInt()\n\n if(n <= 6) {\n println(m)\n return@output\n }\n\n val G = List(n) { hashSetOf() }\n\n repeat(m) {\n val a = readInt() - 1\n val b = readInt() - 1\n G[a].add(b)\n G[b].add(a)\n }\n\n var ans = 0\n\n for(i in 0 until n-1) {\n for(j in i+1 until n) {\n ans = maxOf(ans, m - (G[i] intersect G[j]).size)\n }\n }\n\n println(ans)\n }\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": "f4c912513e4f01e793548ed1989b1db8", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "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 adj = Array(n) { mutableSetOf() }\n for (i in 0 until m) {\n val u = sc.nextInt() - 1\n val v = sc.nextInt() - 1\n adj[u].add(v)\n adj[v].add(u)\n }\n if (n <= 6) {\n println(m)\n } else {\n var max = 0\n for (i in 0 until n) {\n for (j in 0 until n) {\n val count = m - adj[i].intersect(adj[j]).count()\n max = Math.max(max, count)\n }\n }\n println(max)\n }\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}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "955325d4b9e84934e016d94f7d497d85", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "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.*\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 }!!\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": "95535bd0c3df9d724183e0fa7604b04c", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\n\n\nfun main(){\n var a = ni()\n var b = ni()\n var diff = b - a\n var times = Math.ceil(a.toDouble() / diff.toDouble()).toInt()\n var A = diff*times\n var k = A-a\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": "46d31ccb8646aadfb7e800c90ce206f5", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.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()\n val (r, c) = n - 2 * x to m - 2 * x\n fun ans(x: Int):Int {\n val (r, c) = n - 2 * (x - 1) to m - 2 * (x - 1)\n return if (r < 0 || c < 0)\n 0\n else\n ((r-(r / 2)) * ((c + 1) / 2)) + ((r / 2) * (c / 2))\n }\n println(ans(x) - ans(x+1))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "f0c2b7dd499d6c8191a48175c3afcbc0", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main() {\n\n val scanner = Scanner(System.`in`)\n\n val destPoint = scanner.nextInt()\n val maxLitersCount = scanner.nextInt()\n val stationCoordinate = scanner.nextInt()\n val ridesCount = scanner.nextInt()\n\n var ans = 0\n\n var currentFuel = maxLitersCount\n var distanceToRide: Int\n\n if (maxLitersCount < stationCoordinate) {\n println(-1)\n return\n } else {\n currentFuel -= stationCoordinate\n }\n\n for (currentRideNumber in 0 until ridesCount) {\n distanceToRide = if (currentRideNumber.rem(2) == 0) {\n destPoint - stationCoordinate\n } else {\n stationCoordinate\n }\n if (currentRideNumber < ridesCount - 1) {\n distanceToRide *= 2\n }\n if (maxLitersCount < distanceToRide) {\n println(-1)\n return\n } else if (currentFuel < distanceToRide) {\n ans++\n currentFuel = maxLitersCount\n }\n\n currentFuel -= distanceToRide\n }\n\n println(ans)\n\n\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "df60e3c4f4ee7931030a1595f11636ad", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b, f, k) = readLine()!!.split(\" \").map { it.toInt() }\n var x = 0\n var y = b\n var ans = 0\n if (b < f || b < a - f) {\n print(-1)\n return\n }\n repeat(k - 1) {\n when {\n k > 2 && x == a && 2 * f > b -> {\n print(-1)\n return\n }\n k > 1 && x == 0 && 2 * (a - f) > b -> {\n print(-1)\n return\n }\n x == 0 && a + a - f > y -> {\n x = a\n y = b - (x - f)\n ans++\n }\n x == 0 -> {\n x = a\n y -= a\n }\n x == a && a + f > y -> {\n x = 0\n y = b - f\n ans++\n }\n x == a -> {\n x = 0\n y -= a\n }\n }\n }\n if (y < a) ans++\n print(ans)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "096e2d213ad5a023ea1c311769d5ac7a", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Kotlin", "source_code": "import kotlin.math.exp\nimport kotlin.math.sqrt\n\nfun main() {\n readLn()\n val s = readLn()\n \n var ans = 0\n for(c in s) {\n when(c) {\n '-' -> {\n if(ans > 0) ans--\n }\n '+' -> ans++\n }\n }\n\n println(ans)\n}\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": "92ead72ecd395156c0fdc59e73751aff", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main(arg: Array){\n var s1: String\n var s2: String\n var s3: String\n var s4: String\n var s5: String\n var s6: String\n s1 = readLine()!!\n s2 = readLine()!!\n s3 = readLine()!!\n s4 = readLine()!!\n s5 = readLine()!!\n s6 = readLine()!!\n \n if (s1.substring(3,4)==\".\")\n {\n s1 = s1.substring(0,3)+\"P\"+s1.substring(4)\n } else if (s1.substring(4,5)==\".\")\n {\n s1 = s1.substring(0,4)+\"P\"+s1.substring(5)\n } else if (s2.substring(3,4)==\".\")\n {\n s2 = s2.substring(0,3)+\"P\"+s2.substring(4)\n } else if (s2.substring(4,5)==\".\")\n {\n s2 = s2.substring(0,4)+\"P\"+s2.substring(5)\n } else if (s1.substring(0,1)==\".\")\n {\n s1 = \"P\"+s1.substring(1)\n } else if (s1.substring(1,2)==\".\")\n {\n s1 = s1.substring(0,1)+\"P\"+s1.substring(2)\n } else if (s2.substring(0,1)==\".\")\n {\n s2 = \"P\"+s2.substring(1)\n } else if (s2.substring(1,2)==\".\")\n {\n s2 = s2.substring(0,1)+\"P\"+s2.substring(2)\n } else if (s1.substring(6,7)==\".\")\n {\n s1 = s1.substring(0,6)+\"P\"+s1.substring(7)\n } else if (s1.substring(7,8)==\".\")\n {\n s1 = s1.substring(0,7)+\"P\"\n } else if (s2.substring(6,7)==\".\")\n {\n s2 = s2.substring(0,6)+\"P\"+s2.substring(7)\n } else if (s2.substring(7,8)==\".\")\n {\n s2 = s2.substring(0,7)+\"P\"\n } else if (s3.substring(3,4)==\".\")\n {\n s3 = s3.substring(0,3)+\"P\"+s3.substring(4)\n } else if (s3.substring(4,5)==\".\")\n {\n s3 = s3.substring(0,4)+\"P\"+s3.substring(5)\n } else if (s4.substring(3,4)==\".\")\n {\n s4 = s4.substring(0,3)+\"P\"+s4.substring(4)\n } else if (s4.substring(4,5)==\".\")\n {\n s4 = s4.substring(0,4)+\"P\"+s4.substring(5)\n } else if (s5.substring(3,4)==\".\")\n {\n s5 = s5.substring(0,3)+\"P\"+s5.substring(4)\n } else if (s5.substring(4,5)==\".\")\n {\n s5 = s5.substring(0,4)+\"P\"+s5.substring(5)\n } else if (s6.substring(3,4)==\".\")\n {\n s6 = s6.substring(0,3)+\"P\"+s6.substring(4)\n } else if (s6.substring(4,5)==\".\")\n {\n s6 = s6.substring(0,4)+\"P\"+s6.substring(5)\n } else if (s3.substring(0,1)==\".\")\n {\n s3 = s3.substring(0,0)+\"P\"+s3.substring(1)\n } else if (s3.substring(1,2)==\".\")\n {\n s3 = s3.substring(0,1)+\"P\"+s3.substring(2)\n } else if (s4.substring(0,1)==\".\")\n {\n s4 = s4.substring(0,0)+\"P\"+s4.substring(1)\n } else if (s4.substring(1,2)==\".\")\n {\n s4 = s4.substring(0,1)+\"P\"+s4.substring(2)\n } else if (s3.substring(6,7)==\".\")\n {\n s3 = s3.substring(0,6)+\"P\"+s3.substring(7)\n } else if (s3.substring(7,8)==\".\")\n {\n s3 = s3.substring(0,7)+\"P\"+s3.substring(8)\n } else if (s4.substring(6,7)==\".\")\n {\n s4 = s4.substring(0,6)+\"P\"+s4.substring(7)\n } else if (s4.substring(7,8)==\".\")\n {\n s4 = s4.substring(0,7)+\"P\"+s4.substring(8)\n } else if (s5.substring(6,7)==\".\")\n {\n s5 = s5.substring(0,6)+\"P\"+s5.substring(7)\n } else if (s5.substring(7,8)==\".\")\n {\n s5 = s5.substring(0,7)+\"P\"+s5.substring(8)\n } else if (s6.substring(6,7)==\".\")\n {\n s6 = s6.substring(0,6)+\"P\"+s6.substring(7)\n } else if (s6.substring(7,8)==\".\")\n {\n s6 = s6.substring(0,7)+\"P\"+s6.substring(8)\n } else if (s5.substring(0,1)==\".\")\n {\n s5 = s5.substring(0,0)+\"P\"+s5.substring(1)\n } else if (s5.substring(1,2)==\".\")\n {\n s5 = s5.substring(0,1)+\"P\"+s5.substring(2)\n } else if (s6.substring(0,1)==\".\")\n {\n s6 = s6.substring(0,0)+\"P\"+s6.substring(1)\n } else if (s6.substring(1,2)==\".\")\n {\n s6 = s6.substring(0,1)+\"P\"+s6.substring(2)\n }\n \n \n println(s1)\n println(s2)\n println(s3)\n println(s4)\n println(s5)\n println(s6)\n \n \n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d5580928d96393050eaf58f61c457cd7", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport kotlin.math.sqrt\n\nprivate val reader = System.`in`.bufferedReader()\nprivate fun readLn() = reader.readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong()\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() }\nprivate val writer = PrintWriter(System.out.bufferedWriter())\nprivate fun write(any: Any) = writer.print(any)\nprivate fun writeLn(any: Any) = writer.println(any)\nprivate fun flush() = writer.flush()\n\nprivate fun factors(n: Long): List {\n val ret = mutableListOf()\n val limit = sqrt(n.toDouble()).toInt()\n for (i in 1..limit) {\n if (n % i == 0L) {\n ret.add(i.toLong())\n if (i.toLong() * i != n) {\n ret.add(n / i)\n }\n }\n }\n ret.sort()\n return ret\n}\n\nfun main() {\n run {\n val (n, k) = readLongs()\n val factors = factors(n)\n// for (factor in factors) {\n// debug(factor)\n// }\n val cache = mutableMapOf, Map>()\n\n fun solve(n: Long, k: Int): Map {\n if (k == 0) {\n return mapOf(n to 1L)\n }\n if (cache.containsKey(n to k)) {\n return cache[n to k] ?: error(\"wtf\")\n }\n val ret = mutableMapOf()\n var cnt = 0\n for (factor in factors) {\n if (factor > n) {\n break\n }\n if (n % factor != 0L) {\n continue\n }\n cnt++\n val ret1 = solve(n / factor, k - 1)\n for (entry in ret1) {\n ret.compute(entry.key) { _, v ->\n v?.addMod(entry.value) ?: entry.value\n }\n }\n }\n// debug(\"$n has $cnt factors\")\n\n for (entry in ret) {\n ret.compute(entry.key) { _, v ->\n v?.divMod(cnt.toLong()) ?: error(\"wtf\")\n }\n }\n\n cache[n to k] = ret\n return ret\n }\n\n val final = solve(n, k.toInt())\n var ans = 0L\n for (x in final) {\n// debug(\"${x.key} ${x.value}\")\n ans = ans.addMod(x.key.mulMod(x.value))\n// debug(ans)\n }\n writeLn(ans)\n }\n flush()\n}\n\nprivate fun Pair.fractionPlus(other: Pair): Pair {\n return first * other.second + other.first * second to second * other.second\n}\n\nprivate fun invMod0(a: Long, m: Long): Long {\n val ans = extGcd(a, m)\n return if (ans[0] == 1L) (ans[1] + m) % m else -1\n}\n\nprivate fun extGcd(a: Long, m: Long): LongArray {\n return if (m == 0L) {\n longArrayOf(a, 1, 0)\n } else {\n val ans = extGcd(m, a % m)\n val tmp = ans[1]\n ans[1] = ans[2]\n ans[2] = tmp\n ans[2] -= ans[1] * (a / m)\n ans\n }\n}\n\nprivate const val MODULO = (1e9 + 7).toLong()\nprivate fun Long.addMod(other: Long): Long {\n var ret = this + other\n while (ret >= MODULO) {\n ret -= MODULO\n }\n while (ret < 0) {\n ret += MODULO\n }\n return ret\n}\n\nprivate fun Long.subMod(other: Long) = addMod(-other)\nprivate fun Long.mulMod(other: Long) = this % MODULO * other % MODULO\nprivate fun Long.invMod() = invMod0(this, MODULO)\nprivate fun Long.divMod(other: Long) = mulMod(other.invMod())\n\nprivate fun debug(any: Any) {\n System.err.println(any)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2673db244874b74ac279957c1bb22b23", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "const val MOD = 1_000_000_007\n\nfun main(args: Array) {\n var (n, k) = readLine()!!.split(' ').map(String::toLong)\n\n var result = 1\n var d = 2L\n while (d * d <= n) {\n var deg = 0\n while (n % d == 0L) {\n n /= d\n ++deg\n }\n result = mult(result, f(d, deg, k.toInt()))\n ++d\n }\n if (n > 1) {\n result = mult(result, f(n, 1, k.toInt()))\n }\n println(result)\n}\n\nfun f(_p: Long, deg: Int, k: Int): Int {\n val dp = Array(k + 1) { IntArray(deg + 1) }\n dp[0][deg] = 1\n for (step in 1..k) {\n for (d in 0..deg) {\n for (nd in d..deg) {\n dp[step][d] = add(dp[step][d], mult(dp[step - 1][nd], inverse(nd + 1)))\n }\n }\n }\n var result = 0\n var pi = 1\n val p = (_p % MOD).toInt()\n for (i in 0..deg) {\n result = add(result, mult(dp[k][i], pi))\n pi = mult(pi, p)\n }\n return result\n}\n\nfun inverse(n: Int) = binPow(n, MOD - 2)\n\nfun binPow(x: Int, n: Int): Int {\n return when {\n n == 0 -> 1\n n % 2 == 1 -> mult(x, binPow(x, n - 1))\n else -> {\n val half = binPow(x, n / 2)\n mult(half, half)\n }\n }\n}\n\nfun add(a: Int, b: Int) = (a + b) % MOD\n\nfun mult(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6a1be22f8943c3599bef87be8ce0657e", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport kotlin.math.log\nimport kotlin.math.sqrt\n\nprivate val reader = System.`in`.bufferedReader()\nprivate fun readLn() = reader.readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong()\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() }\nprivate val writer = PrintWriter(System.out.bufferedWriter())\nprivate fun write(any: Any) = writer.print(any)\nprivate fun writeLn(any: Any) = writer.println(any)\nprivate fun flush() = writer.flush()\n\nfun main() {\n Thread(null, {\n val (n, kTmp) = readLongs()\n val k = kTmp.toInt()\n debug(\"k=$k\")\n\n val t = System.nanoTime()\n\n val primeFactors = mutableListOf>() // (prime, exp)\n run {\n val limit = sqrt(n.toDouble()).toInt()\n var nn = n\n for (i in 2..limit) {\n if (nn % i == 0L) {\n var cnt = 0\n while (nn % i == 0L) {\n cnt++\n nn /= i\n }\n primeFactors.add(i.toLong() to cnt)\n }\n }\n if (nn > 1) {\n primeFactors.add(nn to 1)\n }\n for (primeFactor in primeFactors) {\n debug(primeFactor)\n }\n }\n\n val invs = LongArray(log(1e15, 2.0).toInt() + 10)\n debug(invs.size)\n for (i in invs.indices) {\n invs[i] = i.toLong().invMod2()\n }\n\n var ans = 1L\n\n fun solve(p: Long, e: Int): Long {\n val props = Array(k + 1) { LongArray(e + 1) { 0 } }\n val ev = Array(k + 1) { LongArray(e + 1) { 0 } }\n for (i in 0..e) {\n props[0][i] = 1\n ev[0][i] = p.powerMod(i)\n }\n for (kk in 1..k) {\n for (i in 0..e) {\n for (j in 0..i) {\n props[kk][i] = props[kk][i].addMod(props[kk - 1][j])\n ev[kk][i] = ev[kk][i].addMod(ev[kk - 1][j])\n }\n props[kk][i] = props[kk][i].mulMod(invs[i + 1])\n ev[kk][i] = ev[kk][i].mulMod(invs[i + 1])\n }\n }\n return ev[k][e]\n }\n\n for ((p, exp) in primeFactors) {\n ans = ans.mulMod(solve(p, exp))\n }\n\n writeLn(ans)\n\n debug(\"time: ${(System.nanoTime() - t) / 1e9}\")\n }, \"cool\", 1 shl 28).apply {\n start()\n join()\n }\n flush()\n}\n\nprivate fun invMod0(a: Long, m: Long): Long {\n val ans = extGcd(a, m)\n return if (ans[0] == 1L) (ans[1] + m) % m else -1\n}\n\nprivate fun extGcd(a: Long, m: Long): LongArray {\n return if (m == 0L) {\n longArrayOf(a, 1, 0)\n } else {\n val ans = extGcd(m, a % m)\n val tmp = ans[1]\n ans[1] = ans[2]\n ans[2] = tmp\n ans[2] -= ans[1] * (a / m)\n ans\n }\n}\n\nprivate fun Long.sqr() = this * this\n\nprivate const val MODULO = (1e9 + 7).toLong()\nprivate fun Long.addMod(other: Long): Long {\n var ret = this + other\n while (ret >= MODULO) {\n ret -= MODULO\n }\n while (ret < 0) {\n ret += MODULO\n }\n return ret\n}\n\nprivate fun Long.subMod(other: Long) = addMod(-other)\nprivate fun Long.mulMod(other: Long) = this % MODULO * (other % MODULO) % MODULO\nprivate fun Long.invMod() = invMod0(this, MODULO)\nprivate fun Long.invMod2() = powerMod(MODULO - 2)\nprivate fun Long.divMod(other: Long) = mulMod(other.invMod2())\nprivate fun Long.powerMod(exp: Int) = powerMod(exp.toLong())\nprivate fun Long.powerMod(exp: Long): Long = when {\n exp == 0L -> 1\n exp % 2 == 0L -> powerMod(exp / 2).sqr() % MODULO\n else -> powerMod(exp - 1).mulMod(this)\n}\n\nprivate fun debug(any: Any) {\n System.err.println(any)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "700fb9525d465206615e0577840e28c5", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.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 n = r.readLine()!!.toInt()\n //val l = r.readLine()!!.split(\" \").map { it.toInt() }\n //val n = r.readLine()!!.toInt()\n val (a, b, s) = r.readLine()!!.split(\" \").map { it.toLong() }.sorted()\n println(if ((s-a-b)%2==0L && s>= abs(a)+ abs(b)) \"Yes\" else \"No\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "23064bec846eafc78f9e5d75a7998033", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Kotlin 1.4", "source_code": "import kotlin.random.Random.Default.nextLong\n\nval br = System.`in`.bufferedReader()\nfun readInt() = br.readLine()!!.toInt()\nfun readInts() = br.readLine()!!.split(\" \").map { it.toInt() }\nfun readLongs() = br.readLine()!!.split(\" \").map { it.toLong() }\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n\nclass segTree(\n val leftMost: Int,\n val rightMost: Int,\n var leftChild: segTree? = null,\n var rightChild: segTree? = null,\n var value: Long = 0L, // can put more data here\n var size: Int = 1, // should be rightMost - leftMost + 1\n var toProp: Long = 0L\n) {\n\n constructor(tl: Int, tr: Int, a: List) : this(leftMost = tl, rightMost = tr) {\n if (tl == tr) {\n value = a[tl].toLong()\n } else {\n val mid = (tl + tr) / 2\n leftChild = segTree(tl, mid, a)\n rightChild = segTree(mid + 1, tr, a)\n size = tr - tl + 1\n recalc()\n }\n }\n\n // can change to other function, not just for sum (also change rangeSum function)\n // function does: combine two child to get parent's data\n fun recalc() {\n if (leftMost == rightMost) return\n else value = leftChild!!.value + rightChild!!.value\n }\n\n // should not be leaf\n fun prop() {\n leftChild\n }\n\n fun pointUpdate(index: Int, newVal: Long) {\n if (leftMost == rightMost) {\n value = newVal; return\n } // leaf node, just update value\n if (index <= leftChild!!.rightMost) leftChild!!.pointUpdate(index, newVal)\n else rightChild!!.pointUpdate(index, newVal)\n // child may change, so recalculate value\n recalc()\n }\n\n fun rangeQuery(l: Int, r: Int): Long {\n // entirely disjoint\n if (l > rightMost || r < leftMost) return 0L\n // covers us\n if (l <= leftMost && rightMost <= r) return value\n // we don't know\n return leftChild!!.rangeQuery(l, r) + rightChild!!.rangeQuery(l, r)\n }\n}\n\n\n// Range update (lazy propagetino), range sum (log n time)\nclass Treap(\n var key: Long, // key\n val priority: Long, // priority\n val kids: MutableList = MutableList(2) { null },\n var subtreeSize: Long = 0,\n var sum: Long = 0L, // upper treap use sum\n var toProp: Long = 0L\n) {\n\n // return size of subtree (include this node)\n fun size(t: Treap?) = t?.subtreeSize ?: 0\n\n // update subtreeSize and sum for this node. so what is sum,\n private fun recalc(t: Treap?) {\n if (t == null) return\n t.subtreeSize = 1\n t.sum =\n t.key + t.toProp * size(t) // when should propagate data ???? so size should be 1 because just set it subtreeSize to 1\n t.kids.forEach {\n if (it != null) {\n t.subtreeSize += it.subtreeSize; t.sum += it.key + it.toProp * size(it)\n }\n }\n }\n\n // when range update, first split treap to three part(mostly), int middle part, update all value with some number by lazy propagation\n private fun prop(t: Treap?) {\n if (t == null || t.toProp == 0L) return\n t.kids.forEach { if (it != null) it.toProp += t.toProp } // propagate to child\n t.key += t.toProp // also propagate to itself\n t.toProp = 0L // clear propagate value after propagate\n recalc(t) // will sum change ??? : kid may have change value\n }\n\n\n private fun split(t: Treap?, nInLeft: Long): List {\n if (t == null) return List(2) { null }\n prop(t) // before make any change, propagate value to child\n if (size(t.kids[0]) >= nInLeft) { // Treap t(this one) is in right half of treap\n val (left, right) = split(t.kids[0], nInLeft) // keep split left treap because it has more treap\n t.kids[0] = right\n recalc(t) // any time make change, should recalculate treap\n return listOf(left, t) // left should have iInLeft treap in it.\n } else {\n // Treap t(this one) is in left half of treap, t's right child should return [nInLeft - size(t.kids[0]) - 1] treap to make total of nInLeft in first return treap\n // split result can be null when nInLeft = size(t.kids[0]) + 1, right child return null\n val (left, right) = split(t.kids[1], nInLeft - size(t.kids[0]) - 1)\n t.kids[1] = left\n recalc(t) // any time make change, should recalculate treap\n return listOf(t, right)\n }\n }\n\n // for insert treap\n fun merge(l: Treap?, r: Treap?): Treap? {\n if (l == null) return r\n if (r == null) return l\n prop(l) // before use, propagate value\n prop(r)// before use, propagate value\n if (l.priority < r.priority) { // l should on the top, l's right child become merge result of l's right child and r\n l.kids[1] = merge(l.kids[1], r)\n recalc(l) // after change, recalculate value\n return l\n } else {\n r.kids[0] = merge(l, r.kids[0])\n recalc(r) // after change, recalculate value\n return r\n }\n }\n\n // l and r in 0..n-1 where n is number of treap\n fun rangeAdd(t: Treap?, l: Long, r: Long, toAdd: Long): Treap {\n assert(t != null)\n val (a, b) = split(t, l)\n val (c, d) = split(b, r - l + 1) // treap become a c d, and c is which we want to update\n c!!.toProp += toAdd // c should not be null here\n return merge(a, merge(c, d))!! // this should not null\n }\n\n fun rangeSum(t: Treap, l: Long, r: Long): Pair {\n // before split, should propagate t's toProp.\n val (a, b) = split(t, l)\n val (c, d) = split(b, r - l + 1) // treap become a c d, and c is include sum we need\n val rootTreap = merge(a, merge(c, d))\n return Pair(rootTreap!!, c!!.sum)\n }\n}\n\nfun main() {\n val sb = StringBuilder()\n //repeat(readInt()) {\n // special case, use dp,\n // op: << +1/+0, << +1/+0,\n // 10010010...10001\n // 0+0 -> delete\n // 0+1 -> len++\n // 1+0 -> not know\n // 1+1 -> len++\n // 101001 10 101001 001 || 101001 001 || 10 101001\n // first remove right zero\n // then add some number and end with 1\n // then reverse\n // then add some number and end with 1\n // then reverse\n // \u524d\u540e\u90fd\u52a0 -\u300b\u987a\u5e8f\u4e0d\u53d8 -\u300b substr \u5373\u53ef\n // \u53ea\u52a0\u540e\u9762\uff0c\u53cd\u5411 substr \u5e76\u4e14 \u521a\u597d\u662f\u672b\u5c3e\n // \u672b\u5c3e\u662f0\u4e0d\u884c\uff0c\u9664\u975e\u521a\u5f00\u59cb\u5c31\u4e00\u6837\n var (x, y) = readLongs()\n fun stringToNum(s: String): Long {\n var ans = 0L\n for (i in s.length - 1 downTo 0) {\n if (s[i] == '1') ans += 1 shl (s.length - 1 - i)\n }\n return ans\n }\n\n var c = x // plus 0\n while (c % 2 == 0L) c /= 2\n val d = stringToNum(c.toString(2).reversed()) // plus 0 reverse\n val a = (x shl 1) +1 // plus 1\n val b = stringToNum(a.toString(2).reversed())\n fun sub(a: Long, b: Long): Boolean {\n val stra = a.toString(2)\n val strb = b.toString(2)\n if (stra.length>strb.length) return false\n val mid = stra.length\n var check = false\n //println(\"$stra, $strb\")\n for (i in 0.. strb.length-stra.length){ // 1 front\n //println(\"enter\")\n var ans = true\n for (j in 0 until i) if (strb[j]!='1') ans = false\n for (j in i until i+stra.length) if (strb[j]!=stra[j-i]) ans = false\n for (j in i+stra.length until strb.length) if (strb[j]!='1') ans = false\n //if (ans) println(\"$stra, $strb, strat index $i\")\n if (ans) check = true\n }\n return check\n }\n\n val ans = sub(a, y) || sub(b, y) || sub(c, y) || sub(d, y) || (x == y)\n\n sb.appendLine(if (ans) \"YES\" else \"NO\")\n\n println(sb)\n\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "2bad37bda4150849e62d93886c1407b8", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "Kotlin", "source_code": "import kotlin.math.*\n\nfun main() {\n val n = readInt()\n\n val ans = n.toBigInteger().bitLength()\n\n println(ans)\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 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": "c4c7dcd87e48f39e87e4499bfd6c9588", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n val n = readLine()!!.toInt()\n var s = 0L\n var i = 1\n var x = 0\n while(s < n) {\n s+=i\n i*=2\n x++\n }\n println(x)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "86f632956a16c07b92a00f83b8c238f0", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\nvar sc = Scanner(System.`in`)\nval x = sc.nextInt()\n var h = sc.nextInt()\n val m = sc.nextInt()\n if (m%10==7 || h%10 == 7){\n println(0)\n return\n }else {\n var dec = m-x\n var occ = 1\n while (true){\n\n if (dec%10==7 || h%10 ==7)break\n if (dec<0){\n h--\n if (h <0){\n h=23\n }\n dec=60+dec\n occ--\n }else if (dec<60){\n dec-=x\n }else {\n dec+=x-60\n }\n occ++\n }\n println(occ)\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4224729f77382a2abd16af9a39cb5a07", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "val M = 1000000007L\nval N = 200005\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": "d81d69817e5386fb58986d9f35aa7c08", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.collections.HashMap\n\nfun main(args : Array) {\n val input = Scanner(System.`in`)\n var city = HashMap()\n\n var j=0\n val n = input.nextInt()\n val u = input.nextInt()\n var sum = u\n if (n < u){\n println(n -1)\n } else {\n for (i in n downTo 1){\n city.put(i, j)\n if (j < u){\n j++\n } else {\n sum += i*1\n }\n }\n println(sum-1)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "59d9c4e1bd58656fb8bb64f25e844155", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\n//2019-02-18\nfun main(args: Array) = with(Scanner(System.`in`)) {\n val n = nextInt()\n val v = nextInt()\n var diff = v - (n - 1)\n if (diff >= 0) {\n print(n - 1)\n } else {\n diff *= -1\n print((2 + diff + 1) * diff / 2 + v)\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "9a76beb47dd1fba9dcee895170844454", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "fun main() {\n val (a, b) = readLine()!!.split(\" \")\n print(if (a == b) a else 1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "d98f17a54660ca7980f384b3207a53a6", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun abs(x: Int) = if (x >= 0) x else -x\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 = abs(pos - l) + 1 + (1 + r - l) * (if (r != n) 1 else 0)\n val rightToLeft = abs(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": "09991a4ef83a9714db0743e43c3e5635", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\nimport kotlin.system.exitProcess\nimport kotlin.math.*\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 longs\nprivate fun exit() : Nothing = exitProcess(0)\n\ninline fun > min(x : T, y : T): T{\n if(x < y){return x;}\n else{return y;}\n}\n\ninline fun > max(x : T, y : T): T{\n if(x > y){return x;}\n else{return y;}\n}\n\nfun getid(row : Int): Int{\n val kek = (row - 1)/2;\n return 2 + 3 * kek;\n}\n\nfun main(){\n var (a, x, y) = readInts();\n a = a * 2;\n x = x * 2;\n y = y * 2;\n if(y%a == 0){\n println(-1);\n return;\n }\n val row = y/a;\n if(row <= 1){\n if(abs(x) >= a/2){println(-1);}\n else{println(row + 1);}\n return;\n }\n if(row%2 == 0){\n if(x != 0 && abs(x) < a){\n if(x < 0)println(getid(row - 1) + 1);\n else println(getid(row - 1) + 2);\n }\n else{println(-1);}\n }\n else{\n if(abs(x) < a/2){println(getid(row));}\n else{println(-1);}\n }\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e956683e3307393c6d2dd37b5a8c75cd", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Kotlin", "source_code": "fun main()\n{\n println(\"INTERCAL\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "747ae25b3d2620157769ff914efc7f4c", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "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\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 .. 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 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": "d707d04f5a4e9f5b6b856fa626d5ff8b", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Kotlin 1.4", "source_code": "fun main() {\r\n val (h, w) = readLine()!!.split(' ').map { it.toInt() }\r\n val cake = List(h) { readLine()!!.map { it == '*' } }\r\n var i = 0\r\n var j = 0\r\n var ans = 0\r\n while (i + 1 < h || j + 1 < w){\r\n ans += if (cake[i][j]) 1 else 0\r\n if (i + 1 == h) {\r\n j++\r\n } else {\r\n if (j + 1 == w) {\r\n i++\r\n } else {\r\n if (cake[i + 1][j]) i++ else j++\r\n }\r\n }\r\n }\r\n println(ans + if (cake[i][j]) 1 else 0)\r\n}\r\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6e15629a82fe46cd906e0b62c6875a18", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.util.Scanner\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 p1 = 0\n var p2 = 0\n\n if(a<=x || b<=y){\n print(0)\n print(\" \")\n print(0)\n }\n else{\n var a1 = a / x\n var b1 = b / y\n\n if(a1>=b1){\n p1 = b1 * x\n p2 = b1 * y\n }\n else{\n p1 = a1 * x\n p2 = a1 * y\n }\n print(p1)\n print(\" \")\n print(p2)\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ae9fc908e062dd6dc63d6b59d2c84e8f", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.*\n\nfun main(vararg args:String) {\n val n = readLine()!!.toInt()\n var b = (Math.sqrt(n.toDouble())).toInt()\n while (n % b != 0)\n b--\n println(\"$b \" + n / b)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "cd263051fc888e7921cbb50e7f151214", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Integer.min\n\nfun main(args: Array) {\n var t = arrayListOf()\n repeat(8) { t.add(readLine()!!) }\n var (a, b) = 8 to 8\n for (i in 0..7) {\n t.map { it[i] }.foldIndexed(false to 8) { i, acc, c ->\n var (metB, bestB) = acc\n if (c == 'W' && !metB) {\n a = min(a, i)\n bestB = 8\n }\n if (c == 'B') {\n metB = true\n bestB = 7 - i\n }\n\n metB to bestB\n }.let { b = min(b, it.second) }\n }\n print(if (b < a) \"B\" else \"A\")\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ee9509bf9abfbc81008b799a365bd7fe", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.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 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": "637dbe0eddd2de3024910f3e36cade0e", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\n\nfun > max(a: T, b: T): T = if (b > a) b else a\nfun > min(a: T, b: T): T = if (b < a) b else a\nfun Number.isEven(): Boolean = if (this.toInt() and 1 == 0) true else false\nfun Number.isOdd(): Boolean = !this.isEven()\n\nfun main(args: Array) {\n if (args.isNotEmpty()) 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 str = st.nextToken()\n var hasDigit = false; var hasLower = false; var hasUpper = false\n for (c in str) {\n if (c >= '0' && c <= '9') hasDigit = true\n else if (c >= 'a' && c <= 'z') hasLower = true\n else if (c >= 'A' && c <= 'Z') hasUpper = true\n }\n if (str.length >= 5 && hasDigit && hasLower && hasUpper) bw.write(\"Correct\")\n else bw.write(\"Too weak\")\n bw.newLine()\n bw.flush()\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "ccad7c8e4dd3a6d76fcd3ec371da66f3", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n //val n = r.readLine()!!\n var (a, b, c) = r.readLine()!!.split(\" \").map { it.toInt() }\n b -= 1\n c %= a\n\n b += a\n b += c\n b %= a\n b += 1\n println(b)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "66d90a47b8cc68214124e7ac51e96218", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.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} ${2+t1}\")\n } else {\n println(\"${n-t0} ${1+m-1-t1}\")\n }\n }\n }\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "eb7b479c1f2e1f4360214bb9947b66a1", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val b = longArrayOf( 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968);\n val a = sc.nextInt()\n print(b[a])\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "228eb8eed5615756c649c1b826752ade", "src_uid": "76f6ebfaeea789952c931d65c6a5fdff", "difficulty": 1900.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 && n == 1L) return true\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": "dfb4d138078c68472db5cf2969461a33", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.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.nextInt()\n val m = tokenizer.nextInt()\n val a = Array(n) { tokenizer.nextInt() }.apply {\n sort()\n reverse()\n }\n if (a.sum() < m)\n println(\"-1\")\n else {\n var l = 1\n var r = n\n while (l < r) {\n val mid = (l + r) / 2\n if (check(a, m, mid))\n r = mid\n else\n l = mid + 1\n }\n println(l)\n }\n}\n\nfun check(a: Array, m: Int, d: Int): Boolean {\n var sum = 0\n for (i in 0 until a.size) {\n val debuff = i / d\n if (a[i] <= debuff)\n break\n sum += a[i] - debuff\n }\n return sum >= m\n}\n\nfun StringTokenizer.nextInt() = nextToken().toInt()\nfun StringTokenizer.nextLong() = nextToken().toLong()\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "3fbdceebe7673acba36fa9b860310fcf", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0} {"lang": "Kotlin", "source_code": "import java.*\nimport java.util.*\nfun main(args: Array) {\n val `in` = Scanner(System.`in`)\n val n = `in`.nextInt()\n val m = `in`.nextInt()\n var maxIt = 0\n var maxChild = 0\n for (i in 0 until n) {\n val x = `in`.nextInt()\n val it = (x + (m - 1)) / m\n if (it >= maxIt) {\n maxIt = it\n maxChild = i\n }\n }\n println(maxChild + 1)\n\n\n }", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "911697db5c3fa4290d25caf9ade1aa2c", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.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, m) = r.readLine()!!.split(\" \").map { it.toInt() }\n val l = r.readLine()!!.split(\" \").map { it.toInt() }.map { it / m + if (it % m != 0) 1 else 0 }\n var max = Int.MIN_VALUE\n var ind = -1\n for (i in n-1 downTo 0){\n if (l[i]>max) {\n max = l[i]\n ind = i+1\n }\n }\n println(ind)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "6c01178a164d15c9b445ba3a33c881a6", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "\nimport kotlin.math.abs\nimport kotlin.math.max\n\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val (x1, y1) = readLongs()\n val (x2, y2) = readLongs()\n val a = abs(x2 - x1)\n val b = abs(y2 - y1)\n println(max(a, b))\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": "f41e9cd595d112dbf87f48cd724cd8ae", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.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 = 0\n while (1L shl p < power) {\n if (power and (1L shl p) != 0L) {\n ret = (ret * current) % MOD\n }\n current = (current * current) % MOD\n p++\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": "220b10e958c5d0a0468bc705902c4e04", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Kotlin", "source_code": "fun main() {\n fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\n val (watchPerSecond, downloadPerSecond, seconds) = readInts()\n var wait = (seconds * watchPerSecond - seconds * downloadPerSecond) / downloadPerSecond\n if (wait * downloadPerSecond + seconds * downloadPerSecond < watchPerSecond * seconds) wait++\n print(wait)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "06b4cb6ba83b7cad4318506e0e40ebeb", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "fun main() {\n val r = System.`in`.bufferedReader()\n val s = StringBuilder()\n var n = r.readLine()!!.toInt()\n val v = r.readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n n %= v.sum()\n (1..6).forEach { v[it]+=v[it-1] }\n fun b(x: Int): Int {\n var le = 0\n var ri = 7\n while (le < ri) {\n val mi = le + (ri - le) / 2\n when {\n v[mi] < x -> le = mi + 1\n v[mi] >= x -> ri = mi\n }\n }\n return le % 7 + 1\n }\n println(b(n))\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "042a3894a48a15f63733849fb8cc3adc", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n\n val scanner = Scanner(System.`in`)\n\n val n = scanner.nextLine().toInt()\n\n val a = scanner.nextLine()\n\n val values = a.split(' ').map { it.toInt() }\n\n val sum = values.sum()\n\n if (sum != 0) {\n System.out.println(\"YES\")\n System.out.println(1)\n System.out.println(\"1 $n\")\n } else {\n\n val countZeros = values.count { it == 0 }\n if (countZeros == values.size) {\n System.out.println(\"NO\")\n } else {\n\n var currentSum = 0\n var i = 0\n\n while (currentSum == 0) {\n currentSum += values[i]\n i++\n }\n\n System.out.println(\"YES\")\n System.out.println(2)\n System.out.println(\"1 ${i+1}\")\n System.out.println(\"${i+2} ${values.size}\")\n\n }\n\n\n\n// val partsum1 = values.take\n\n\n\n\n }\n\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "545de561129bed57d041fdf049bc95f3", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nimport kotlin.Comparator\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\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 (year, month, day) = reader.readLine().split(':').map(String::toInt)\n val (year2, month2, day2) = reader.readLine().split(':').map(String::toInt)\n val start = Calendar.getInstance().apply { set(year + 400, month, day) }\n val end = Calendar.getInstance().apply { set(year2 + 400, month2, day2) }\n val result = abs(end.timeInMillis - start.timeInMillis + 1) / 1000\n writer.println(result / 3600 / 24)\n}\n", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "8f33a634294e9edc7480fc8ba00bb058", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "fun main() {\n var nominal: Int = readLine()!!.toInt()\n var greatestDivisor = 2\n while(nominal>1){\n println(nominal)\n while(nominal%greatestDivisor!=0) greatestDivisor++\n nominal/=greatestDivisor\n }\n println(1)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "60c3e26d3f72cd314f4d34ac9613175a", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "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 '9'->count+=6\n }\n }\n }\n println(count)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b328b8dc767be2e0e478af59d702ef69", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.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 xor 0\n if (cCandidate in b..min(n, a + b - 1)) sol++\n }\n print(sol)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "b1d181431ff233be2a19e61da142c12f", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Kotlin", "source_code": "import java.io.PrintWriter\nimport kotlin.math.min\n\n\nfun main() {\n io.apply {\n\n val sum = int\n val k = int\n val wMin = int\n\n val M = 1000000007\n\n val dp0 = IntArray(sum + 1)\n val dp1 = IntArray(sum + 1)\n dp0[0] = 1\n for (i in 1..sum) {\n for (j in 1 .. k) {\n if (i - j >= 0) {\n dp1[i] = (dp1[i] + dp1[i - j]) % M\n if (j < wMin) {\n dp0[i] = (dp0[i] + dp0[i - j]) % M\n } else\n dp1[i] = (dp1[i] + dp0[i - j]) % M\n }\n }\n }\n\n cout .. dp1[sum] .. 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 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": "9603db98165b30c1082e5495217c7acf", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.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): Int {\n var z = z\n var res = 0\n while (z > 0L) {\n if (z and 1L == 1L) {\n if (z and 3L == 3L) {\n z++\n } else {\n z--\n }\n res++\n }\n z = z shr 1\n }\n return res\n }\n var answer = Long.MAX_VALUE\n for (e in 0..29) {\n answer = min(answer, (e.toLong() * y) + (((n shr e) + minChanges(n % (1L shl e))) * x))\n }\n println(answer)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "0222e1b47c62389ec89babd45d513b5f", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.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\n var nodValue = if (x < y) nod(x, y) else nod(y, x)\n\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": "5cacf273d4d5bbf6ba3beee7bfadebea", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Kotlin", "source_code": "import java.io.*\nimport java.util.*\nfun main(args : Array) = Thread { run() }.start()\n\nfun run() {\n\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val arr1 = IntArray(n) { scanner.nextInt() }\n val arr2 = IntArray(n) { scanner.nextInt() }\n if (arr1.sum() >= arr2.sum())\n println(\"Yes\")\n else\n println(\"No\")\n\n\n}\n\n\nclass Parser(`in`: InputStream) {\n private val BUFFER_SIZE = 1 shl 16\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 fun nextString(maxSize: Int): String {\n val ch = ByteArray(maxSize)\n var point = 0\n try {\n var c = read()\n while (c == ' '.toByte() || c == '\\n'.toByte() || c == '\\r'.toByte())\n c = read()\n while (c != ' '.toByte() && c != '\\n'.toByte() && c != '\\r'.toByte()) {\n ch[point++] = c\n c = read()\n }\n } catch (e: Exception) {}\n\n return String(ch, 0, point)\n }\n\n fun nextInt(): Int {\n var ret = 0\n val neg: Boolean\n try {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n 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\n if (neg) return -ret\n } catch (e: Exception) {}\n return ret\n }\n\n fun nextLong(): Long {\n var ret: Long = 0\n val neg: Boolean\n try {\n var c = read()\n while (c <= ' '.toByte())\n c = read()\n 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\n if (neg) return -ret\n } catch (e: Exception) {}\n\n return ret\n }\n\n fun nextDouble(): Double\n = nextString(10000).toDouble()\n\n private fun fillBuffer() {\n try {\n bytesRead = din.read(buffer, 0, BUFFER_SIZE)\n } catch (e: Exception) {}\n if (bytesRead == -1) buffer[0] = -1\n }\n\n private fun read(): Byte {\n if (bufferPointer == bytesRead) fillBuffer()\n return buffer[bufferPointer++]\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)\nfun min(a: Char, b: Char): Int {\n if (a < b)\n return a.toInt()\n return b.toInt()\n}\nfun max(a: Char, b: Char): Int {\n if (a > b)\n return a.toInt()\n return b.toInt()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "4bd0c9c0ee6d3f1f27d2bcca9f9089da", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "Kotlin", "source_code": "import java.lang.Long.max\nimport java.util.*\nimport java.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\nval mod=998244353L\nfun mul(x:Long,y:Long):Long=x*y%mod\nfun add(x:Long,y:Long):Long{\n val z=x+y\n if(z>=mod)return z-mod\n else return z\n}\nfun sub(x:Long,y:Long):Long{\n val z=x-y\n if(z<0L)return z+mod\n else return z\n}\nfun pw(_x:Long,_k:Long):Long{\n var ans=1L\n var k=_k\n var x=_x\n while(k>0){\n if(k%2L==1L)ans=mul(ans,x)\n x=mul(x,x)\n k/=2L\n }\n return ans;\n}\n\nfun main(){\n var (n,k)=readLongs()\n var F=LongArray((n+1).toInt()){1}\n var I=LongArray((n+1).toInt()){1}\n for(i in 1..n)F[i.toInt()]=mul(F[(i-1).toInt()],i)\n for(i in 2..n)I[i.toInt()]=mul((mod-mod/i),I[(mod%i).toInt()])\n for(i in 1..n)I[i.toInt()]=mul(I[i.toInt()],I[(i-1).toInt()])\n fun binom(n:Long,k:Long):Long{\n return mul(F[n.toInt()],mul(I[(n-k).toInt()],I[k.toInt()]))\n }\n if(k>=n)printLine(\"0\")\n else{\n var m=n-k\n var ans=0L\n var bsz=0L\n for(i in m downTo 1){\n bsz=binom(n-i,m-i)\n var now=mul(mul(binom(n,i),pw(i,n)),bsz)\n if((m-i)%2L==0L){\n ans=add(ans,now)\n }else{\n ans=sub(ans,now)\n }\n }\n if(k!=0L)ans=mul(ans,2)\n printLine(\"$ans\")\n }\n output()\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "5626ad31dba25cc1dc584acb347d453a", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.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 = when {\n v >= v1 -> v\n v + a > v1 -> v1\n else -> v + a\n }\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": "ab61bddb543128e84be870bec5ed88b3", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Kotlin", "source_code": "import java.util.*\n\nfun main(args: Array) {\n\n var sc = Scanner(System.`in`)\n var n = sc.nextInt()\n var x=0\n var max = 0\n for (i in 0 .. n-1){\n x=sc.nextInt()\n max= maxOf(x,max)\n }\n max = maxOf(0,max-25)\n println(max)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "59c2f95675feb0c355b91782a8a581bc", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "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 solve(input: BufferedReader, output: PrintWriter) {\n val line = input.readLine()\n val c = line[0]\n val n = line[1]\n\n val top = when {\n n == '1' -> 0\n c == 'a' || c == 'h' -> 2\n else -> 3\n }\n\n val bottom = when {\n n == '8' -> 0\n c == 'a' || c == 'h' -> 2\n else -> 3\n }\n\n val leftRight = when {\n c == 'a' || c == 'h' -> 1\n else -> 2\n }\n\n output.println(top + bottom + leftRight)\n}", "lang_cluster": "Kotlin", "compilation_error": false, "code_uid": "e18286be33d45aa83c67180c3a78a098", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0}